Application
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 thebody-parsermiddleware. Subkeys map to methods on body-parser, passingtruewill 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: Enablecompressionmiddleware. Usetrueto enable or an object to customize options. Defaults totrue.cors: Enable Expressify’s CORS middleware. Usetrueto enable or an object to customize its options. Defaults totrue.express: Use this to pass in a customexpressmodule. Defaults to the express module defined in Expressify’s dependencies.trustProxy: Set express’trust proxysetting. Defaults totrue.logger: A@ambassify/bunyan-loggercompatible logger instance.gracefulShutdown: HandlesSIGTERMandSIGINTsignals to gracefully shutdown the http server usinghttp-shutdown. Defaults totruegracefulShutdown.callback: a callback function (may be async) called when the server has shutdown. May be used to close database connections. Defaults tolodash/noop.gracefulShutdown.forceTimeout: milliseconds to wait before forcingprocess.exit(1)if shutdown hasn’t completed. Defaults to30000. Set to0to disable.
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
}
});