ForgeAPI, the best way to interact with your ForgeScript bot and it's server.
npm install @tryforge/forge.apibash
npm i @tryforge/forge.api
`
in your client initialization:
`js
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
`js
module.exports = {
url: '/string',
method: "type",
auth: boolean,
handler: async function (ctx) {
},
}
``
| 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].
[template brench]: https://github.com/tryForge/forgeAPI/tree/templates
Contributors ✨
Thanks goes to these wonderful people (emoji key):
Agglos-007
💻
Lynnux
⚠️