代码拉取完成,页面将自动刷新
const Hapi = require('@hapi/hapi');
const boom = require('@hapi/boom');
const inert = require('inert');
const vision = require('vision');
const Joi = require('joi');
const model = require('./model');
const plugin = require('./plugin');
const router = require('./router');
const config = require('./config.js');
const {log} = console;
const init = async () => {
const server = Hapi.server({
port: config.server.port,
host: config.server.host,
routes: {
cors: {
origin: ['*'],
},
files: {
relativeTo: './public',
},
validate: {
failAction(request, h, err) {
return err;
},
},
},
});
await server.state('paperId', {
ttl: null,
isSecure: false,
isHttpOnly: false,
encoding: 'base64json',
clearInvalid: false,
strictHeader: false,
});
server.decorate('server', 'Joi', Joi);
server.decorate('server', 'headers', Joi.object({
authorization: Joi.string().required(),
}).unknown());
server.decorate('toolkit', 'boom', boom);
await server.register([
inert,
vision,
plugin,
model,
router, // 加载路由
]);
// 静态目录
await server.route({
method: 'GET',
path: '/{param*}',
handler: {
directory: {
path: '.',
},
},
config: {
auth: false,
},
});
await server.start();
log(`http://${config.server.host}:${config.server.port}/documentation`);
};
init();
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。