New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aldojs/http

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aldojs/http

Enhanced HTTP `Server` for Node.js

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by20%
Maintainers
1
Weekly downloads
 
Created
Source

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

declare function createServer (options: Options, fn: RequestHandler): Server;
declare function createServer (fn: RequestHandler): Server;
declare function createServer (options: Options): Server;
declare function createServer (): Server;

declare interface Options {
  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

declare type RequestHandler = (request: http.IncomingMessage, response: http.ServerResponse) => void;

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

declare type RequestHandler = (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';

declare interface Response {
  send (res: ServerResponse): void | Promise<void>;
}

Keywords

FAQs

Package last updated on 12 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc