0.0.1 • Published 4 months ago

forgeapi v0.0.1

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

ForgeAPI

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

forgeAPI forgescript Discord

How to use

Download this npm package:

npm i forgeapi

Now, in your client initialization:

const { ForgeAPI } = require("forgeapi")

// I'll assume client, can be bot or anything else
const client = new ForgeClient({
    ...options // The options you currently have
    extensions: [
        new ForgeAPI({
            port: number
            authorization?: string | string[]
        })
    ]
})

And voi-la, you now have ForgeAPI installed and loaded to your bot.

Note: if you add authorization you will have to assign in the headers

{
    "authorization": "1 of the assigned keys you added"
}

Endpoints

Default

EndpointMethodHas WS
/usageGETyes
/commandsGETyes
/guildsGETyes
/{guild.id}/leavePOSTno

Custom

Now, in your client initialization:

const { ForgeAPI } = require("forgeapi")

// I'll assume client, can be bot or anything else
const client = new ForgeClient({
    ...options // The options you currently have
    extensions: [
        new ForgeAPI({
            port: number
            load: string // Here add the path to load the custom endpoints
            authorization?: string | string[]
        })
    ]
})

On /<path>/<fileName> add this

const data = {
    url: '/endpoint',
    method: "HTTP Method",
    auth?: boolean,
    handler: async function (ctx) {
        ctx.reply.end('Endpoint here!');
    },
    wsHandler?: async funtion (ctx){
        ctx.ws.send('WebSocket here!')
    }
}

module.exports = { data }

Note: your const must always be named data.

More about RouteOptions:

0.0.1

4 months ago

1.0.0

1 year ago