通过Npm 方式安装kvl
$ npm install kvl@latest -g
1
mac/linux安装
$ sudo npm install kvl@latest -g
1
基础方式使用
import kvl from 'kvl';
import { Main ,Router, config } from 'kvl';
@Router({})
class HelloWord{
private msg: string = 'Hello, world'
@config({ url: '/hello', name: 'hello', type: 'get' })
private hello(req: kvl.Request, res: kvl.Response): void {
res.end(`<h1>${this.msg}</h1>`)
}
}
Main({
port: 8080,
router: [ HelloWord ],
}).then(({app,httpServer}) => {
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20