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 🙏

© 2025 – Pkg Stats / Ryan Hefner

webexapp

v0.1.2

Published

Web Application Framework Using Express JS

Downloads

7

Readme

Web Application Framework Using Express JS

var webexapp = require('../lib'),
    WebServer = webexapp.WebServer;

var server;

server = new WebServer();
server.use('/hello', function (req, res) {
    res.send('hello world');
});
server.run();

Installation

$ npm install webexapp

Installation Dependencies

  • Node JS (v0.10.29+) - http://www.nodejs.org
  • Redis (v2.6.12+) - http://redis.io

Features

  • Built upon Express JS web framework - https://github.com/strongloop/express
  • Multi-transport logging using Winston - https://github.com/flatiron/winston
  • Faster web using Compression - https://github.com/expressjs/compression
  • Cookies using Cookie-Parser - https://github.com/expressjs/cookie-parser
  • User sessions using Express-Session - https://github.com/expressjs/session
  • Session storage using Connect-Redis - https://github.com/visionmedia/connect-redis
  • JSON/URL-Encoded body parsing using Body-Parser - https://github.com/expressjs/body-parser
  • Default-body parsing using raw-body - https://github.com/stream-utils/raw-body
  • Load management using Toobusy-JS - https://github.com/STRML/node-toobusy
  • Usage limiting using Node-Ratelimter - https://github.com/visionmedia/node-ratelimiter
  • Security headers using Helmet - https://github.com/evilpacket/helmet

Philosophy

One of the many possible implementations of Web-App skeleton using Express JS including different middleware needed for any serious development effort.

This is an attempt to provide a one-stop solution to get started...

APIs

Overview

This module puts togethar different middleware to create a web-app framework, and provides different APIs to configure some of the middleware parameters. It also provides APIs to fine-tune some of the configuration parameters. The default configurations are specified in respective setConfig details below. For more details regarding the configuration parameters, please view the documentation of the respective modules (see Features list above).

Some of the modules used internally are made accessible to enable building apps.

See examples folder for usage of different features.

Logger-instance: webexapp.loggerFactory.getLogger([name])

Create a logger instance based on winston; 'name' defaults to the file-name where the instance is created. Four different levels are defined as:

  • debug
  • info
  • warn
  • error

Logger-config: webexapp.setLoggerConfig(options)

webexapp.setRedisConfig({
    levels: {
        'debug': 0,
        'info': 1,
        'warn': 2,
        'error': 3
    },
    colors: {
        'debug': 'blue',
        'warn': 'yellow',
        'error': 'red',
        'info': 'green'
    },
    transports: [
        new(winston.transports.Console)({
            timestamp: true,
            colorize: true,
            json: true,
            level: 'debug'
        })
    ]
});

Browser-logging

Logging is also enabled from the browser. You will need to include JQuery and provided winston-client. A global winston object is made available for logginng.

    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript" src="/winston/client.js"></script>

For e.g., you can use winston.debug("some message") to log messages.

Redis-config: webexapp.setRedisConfig(options)

webexapp.setRedisConfig({
    host: null, // localhost
    port: null, // 6379
    options: {} // none
});

Sessions-config: webexapp.setCookieSessionConfig(options)

webexapp.setCookieSessionConfig({
    name: 'webappfx.sid',
    secret: 'secret sauce!',
    resave: true,
    saveUninitialized: true,
    cookie: {
        path: '/',
        httpOnly: true,
        secure: false,
        maxAge: null
    },
    redisPrefix: 'session:'
});

Security-config: webexapp.setSecurityConfig(options)

webexapp.setSecurityConfig({
    features: { // enable or disable specific headers
        crossdomain: true,
        csp: true,
        hidePoweredBy: true,
        hsts: true,
        ienoopen: true,
        nocache: true,
        nosniff: true,
        xframe: true,
        xssFilter: true
    },
    csp: {
        defaultSrc: ["'self'"],
        imgSrc: ["'self'", 'http://www.google-analytics.com', 'http://placehold.it'],
        scriptSrc: ["'self'", "'unsafe-eval'", "'unsafe-inline'", 'http://ajax.googleapis.com', 'http://www.google-analytics.com'],
        styleSrc: ["'self'", "'unsafe-inline'"],
        frameSrc: ["'self'", 'https://maps.google.com', 'https://www.google.com/maps/embed'],
    },
    xframe: 'sameorigin'
});

Limits-config: webexapp.setLimitsConfig(options)

webexapp.setLimitsConfig({
    // rate-limiting: max-requests in a given duration
    requestsMax: 2500,
    requestsDuration: 3600000,
    // server-load: max-lag allowed between callbacks
    maxLag: 1000
});

BodyParsing-config: webexapp.setBodyParserConfig(options)

The parsed body is available as req.body in case of JSON & URL-Encoded bodies. For other types, the body is available as a stream in req.rawBodyStream which can be pipe'd to other body-parsing modules like busboy

webexapp.setBodyParserConfig({
    jsonLimit: '10kb', // JSON body-limit
    urlencodedLimit: '10kb', // URLEncoded body-limit
    rawLimit: '100kb' // all other-types body-limit
});

WebServer-config: webexapp.setWebserverConfig(options)

webexapp.({
    // 0: as many cores; or, set non-zero 
    workers: 0,
    // server will run with following uid & gid
    setuid: 'ubuntu', 
    setgid: 'ubuntu',
    // listen on this port
    port: 8080
});

WebServer-instance: webexapp.WebServer([name])

var webexapp = require('../lib'),
    WebServer = webexapp.WebServer;

var server;

server = new WebServer(); // optional name defaults to 'webserver'
server.use('/hello', function (req, res) {
    res.send('hello world');
});
server.run();

Exported Modules

Some useful modules are export'ed from the main-module.

var webexapp = require('../lib'),
    express = webexapp.express,
    redis = webexapp.redis,
    winston = webexapp.winston;

License

MIT