npm
Source
Description
A plugin for@wolfstar/http-framework,
ported from @sapphire/plugin-api.
It exposes a standalone REST API server — for health checks, dashboards, or webhooks from other
services — built on the same @sapphire/pieces Route/Middleware conventions.
It is intentionally independent from Client#server (the interactions webhook): that server already
claims every path on its port and 404s anything that doesn’t match, so this plugin binds its own
ApiServer on a separate port instead of trying to share the same listener.
Installation
Usage
Import the side-effectingregister entrypoint before you create your Client:
Writing a route
Routes areRoute pieces loaded from a routes directory, exactly like commands/listeners:
src/routes/health.get.ts registers
GET /health. A folder named [id] becomes a dynamic segment (request.params.id), and a
(group)-style folder is skipped when building the path. Both can be overridden explicitly:
Writing a middleware
Middlewares areMiddleware pieces loaded from a middlewares directory, run in ascending
position order before route dispatch; a middleware stops the chain by ending the response:
headers (position 10, sets CORS headers and short-circuits OPTIONS
pre-flight requests) and body (position 20, rejects requests whose Content-Length exceeds
maximumBodyLength).
ApiServerOptions
Scope
Ported faithfully: theRoute/RouteStore piece conventions, the filesystem-routing/dynamic-segment
trie router (RouterRoot/RouterBranch/RouterNode), the position-ordered Middleware/MiddlewareStore
chain, and the listener-driven request dispatch pipeline (request → middlewares → routerFound /
routerBranchNotFound / routerBranchMethodNotAllowed → route run).
Not ported (out of scope for this webhook-only framework, kept for a future release): cookies,
OAuth2/session auth, and the built-in oauth/callback, oauth/logout routes from the original
@sapphire/plugin-api. Add your own auth middleware/routes as needed.