Web Application Framework Using Express JS
var webexapp = WebServer = webexappWebServer; var server; server = ;server;server;
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;
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.
For e.g., you can use winston.debug("some message") to log messages.
Redis-config: webexapp.setRedisConfig(options)
webexapp;
Sessions-config: webexapp.setCookieSessionConfig(options)
webexapp;
Security-config: webexapp.setSecurityConfig(options)
webexapp;
Limits-config: webexapp.setLimitsConfig(options)
webexapp;
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;
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 = WebServer = webexappWebServer; var server; server = ; // optional name defaults to 'webserver'server;server;
Exported Modules
Some useful modules are export'ed from the main-module.
var webexapp = express = webexappexpress redis = webexappredis winston = webexappwinston;