1.0.1 • Published 6 months ago

@tryforge/forge.api v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

ForgeAPI

ForgeAPI, the best way to interact with your ForgeScript bot and it's server.

@tryforge/forge.api @tryforge/forgescript Discord

How to use

Download from npm:

npm i @tryforge/forge.api

in your client initialization:

const { ForgeAPI } = require("@tryforge/forge.api")

const api = new ForgeAPI({
  port: number,
  logLevel?: number,
  auth: {
    bearer?: boolean,
    type: number,
    code?: string | string[],
    ip?: string | string[]
  }
})

const client = new ForgeClient({
  ...
  "extensions": [api]
})

api.router.load("path")
nameInputdescriptionRequired
portnumberThe port to open for the apitrue
logLevel0/1/20 = none | 1 = all | 2 = debugfalse
auth.bearerbooleanIf true the client will make a bearer token.false
auth.type0/1/20 = no auth | 1 = either token or ip | 2 = both token and iptrue
auth.codestring[]SecretKey used for non bearer authfalse
auth.ipstring[]The ips who are allowed to make requests.false

Making Routes on <path>/<filename>

module.exports = {
  url: '/string',
  method: "type",
  auth: boolean,
  handler: async function (ctx) {
    <code>
  },
}
nameInputdescriptionRequired
Url/stringThe endpoint to appoint this totrue
methodestringGet / Put / Post / Delete / patch / options / trace / connecttrue
authBooleanIf false ForgeAPI wont check for authentication (ip/token)true
handlerstringthe code to run if connected successfullytrue

You can also check our endpoint templates at our template brench.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

1.0.1

6 months ago

1.0.0

11 months ago

0.1.1

1 year ago

0.1.0

1 year ago