an extremely lightweight node web application framework
const web = require('web');
const webApp = web.server();
webApp.get('/', (req, res) => {
res.end('Hello World');
});
webApp.listen(3000);
Installation is done using the
npm install
command:
$ npm install andydam/web
const webRouter = web.router();
webRouter.get('/', (req, res) => {
res.end('Hello World from Router');
});
webApp.use(webRouter);
webApp.use('/static', web.static('path/to/folder'));
webApp.get('/some/path/:dynamic', (req, res) => {
res.end('Dynamic end point is ' + req.params.dynamic);
});
web only has support for one param at the end of static path
webApp.post('/somePoint', (req, res) => {
res.end('POST data is ' + req.body);
});
That's it! web only comes with extremely limited features, extending upon node's http module. This means that the request and response objects are node's http IncomingMessage and ServerResponse objects.
Using hbakhtiyor's node frameworks benchmark
Simple HTTP benchmark results (wrk) with close connection
47372.89 Requests/sec - ukoa.js
35548.17 Requests/sec - ufeathers.js
*** 31403.07 Requests/sec - web.js ***
29583.14 Requests/sec - uexpress.js
555.82 Requests/sec - restify.js
551.59 Requests/sec - rawnode.js
550.16 Requests/sec - express.js
549.61 Requests/sec - hapi.js
549.23 Requests/sec - total/total.js
548.67 Requests/sec - koa.js
548.29 Requests/sec - feathers.js
546.58 Requests/sec - micro.js
173.34 Requests/sec - uws.js
- Node 9.4