@serverful/core

0.0.1 • Public • Published

Serverful

The core Serverful library

[Contribute] [Documentation]

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @serverful/core

Weekly Downloads

5

Version

0.0.1

License

Apache-2.0

Unpacked Size

15.1 kB

Total Files

11

Last publish

Collaborators

  • smally