npm.io
0.0.1 • Published 5 years ago

@serverful/core

Licence
Apache-2.0
Version
0.0.1
Deps
2
Size
15 kB
Vulns
0
Weekly
0

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.

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.