Skip to content

ServerfulArch/Core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.