Socket
Book a DemoInstallSign in
Socket

forgeapi

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

forgeapi

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

unpublished
latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

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:

FAQs

Package last updated on 15 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts