快速搭建 Koa2 + TS 服务器
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"); });
相关推荐
boneix 2020-10-21
MrQuinn 2020-08-16
starzhangkiss 2020-04-19
LorenLiu 2020-03-28
Qimingweikun 2020-03-05
发条戏子 2020-02-01
jackyhungvip 2020-01-19
Qimingweikun 2019-12-09
Anything0 2019-11-17
lert0 2019-11-04
88530198 2019-11-03
sqliang 2019-11-03
苹果咏 2019-07-23
bobbaobao 2018-11-13
lert0 2019-07-01
fanix 2019-07-01
liwenbocsu 2019-07-01
slackkoala 2019-07-01