Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

zzz

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zzz

Lightweight REST service container

Source
npmnpm
Version
0.3.0
Version published
Weekly downloads
26
225%
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 24 Nov 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts