Expressify’s app factory. This module exports a function you can use to create and configure an express app. With some often used settings and middlewares.

Options

  • body: Object to configure the body-parser middleware. Subkeys map to methods on body-parser, passing true will call the method without options while setting an object will pass that object to body parser. Defaults to { json: true } to enable JSON formatted body parsing.
  • compression: Enable compression middleware. Use true to enable or an object to customize options. Defaults to true.
  • cors: Enable Expressify’s CORS middleware. Use true to enable or an object to customize its options. Defaults to true.
  • express: Use this to pass in a custom express module. Defaults to the express module defined in Expressify’s dependencies.
  • trustProxy: Set express’ trust proxy setting. Defaults to true.

Example

const expressify = require('@ambassify/expressify');

// Default options
const app = expressify.createApp();

// URL encoded body instead of JSON
const app = expressify.createApp({
    body: {
        urlencoded: true
    }
});