blog-server/app.js

24 lines
653 B
JavaScript
Raw Permalink Normal View History

2019-10-28 08:21:03 +08:00
const Koa = require("koa");
2019-10-31 15:31:11 +08:00
const requter = require("./bin/router.js");
2019-11-12 23:30:26 +08:00
jwt = require('jsonwebtoken');
2019-11-13 10:59:06 +08:00
dbs = require("./bin/mongodb.js")('mongodb://localhost:27017/myblog',"myblog")
2019-10-28 08:21:03 +08:00
// console.log(requter)
// import requter from "./bin/router"
const app = new Koa();
app.use(async (ctx,next)=>{
// await next();
2019-11-12 16:50:28 +08:00
console.log(ctx.url)
2019-11-13 20:17:51 +08:00
// console.time("asd")
2019-11-12 16:50:28 +08:00
// ctx.response.body = {a:1};
2019-11-12 23:30:26 +08:00
await next()
2019-11-13 20:17:51 +08:00
// console.log("执行")
// console.timeEnd("asd")
2019-10-28 08:21:03 +08:00
});
const bodyParser = require('koa-bodyparser');
app.use(bodyParser());
// console.log(requter())
app.use(requter());
2019-11-12 17:06:53 +08:00
app.listen(3000);
console.log("http://localhost:3000")