1.0.5 • Published 1 year ago

rest-builder v1.0.5

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
1 year ago

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

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago