@hamjs/http

HamJS mini HTTP Server library

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
@hamjs/http
Minified + gzip package size for @hamjs/http in KB

Readme

@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');
});

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.