2ex
An opinionated express application framework
Last updated a year ago by wesleytodd .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install 2ex 
SYNC missed versions from official npm registry.

2ex (pronounced 2X)

NPM Version NPM Downloads Build Status js-standard-style

A semi-opinionated framework for setting up Express apps.

Install

$ npm install --save 2ex

Usage

const createApp = require('2ex')

const runApp = createApp((app, opts = {}) => {
  // Handle app errors
  app.on('error', console.error)

  // Load in your routes
  app.get('/', (req, res) => {
    res.send(`Hello ${opts.message}!`)
  })
})

// Start the app
runApp({
  port: 8080,
  message: 'World'
}).then(({ app, server }) => {
  const addr = server.address()
  console.log(`Server started at http://${app.get('host')}:${addr.port}`)
})

What does it do?

This package sets up common requirements for running an Express app in production with the goal of reducing boilerplate in your applications. Here is a list of some of those things:

  • Uses next gen Express (5.0.0-alpha.7 at the time of publishing this)
  • Express app settings
    • Remove x-powered-by header
    • Sets query string parsing to simple (faster, more secure, planned default for 5.0)
  • Set process title (nice for identifying your server process)
  • Catch, report and exit on uncaughtException and unhandledRejection
  • Handle and report server clientErrors
  • Parses JSON bodies
  • Parses cookies (off by default, turn on by passing options.parseCookies

Current Tags

  • 1.0.0-3                                ...           latest (a year ago)

4 Versions

  • 1.0.0-3                                ...           a year ago
  • 1.0.0-2                                ...           a year ago
  • 1.0.0-1                                ...           a year ago
  • 1.0.0-0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 19
Last Day 0
Last Week 6
Last Month 8
Dependencies (5)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |