1.1.1 • Published 4 years ago

midmare-http-router v1.1.1

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

npm version Build Status codecov.io

const { createServer } = require('http');
const { default: mid } = require('midmare');
const { Router: { HttpRouter, delegateHttp } } = require('midmare-http-router');

// HTTP ROUTER
const app = mid();
const httpRouter = new HttpRouter();

// Use named function declaration to 
httpRouter.process('/', function get(ctx) {
    ctx.status = 200;
    ctx.body = { ololo:1 };
});
app.use(httpRouter).init();

// Be sure that you use `delegateHttp` on app.
// delegateHttp make app understand that at some moment you will get request response object. And it will be injected to context.
createServer(delegateHttp(app)).listen(3000);
1.1.1

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago