UNPKG

mm_os

Version:

这是超级美眉服务端框架,用于快速构建应用程序。

27 lines (26 loc) 588 B
/** * web请求之前 * @param {Object} server 服务 * @param {Object} config 配置参数 */ module.exports = function(server, config) { // 使用路由(主要) server.use(async (ctx, next) => { if (!ctx.db) { ctx.db = { ret: null }; } if (ctx.path !== "/favicon.ico") { await $.eventer.run('web_before', ctx, ctx.db); var event = $.event_admin('api'); var ret = await event.before(ctx.path, ctx, ctx.db); // console.log("before阶段", ret); if (ret) { ctx.body = ret; } } await next(); }); return server; };