/whatwg-http-server

An universal way to implement HTTP server listeners, using WHATWG-similar standards. Translates your endpoint to many HTTP server implementations, like Node.js, Express.js, Azure Functions and more.

Primary LanguageTypeScriptMIT LicenseMIT

WHATWG HTTP Server

An universal way to implement HTTP server listeners, using WHATWG-similar standards. Translates your endpoint to many HTTP server implementations, like Node.js, Express.js, Azure Functions and more.

Problem

WHATWG Fetch API standardized the way we treat HTTP Request and Response objects in browser, but JavaScript HTTP servers don't follow any standard.

This makes your API bounded to a specific framework and harder to change it to another application environment because the vendor lock-in.

Some comparative examples of different HTTP server implementations in JavaScript:

Node.js native HTTP Express.js Azure Functions

This way your endpoint logic is bounded to specific request/response types, each one with different properties, methods and HTTP response approachs, without any convention.

Solution

  1. Define your API using WHATWG-similar types
  2. Export it like anything your server needs

chrome-capture

This way you can easily change from and to any framework or application environment, without changing your main code logic.

Usage

Installing

Defining the endpoint logic

Differences from WHATWG Fetch API types

HTTP server implementations

Conttributing

License