Skip to content
This repository was archived by the owner on Feb 1, 2026. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

157 Commits

Repository files navigation

An enhanced HTTP(S) Server for Node.js. It uses a pure request handler instead of the traditional Nodejs request handler

Install

$ npm add @aldojs/http

Server

To create HTTP or HTTPS servers, you may use the function createServer.

const{ readFileSync }=require('fs');declarefunctioncreateServer(options: Options,fn: RequestHandler): Server;declarefunctioncreateServer(fn: RequestHandler): Server;declarefunctioncreateServer(options: Options): Server;declarefunctioncreateServer(): Server;declareinterfaceOptions{tls?: {key: readFileSync('path/to/key/file.pem'),cert: readFileSync('path/to/cert/file.pem')// see `https.createServer()` for more options to create secure servers}}

Request handler

The request event handler could be a common or an async function. It's a pure function to replace the traditional handler

declaretypeRequestHandler=(request: http.IncomingMessage,response: http.ServerResponse)=>void;

Each handler will receive the http.IncomingMessage object as a request, and should return a Response object.

declaretypeRequestHandler=(request: http.IncomingMessage)=>Response|Promise<Response>;

Response

The returned response object should have a send method to configure and finalize the http.ServerResponse

import{ServerResponse}from'http';declareinterfaceResponse{send(res: ServerResponse): void|Promise<void>;}

About

Enhanced HTTP(S) `Server` for Node.js

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages