3 Star 0 Fork 0

鸿基梦 / MTools-Admin-node

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
serve.js 898 Bytes
一键复制 编辑 原始数据 按行查看 历史
鸿基梦 提交于 2020-01-20 16:14 . 项目初始化
const kluy = require('./kluy/core');
const compress = require('koa-compress');
const http = require('http');
const config = require('./config/serve.config.js');
const app = new kluy();
// 配置跨域
app.use(async (ctx, next) => {
ctx.set('Access-Control-Allow-Headers', 'Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With')
ctx.set('Access-Control-Allow-Origin', 'http://localhost:8080');
ctx.set('Access-Control-Allow-Methods', 'PUT,DELETE,POST,GET');
ctx.set('Access-Control-Allow-Credentials', true);
ctx.set('Access-Control-Max-Age', 3600 * 24);
await next();
});
// compressor
app.use(compress({
filter: contentType => /text|javascript/i.test(contentType),
threshold: 2048
}));
// 使用新建的路由文件
app.setRouters();
// 监听在1234
http.createServer(app.callback()).listen(config.port);
console.log(`服务运行在 ${config.port}`)
NodeJS
1
https://gitee.com/hjmeng/MTools-Admin-node.git
git@gitee.com:hjmeng/MTools-Admin-node.git
hjmeng
MTools-Admin-node
MTools-Admin-node
master

搜索帮助