1.3.1 • Published 2 years ago

zzz v1.3.1

Weekly downloads
37
License
ISC
Repository
github
Last release
2 years ago

Zzz

Zzz is a Lightweight Node.js REST Framework - Currently, Zzz supports the following http request methods: GET, POST, PUT, and DELETE.

Build Status

Installation

$ npm install zzz

Usage

Getting Started

// Load Zzz module and create a server instance
var Zzz = require("zzz");

// Create a new Zzz server
var server = new Zzz.Server();

// Define a GET request
server.get("/my/route", function(request, response) {
	response.end("Hello World, I serve GET requests!")
});

// Define a POST request
server.post("/my/route", function(request, response) {
	response.end("Hello World, I serve POST requests!")
});

// Start listening for requests
server.listen(80);

Routing

Routes are defined by assigning a callback to a http request method and request path:

server.[get|post|put|delete]("/some/path", callback);

server.get("/some/static/path", function(request, response) {
	// do something here
	response.end("I did something.");
});

Zzz will always pass http.serverRequest and http.serverResponse objects to the callback. However, if there are dynamic path segments denoted by a ':', these will be passed via an object of key/value pairs as the third argument to the callback.

server.post("/some/:dynamic/path", function(request, response, uriParams) {
	var body = "";
	
	// do something with post params here
	request.on("data", function(chunk) {
		body += chunk;
	});

	request.on("end", function() {
		var postBody = querystring.parse(body);
		response.write("<p>I was" + uriParams.dynamic + "</p>");
		response.end("<pre>" + postBody + "</pre>");
	});
});

Run Tests

$ make test

Code Coverage Report

$ make coverage

Note: The code coverage report depends on having jscoverage installed.

License: MIT

Author: Andrew Vayanis

1.3.1

2 years ago

1.3.0

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.3.0

10 years ago

0.2.0

11 years ago

0.1.1

12 years ago