苏莉koa 2020-06-10
package.json
{ "name": "myweb", "version": "1.0.0", "description": "", "main": "", "scripts": { "start": "ts-node index.ts" }, "author": "nero", "license": "ISC", "devDependencies": { "@types/koa": "^2.11.3", "@types/node": "^14.0.12", "koa": "^2.12.0", "ts-node": "^8.10.2", "typescript": "^3.9.5" } }
index.ts
import * as Koa from "koa"; const app = new Koa(); app.use(async ctx => { ctx.body = ‘Hello World‘; }); //设置监听端口 app.listen(3000, () => { console.log("服务器开启 127.0.0.1:3000"); });