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

webappengine

v1.2.0

Published

A web application server that can host multiple web apps running with Node.js.

Downloads

5,299

Readme

WebAppEngine build status Coverage Status

NPM

A web application server that can host multiple web apps running with Node.js.

WebAppEngine Note. The administration UI is currently under construction.

Installation

For the API usage:

$ npm install --save webappengine

For the command line usage:

$ npm install -g webappengine

Kickstart your project using generator-webappengine

A Yeoman generator for developing WebAppEngine app is available at https://github.com/cheton/generator-webappengine. You can use the generator to kickstart your project. It includes Gulp, Browserify, Babelify, Stylus, Handlebars, i18next, and React.

Follow the steps to run the generator:

$ npm install -g yo
$ npm install -g generator-webappengine
$ yo webappengine

Once completed, you have to install NPM packages and Bower components, and run the gulp command to build your project.

$ npm install
$ bower install
$ gulp

Now you can run node app/main.js to launch your web app, or use webappengine to load app.js. For example:

var path = require('path');
var webappengine = require('webappengine');

webappengine({
    port: 80,
    routes: [
        {
            type: 'server',
            route: '/',
            server: function(options) {
                options = options || {};

                var app = express();
                var serveStatic = require('serve-static');
                var assetPath = path.resolve(__dirname, 'web');
                
                app.use(options.route, serveStatic(assetPath));

                return app;
            }
        }
    ]
});

Usage

API usage

var path = require('path');
var webappengine = require('webappengine');
var options = {
    port: 80, // [optional] The listen port (default: 8000)
    //host: '', // [optional] The listen address or hostname (default: 0.0.0.0)
    //backlog: 511, // [optional] The listen backlog (default: 511)
    routes: [
        {
            type: 'static', // [static|server]
            route: '/',
            directory: path.resolve(__dirname, 'web') // for the static type
        }
    ]
};

webappengine(options)
    .on('ready', function(server) {
        var address = server.address();
        console.log('Server is listening on %s:%d', address.address, address.port);

        var io = require('socket.io')(server); // using socket.io
    })
    .on('error', function(err) {
        console.error('Error:', err);
    });

Command line usage

Run webappengine to start the app, and visit http://yourhostname:8000/ to check if it works:

$ webappengine

To check what port the app is running on, find the message Server is listening on 0.0.0.0:8000 from console output.

By default the app listens on port 8000, you can run webappengine with -p (or --port) to determine which port your application should listen on. For example:

$ webappengine -p 80

Set the environment variable NODE_ENV to production if you are running in production mode:

$ NODE_ENV=production webappengine

Run webappengine with -h for detailed usage:

$ webappengine -h

  Usage: webappengine [options]
  
  Options:

    -h, --help               output usage information
    -V, --version            output the version number
    -p, --port               set listen port (default: 8000)
    -H, --host <host>        set listen address or hostname (default: 0.0.0.0)
    -b, --backlog            set listen backlog (default: 511)
    -c, --config <filename>  set multihost configuration file
    -v, --verbose            increase the verbosity level

Getting Started

Working with static assets

The following configuration will serve static assets from the directory:

static-config.json:

[
    {
        "type": "static",
        "route": "/",
        "directory": "/path/to/your/project/web/"
    }
]

Run webappengine with --config to set multihost configuration file:

$ webappengine --config "/path/to/your/project/static-config.json"

or use the API:

var webappengine = require('webappengine');
var routes = require('./static-config.json');

webappengine({
    routes: routes
});

Visits http://yourhostname:8000/ will serve index.html file as below:

<h1>WebAppEngine Test Page</h1>

(See also: examples/static/index.html)

Configure multihost settings to run multiple web apps

First, checkout examples/simple/app.js and examples/multihost.json, and copy examples to your project folder to kickstart a web application.

simple/app.js:

var path = require('path'),
    express = require('express');

module.exports = function(options) {
    options = options || {};

    var app = express();
    var serveStatic = require('serve-static');
    var assetPath = path.resolve(__dirname, 'web');

    // Enable case sensitivity routing: "/Foo" is not equal to "/foo"
    app.enable('case sensitive routing');
    // Disable strict routing: "/foo" and "/foo/" are treated the same
    app.disable('strict routing');

    app.use(options.route, serveStatic(assetPath));

    return app;
};

server-config.json:

[
    {
        "type": "server",
        "route": "/simple",
        "server": "/path/to/your/project/simple/app"
    }
]

Run webappengine with --config to set multihost configuration file:

$ webappengine --config "/path/to/your/project/server-config.json"

or use the API:

var webappengine = require('webappengine');
var routes = require('./server-config.json');

webappengine({
    routes: routes
});

Visits http://yourhostname:8000/simple will serve index.html file as below:

<h1>WebAppEngine Test Page</h1>

(See also: examples/simple/web/index.html)

Administration UI

The administration UI is currently under construction.

Dashboard

TBD

Change the display language

You can change the display language from the Settings menu, it will set the lang query string parameter: ?lang={locale}

Here is a list of currently supported locales:

Locale | Language ------ | -------- de | Deutsch en | English (US) es | Español fr | Français it | Italiano ja | 日本語 zh-cn | 中文 (简体) zh-tw | 中文 (繁體)

License

Copyright (c) 2015-2016 Cheton Wu

Licensed under the MIT License.