Skip to content

A simple REST client inspired by Discord.js' Client#api.

Notifications You must be signed in to change notification settings

Ciach0/rest-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST Builder

REST Builder is a library for making requests, heavily inspired by Discord.js' Client#api.

Installation

Use the package manager npm or yarn to install REST Builder.

npm i rest-builder
# OR
yarn add rest-builder

Important

rest-builder is an asynchronous library, so you should use it in an asynchronous environment or utilize .then().

Usage

Using CommonJS

const RESTBuilder = require('rest-builder');

async function main() {
  const client = new RESTBuilder({
    baseURL: 'https://example.com'
  });
  // client.api is the entrypoint to HTTP requests
  // to use an HTTP method, simply put .[your method]() at the end of your expression.
  const response = await client.api.users['userid'].setttings.get(); // invoke an HTTP GET method (equivalent to /users/userid/settings)
  console.log(response);
}
main();

Using ES Modules

import RESTBuilder from 'rest-builder';

const client = new RESTBuilder({
  baseURL: 'https://example.com'
});

const response = await client.api.users['userid'].settings.get(); // in ES Modules, you are able to use await at the top level
console.log(response);

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

GPL-3.0

About

A simple REST client inspired by Discord.js' Client#api.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published