npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nover

v0.1.29

Published

A Node.js powered HTTP server.

Downloads

23

Readme

Nover

A Node.js powered HTTP server.

Why Nover?

As a Web developer, I often found that I really need a HTTP server which is more comprehensive than Python SimpleHttpServer but more light-weight than Apache and Nginx.

Supports

  • Static Web sites
  • RESTful APIs written in Node.js
  • WebSocket
  • URL Rewrite
  • Virtual Hosts
  • Customized middleware

Usage

nover <config_file>

Config Tips

  • Run nover -h to show an example nover config.
  • If port is not given in the top section of config files, HTTP port will be assigned to process.env.PORT.
  • Use $ROOT as the shorthand of the document root defined by root.
  • Use $PWD to represent the location of the config file.
  • Use $DOMAIN to indicate the main domain set by domain.
  • For WebSocket, $PORT can be used to indicate the same port defined by port in the top section of config file.
  • When setting rewrites, please be awared that the request urls will also contain a leading / (slash). For example, to rewrite example.com/nover the pattern should be something like ^/nover/?$ rather than ^nover/?$.
  • System variables are not supported in the data attributes of APIs and Socekts.

Sample config

{
    "port": 8080,
    "log": "true",
    "origins": "*",
    "credentials": "false",
    "root": "/Users/nover/",
    "middlewares": [
        "$ROOT/middle/handler.js"
    ],
    "top": "example.io",
    "rewrite": [{
      "pattern": "^/service/?$",
      "replace": "/search/"
    },
    {
      "pattern": "^/show/([0-9]+)/?$",
      "replace": "/git/#/$1"
    }],
    "require": [
        "$ROOT/addon.js"
    ],
    "sites": [{
        "url": "/",
        "local": "$ROOT/server/public"
    },
    {
        "url": "/test",
        "local": "$ROOT/html"
    }],
    "apis": [{
        "uri": "/api/name/:name",
        "method": "get",
        "local": "$ROOT/Workstation/nover/example/api.js",
        "data": {
             "version": 1
        }
    },
    {
        "uri": "/api/name",
        "method": "post",
        "local": "$ROOT/Workstation/nover/example/api.js"
    }],
    "sockets": [{
        "port": "$PORT",
        "local": "$PWD/socket.js"
    }],
    "vhosts": [{
        "subdomain": "foo.$DOMAIN",
        "sites": [{
            "url": "/",
            "local": "$ROOT/Desktop/html"
        }],
        "sockets": [{
            "port": 8090,
             "local": "$ROOT/socket/app.js"
        }]
    },
    {
         "subdomain": "bar.$DOMAIN",
         "sites": [{
             "url": "/",
             "local": "$ROOT/Sites"
         }]
    }]
}

Sample RESTful API

To register Node.js powered APIs, please make sure the exposes of __get, __post, __delete, __put, and __all

#!/usr/bin/env node
exports.__get = function (req, res, data) {
    'use strict';
    var name = req.params.name;
    res.send('Hello, ' + name);
};

Sample Socket.io App

Please make sure your app exposes __socket for Nover.

#!/usr/bin/env node

exports.__socket = function (server, data) {
    'use strict';
    var io = require('socket.io').listen(server);

    io.sockets.on('connection', function (socket) {
        'use strict';
        socket.emit('news', {hello: 'world!!!'});
        socket.on('message', function (data) {
            console.log(data);
        });
    });

};

Sample Middleware

Please make sure your module exposes __middle

exports.__middle = function (req, res, next) {
    'use strict';
    console.log(req.url);
    next();
};

Sample Require Module

Please make sure your required Nover module exposes __require

The parameter data is an object that contains:

  • http: The main HTTP object of Nover server.
  • port: The main port number.
  • root: The root directory.
  • domain: The main domain.
exports.__require = function (data) {
     'use strict';
     var http = data.http;
     http.get('/dev/api/:username', function () {
             ...
     });
};

License

Nover is licensed under MIT.