18 lines
434 B
TypeScript
18 lines
434 B
TypeScript
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}`);
|
|
});
|