UNPKG

@sapphire/plugin-api

Version:

Plugin for @sapphire/framework to expose a REST API

45 lines (43 loc) 1.51 kB
import { __name, __publicField } from '../../chunk-S573YWRP.mjs'; import { Piece } from '@sapphire/pieces'; import { isNullish } from '@sapphire/utilities'; import { RouterRoot } from './router/RouterRoot.mjs'; var _Route = class _Route extends Piece { constructor(context, options = {}) { super(context, options); /** * (RFC 7230 3.3.2) The maximum decimal number of octets. */ __publicField(this, "maximumBodyLength"); /** * The path this route represents. */ __publicField(this, "path"); /** * The methods this route accepts. */ __publicField(this, "methods"); const api = this.container.server.options; const path = RouterRoot.normalize(api.prefix); const methods = new Set(options.methods); if (options.route) { path.push(...RouterRoot.normalize(options.route)); } else { let lastPart = context.name; const implied = RouterRoot.extractMethod(lastPart); if (!isNullish(implied)) { lastPart = lastPart.slice(0, lastPart.length - implied.length - 1); methods.add(implied); } path.push(...RouterRoot.normalize(RouterRoot.makeRoutePathForPiece(this.location.directories, lastPart))); } this.path = path; this.methods = methods; this.maximumBodyLength = options.maximumBodyLength ?? api.maximumBodyLength ?? 1024 * 1024 * 50; } }; __name(_Route, "Route"); var Route = _Route; export { Route }; //# sourceMappingURL=Route.mjs.map //# sourceMappingURL=Route.mjs.map