New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

active

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

active

Cool, simple and fast web framework for NodeJS

  • 0.2.0
  • unpublished
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-20%
Maintainers
1
Weekly downloads
 
Created
Source

ActiveJS framework

Features

  • 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

Installation

$ npm install active

Create application

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

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

app.startServer(parameters);
Server

To start new server you can use default settings:

app.startServer();

Or custom settings:

app.startServer({
    'port': Number, // default 80
    'host': String, // default localhost
    'cluster': Boolean, // default false
});

All properties isn't required.

Routing

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

app.addRoute(options, callback);
Options

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:

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

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

Callbacks

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:

app.addRoute({
    '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}
});

Response

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

Standart

Use standard capabilities of Node using "res" object:

app.addRoute(route, function(req, res) {
    res.statusCode = 200;
    res.end(content);
});
Custom

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
});
Redirect

Framework provides custom way for redirecting queries:

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

Layers

You can add middleware layer for all queries, it can be your own solution or package of other developer. Middleware layer is a function with three arguments: "req", "res" and "next", first and second are standard NodeJS objects, third is callback. Middleware will be executed for every request to the application.

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

app.useLayer(function(req, res, next) {
    next();
});

Contributing

"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

License

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

Keywords

FAQs

Package last updated on 12 Feb 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc