1.0.21 • Published 7 years ago
valley-server v1.0.21
valley-server
code: https://github.com/hitvalley/server-module
server with valley-module: https://github.com/hitvalley/valley-module
引入 valley-server
npm i --save valley-server
代码
// 创建 app.js
const ValleyServer = require('../src/index');
const path = require('path');
const server = new ValleyServer();
// 设置服务器时间
server.use('time', async function(next){
console.time('start');
await next();
console.timeEnd('start');
});
// 静态文件服务设置
server.staticPath(path.join(__dirname, 'static'));
server.staticPath(path.join(__dirname, 'static/img'), /\.svg$/);
// 动态文件服务设置
server.use('default', async function(next) {
this.context.text('hello valley');
await next();
});
const port = 8080;
server.listen(port).then(res => console.log(`http://localhost:${port}`));
运行
node app.js
1.0.21
7 years ago
1.0.20
7 years ago
1.0.19
7 years ago
1.0.18
7 years ago
1.0.17
7 years ago
1.0.16
7 years ago
1.0.15
7 years ago
1.0.14
7 years ago
1.0.13
7 years ago
1.0.12
7 years ago
1.0.11
7 years ago
1.0.10
7 years ago
1.0.9
7 years ago
1.0.8
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.3
8 years ago
1.0.2
8 years ago
1.0.1
8 years ago
1.0.0
8 years ago