Giter Site home page Giter Site logo

express-pants's Introduction

Some nice pants for your Express App to wear

NPM Version NPM Downloads Build Status js-standard-style

A semi-opinionated framework for setting up Express apps.

Install

$ npm install --save express-pants

Usage

const createApp = require('express-pants')

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()
  // Log is a Pino logger
  app.get('log').info(`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)
  • Helmet (turned off by default, but turn on with options.helmet)
  • Pino logging with pino-http

express-pants's People

Contributors

wesleytodd avatar

Stargazers

Álvaro García León avatar Conor Hastings avatar Robby avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.