first
This commit is contained in:
17
src/server.ts
Normal file
17
src/server.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import Koa from "koa";
|
||||
import router from "./routers/router";
|
||||
import bodyParser from "koa-bodyparser";
|
||||
import InitHandler from "./routers/handler";
|
||||
// 使用路由
|
||||
const app = new Koa();
|
||||
app.use(bodyParser());
|
||||
|
||||
|
||||
app.use(router.routes()).use(router.allowedMethods());
|
||||
InitHandler();
|
||||
console.log(router);
|
||||
// 启动服务器
|
||||
const PORT = 3000;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server is running on http://localhost:${PORT}`);
|
||||
});
|
||||
Reference in New Issue
Block a user