httpfrk
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Node.js web server framework for Http/1.1 or Http/2

Description: This is http framework, you can use it to create Http/1.1 or Http/2 service。

Now let's start to use it!

install

npm

npm install httpfrk

yarn

yarn add httpfrk

Start

It's very easy to create http server, and return a HttpServer object that we can use it to control the request and response.

Server

import { Server } from 'httpfrk';

const app = new Server();
app.use(async (req, res, next) => {
  res.send('hello world');
  res.end();
  await next();
});
app.listen(8080, () => {
  console.log('server running at 8080');
});

the next parameter is a function,we can call it to run the next middleware.

MiddleWare

The HttpServer object provide use method to handle request, and the module provide some middleware for HttpServer

import { Server, Router } from 'httpfrk';

const app = new Server();
const router = new Router();

router.get('hello', (req, res, next) => {
  res.send('hello world');
  res.end();
});

app.use(router.routes());

app.listen(8080, () => {
  console.log('server running at 8080');
});

Readme

Keywords

none

Package Sidebar

Install

npm i httpfrk

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

10.9 kB

Total Files

13

Last publish

Collaborators

  • jerrmy