1.0.21 • Published 6 years ago

valley-server v1.0.21

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

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

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago