Skip to content

Latest commit

 

History

History
105 lines (86 loc) · 3.28 KB

readme.md

File metadata and controls

105 lines (86 loc) · 3.28 KB

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")
name Input description Required
port number The port to open for the api true
logLevel 0/1/2 0 = none | 1 = all | 2 = debug false
auth.bearer boolean If true the client will make a bearer token. false
auth.type 0/1/2 0 = no auth | 1 = either token or ip | 2 = both token and ip true
auth.code string[] SecretKey used for non bearer auth false
auth.ip string[] 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>
  },
}
name Input description Required
Url /string The endpoint to appoint this to true
methode string Get / Put / Post / Delete / patch / options / trace / connect true
auth Boolean If false ForgeAPI wont check for authentication (ip/token) true
handler string the code to run if connected successfully true

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

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Agglos-007
💻

Lynnux
⚠️