Install it npm install lab-http-server lab-di
Use it through lab-di:
const container = require('lab-di')();
require('lab-http-server')(container);
const httpServer = container.get('lab-http-server');const server = httpServer.createServer('http://localhost:5000');
server.get('/*', (ctx, next) => {
ctx.body = 'Hello!'
return next().then(() => console.log('later'))
});
server.start();This package itself does not rely on async/await, but you may use it wherever available:
server.get('/*', async (ctx, next) => {
ctx.body = 'Hello!'
await next()
console.log('later')
});Start a test loop via npm test.