1 Star 0 Fork 0

pixel / billon-system

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
admin.js 1.80 KB
一键复制 编辑 原始数据 按行查看 历史
pixel 提交于 2018-06-16 16:40 . online
"use strict";
const Koa = require('koa');
const http = require('http');
// const https = require('https');
const fs = require('fs');
const path = require('path');
const serve = require("koa-static");
// const enforceHttps = require('koa-sslify');
const router = require('koa-router')()
const bodyParser = require('koa-bodyparser');
const app =new Koa();
const controller = require('./controller');
// Force HTTPS on all page
// app.use(enforceHttps());
app.use(bodyParser());
// router.get('/admin', async(ctx,next)=>{
// let html = fs.readFileSync(__dirname+'/admin/index.html')
// console.log(html)
// ctx.body = html.toString()
// });
// router.get('/', async(ctx,next)=>{
// let html = fs.readFileSync(__dirname+'/page/index.html')
// ctx.body = html.toString()
// });
// app.use(serve(path.join(__dirname, '..', 'public')));
app.use(serve(__dirname+ "/admin/"));
//log
app.use(async (ctx, next) => {
console.log(`${ctx.request.method} ${ctx.request.url}`); // 打印URL
await next(); // 调用下一个middleware
});
app.use(async (ctx, next) => {
const start = new Date().getTime(); // 当前时间
console.log(ctx.request.body,'<--------入参')
await next(); // 调用下一个middleware
const ms = new Date().getTime() - start; // 耗费时间
console.log(`
回参-------------->
${JSON.stringify(ctx.body)}
Time: ${ms}ms
`); // 打印耗费时间
});
// router with controller
app.use(controller());
// SSL options
// var options = {
// key: fs.readFileSync('./ssl/henrongyi.top.key'), //ssl文件路径
// cert: fs.readFileSync('./ssl/henrongyi.top.cer') //ssl文件路径
// };
app.use(router.routes())
// start the server
http.createServer(app.callback()).listen(9527);
// https.createServer(options, app.callback()).listen(443);
//
console.log('https server is running');
1
https://gitee.com/pixelmax/billon-system.git
git@gitee.com:pixelmax/billon-system.git
pixelmax
billon-system
billon-system
master

搜索帮助