Latest version : 0.5.6

 Last updated on 2017-04-06T21:14:21.411Z

 Keywords : active, web, framework, rest, api

 2 stars

 Downloads :

  • 3784 in Last Month

 Links :


No examples found for this package


ActiveJS framework

NPM Version NPM Downloads Build Status


  • high performance, our main target is high performance, minimum of hidden unnecessary functionality
  • strict routing, we like strict routing system, if method should use some certain parameters, it must get it
  • simple use, if newbie can use our framework without any problem, this is real cool
  • friendly use, we provide way for connect packages, modules from other developers



$ npm install active --save

Create application

var active = require('active');
var app = active();

app.addRoute(options, callback);
app.addRoute(options, callback);
app.addRoute(options, callback);


To start new server you can use default settings:


Or custom settings:

  'port': Number, // optional, default 80
  'host': String, // optional, default localhost
  'cluster': Boolean // optional, default false

Also you can use http(s) package:

var app = active();
var http = require('http');
var https = require('https');

// simple http server

// secure server with SSL
https.createServer(options, app).listen(port);

Check detailed documentation of these modules.


Next method needs for changing application settings, method isn't required:

  'routing': String // default "nonstrict", also can be "strict"
  'cors': Boolean // default false
  'debug': Boolean // default false
  • routing, strict routing is mean, that if some of your application method needs special parameters (set by route rule), these parameters must be received, if they don't, client will receive error
  • cors, cross-origin resource sharing, read details here
  • debug, application with enabled debug mode prints speed for each request


For adding new routing rule, you must use "addRoute" method of application object:

app.addRoute(options, callback);

Settings for special rule.

  'method': String, // GET by default, also can be POST, PUT, DELETE
  'url': String, // pattern for request url
  'match': Object, // patterns for special params in request url
  'query': Object // query parameters, after question mark

Examples of application routes:

  'url': '/{category}',
  'match': {
    'category': ['phones', 'stuff']
}, callback);

  'url': '/{category}/{item}',
  'match': {
    'category': ['phones', 'stuff'],
    'item': '([a-z0-9-]{2,63}\.[a-z]{4})'
}, callback);


Helpful information about callbacks.

Request parameters

You can use path parameters, which been set in route ("url" directive):

app.addRoute(options, function(req, res) {});

Examples of application callbacks:

  'url': '/{category}/{item}',
  'match': {
    'category': ['phones', 'stuff'],
    'item': '([a-z0-9-]{2,63}\.[a-z]{4})'
}, function(req, res) {
  console.log(req.params); // {category: String, item: String}


You can choose how to return result to the client. Below you can see both examples.


Use standard capabilities of Node using "res" object:

app.addRoute(route, function(req, res) {
  res.statusCode = 200;

Use custom capabilities of framework:

app.addRoute(route, function(req, res) {
  res.html(http_code, html); // show html
app.addRoute(route, function(req, res) {
  res.json(http_code, json); // show json

Framework provides custom way for redirecting queries:

app.addRoute(route, function(req, res) {
  res.redirect('/path/', 301);


What you can do using layers:

  • implement some specific middleware layer for your application
  • connect different packages from other developers

Middleware layer is a function with three arguments: "req", "res" and "next", first and second are standard NodeJS objects, third is callback. There are two types of layers.


Will be executed for request matched specific route rule:

app.addRoute(options, function(req, res, next) {
  // do something with "req" and "res" objects and run callback
}, callback);

Will be executed for each request:

app.useLayer(function(req, res, next) {
  // do something with "req" and "res" objects and run callback

If you want to use few layers, you must send array with functions, instead of function:

// local layer
app.addRoute(options, [Function, Function, Function], callback);

// global layer
app.useLayer([Function, Function, Function]);

You can use any number of layers, but remember about your rom ;)


Below you can find some advices.

Page not found

If some client request doesn't match your routing rules, our framework will shows blank page with 404 status. Of course for production we need more intelligent solution, so here is example how you can show your custom "not found" page:

  'url': '/{url}',
  'match': {
    'url': '(.*)'
}, callback);

You see? Just need add new routing rule for processing all requests. This rule must be last one, it's very important.


Guys, sometimes we implement some new functionality, like uploading files. It works without any packages from other developers, so we need help to test how it works. If you found some error, please open new issue on Github or send email to us. Thanks!


"Active" framework is a new project, there is lot of work to do and you can help:

  • review pull requests
  • find new issue or fix exist
  • add new feature or improve some old
  • update documentation


The Active JS framework is open-source software licensed under the MIT