@sapphire/plugin-api
Version:
Plugin for @sapphire/framework to expose a REST API
36 lines (33 loc) • 1.14 kB
JavaScript
;
var index_cjs = require('./index.cjs');
var framework = require('@sapphire/framework');
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var _Api = class _Api extends framework.Plugin {
/**
* @since 1.0.0
*/
static [framework.postInitialization](options) {
this.server = new index_cjs.Server(options.api);
this.stores.register(this.server.routes).register(this.server.middlewares);
index_cjs.loadListeners();
index_cjs.loadMiddlewares();
index_cjs.loadRoutes();
}
/**
* @since 1.0.0
*/
static async [framework.preLogin]() {
if (!(this.server.options.automaticallyConnect ?? true)) {
return;
}
await this.server.connect();
}
};
__name(_Api, "Api");
var Api = _Api;
framework.SapphireClient.plugins.registerPostInitializationHook(Api[framework.postInitialization], "API-PostInitialization");
framework.SapphireClient.plugins.registerPreLoginHook(Api[framework.preLogin], "API-PreLogin");
exports.Api = Api;
//# sourceMappingURL=register.cjs.map
//# sourceMappingURL=register.cjs.map