0.0.3 • Published 8 years ago

trench v0.0.3

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

trench

Build Status

:large_orange_diamond: Simplistic, promise-based web framework for node.

Features

  • Supports new ES6 features such as Promises and Sets.
  • Supports all HTTP methods listed in http.METHODS.
  • Prioritises speed and simplicity over a large feature-set or extensive options.
  • API modeled on the ever-popular Express.
  • In equivalent "Hello, World!" examples, it's faster than both hapi and Express.

Usage

  • Requires Node 6.0+
const Trench = require("trench");

const app = new Trench();

app.get("/", (req, res) => {
	res.end("<h1>Hello, World!</h1>");
});

app.listen(8080);

Recommended Modules

API

new Trench()

Returns a new app instance.

const app = new Trench();

Trench#use(function)

Specifices a middleware function to be used.

app.use((req, res) => {
	res.locals.startTime = Date.now();
});

Trench.static(root)

Returns a middleware function for serving static files.

app.use(Trench.static(__dirname + "/static"));

Trench#get(path, [ function, [ function, function ]])

Specifices a GET route for the given path.

app.get("/", (req, res) => {
	res.locals.name = "Monty";
}, (req, res) => {
	res.end(`Hi, ${res.locals.name}!`);
});
0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago