这里是sletjs默认api返回的示例
$ npm i -S slet
'use strict';
const Slet = require('slet');
const app = new Slet({
root: __dirname,
debug: true
});
app.router('/', './basicctrl')
app.start(3000)
'use strict';
const BasicController = require('slet').BasicController
module.exports = class MyBasicController extends BasicController {
constructor(app, ctx, next) {
super(app, ctx, next)
}
get() {
return {
msg: 'this is a get'
}
}
post() {
return {
msg: 'this is a post'
}
}
}
最后,执行app.js,启动server
$ node app.js
测试请求,可以使用curl命令
curl http://127.0.0.1:3000/
curl -d "" http://127.0.0.1:3000