0.0.1 • Published 3 years ago

@serverful/core v0.0.1

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
3 years ago

Serverful

An interface for creating HTTP servers, together with powerful features and extensions.

Features

  • Effective and performant HTTP interface.
  • Shortcut behaviour, like gateways and redirects.
  • Optional integration of EJS templates.
  • Native cookie parsing.
  • Rich extension management.

Links

Extensions

Installation

npm install @serverful/core

const Serverful = require("@serverful/core");
// ...

Usage

Creation of a Serverful instance.

const MyServer = new Serverful(Port);

Registration of Serverful extensions.

Serverful.Extension(ServerfulExtension);

Gateways

// /**
MyServer.Incoming(Handler);

// /public/**
MyServer.Gateway("public", Handler);

// /api/**
MyServer.Gateway("api", Handler);

Requests

// Handler
// Redirect the user relatively or absolute.
Packet.Request.Redirect("/dashboard/index");
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);

This module is licensed under Apache 2.0.

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago