This package has been deprecated

    Author message:

    This package was renamed to petitio. Use petitio for updates.

    @helperdiscord/centra
    TypeScript icon, indicating that this package has built-in type declarations

    2.4.2 • Public • Published

    @helperdiscord/centra

    A cool library to use for rest requests in nodejs :) docs

    Examples

    Basic GET Request

    const req = require('@helperdiscord/centra');
    
    const res = await req('https://discord.com/api/gateway').json()
    
    console.log(res);
     
    // { url: 'wss://gateway.discord.gg' }

    Simple POST Request with payload

    const req = require('@helperdiscord/centra');
    
    const res = await req('https://discord.com/api/channels/418933739540840451/messages', 'POST').body({ content: 'hi' }).header({ 'Authorization': 'Bot youryoken' }).json()
    
    console.log(res);
    
    /* {
      id: '805925621561163806',
      type: 0,
      content: 'hi',
      channel_id: '418933739540840451',
      author: [Object],
      attachments: [],
      embeds: [],
      mentions: [],
      mention_roles: [],
      pinned: false,
      mention_everyone: false,
      tts: false,
      timestamp: '2021-02-01T22:20:41.554000+00:00',
      edited_timestamp: null,
      flags: 0,
      referenced_message: null
    } */

    Type casting json responses

    import req from '@helperdiscord/centra';
    
    type Gateway {
        url: string
    }
    
    const res = await req('https://discord.com/api/gateway').json<Gateway>();

    @helperdiscord/centra vs other http libraries

    Here's a size comparison table:

    Here you can see how efficient @helperdiscord/centra is compared in bundle size to other libraries

    Package Size
    request request package size
    superagent superagent package size
    got got package size
    axios axios package size
    isomorphic-fetch isomorphic-fetch package size
    r2 r2 package size
    node-fetch node-fetch package size
    phin phin package size
    @helperdiscord/centra @helperdiscord/centra package size

    Here's a performance comparison of @helperdiscord/centra vs other http libraries

    These results were procured using this

    Results (i7-7700k, CPU governor: performance):
    
    got - promise x 2,770 ops/sec ±6.67% (71 runs sampled)
    request - callback x 4,888 ops/sec ±7.46% (74 runs sampled)
    node-fetch - promise x 5,457 ops/sec ±3.33% (74 runs sampled)
    centra - promise x 8,263 ops/sec ±2.10% (84 runs sampled)
    https - stream x 7,453 ops/sec ±3.19% (78 runs sampled)
    @helperdiscord/centra - promise x 8,202 ops/sec ±1.30% (82 runs sampled)
    Fastest is @helperdiscord/centra - promise
    

    Keywords

    none

    Install

    npm i @helperdiscord/centra

    DownloadsWeekly Downloads

    56

    Version

    2.4.2

    License

    MIT

    Unpacked Size

    11.8 kB

    Total Files

    7

    Last publish

    Collaborators

    • fakevetlix
    • nytelife26
    • tbnritzdoge