@hamjs/http
This is a mini HTTP server library for NodeJS.
Why @hamjs/http?
This library is very fast as it is zero dependency.
Installation
Run this command in your project directory!
$ npm install @hamjs/http
Usage
Before you use @hamjs/http, you have to require it. Example, below.
const http = require('@hamjs/http');
Then, you can create and listen the server. Example, below.
...
const app = new Http();
// routing here
...
app.listen(PORT, callback);
To add route, you can use the router. Example, below.
...
app.router.get(PATH, handler);
...
The handler look like here.
...
(ctx) => {
ctx.send('Anything.');
}
...
Full example code.
const Http = require('@hamjs/http');
const app = new Http();
app.router.get('/', (ctx) => {
ctx.send('halo ');
});
app.listen(8080, () => {
console.log('app start');
});