Serverful
The core Serverful library
An interface for creating HTTP servers, together with powerful features and extensions.
Main Features
- Effective and performant HTTP interface.
- Shortcut behaviour, like gateways and redirects.
- Optional integration of EJS templates.
- Native cookie parsing.
Links
Extensions
Install/Import
npm install @serverful/core
const Serverful = require("@serverful/core");
// ...
Usage
Creation of a Serverful instance.
const MyServer = new Serverful(Port);
Gateways
// /**
MyServer.Incoming(Handler);
// /public/**
MyServer.Gateway("public", Handler);
// /api/**
MyServer.Gateway("api", Handler);
Requests
// Redirect the user relatively or absolute.
Packet.Request.Redirect("/dashboard/");
Packet.Request.Redirect("https://duckduckgo.com/");
// Render an EJS template.
Packet.Request.Render(EJSTemplate, Document)
.then(() => Packet.Request.End(200))
.catch(() => Packet.Request.End(500));
// JSON.
Packet.Request.JSON(Document);
Issues, Contributing & License
Before making an issue for a bug or feature submittion, please ensure that it hasn't already been created on the repository.
This module is licensed under Apache 2.0.