createRouter(app, [options])

Creates locale aware express router with universal cookie and gzip compression enabled.

Gzip compression is only enabled on production environment

Arguments

  • [options] (Object):

    • [routes] (Object.<Object>): An object which key is a route path and value is an object with the following properties:

      • page (String): Path to page component.

      • [method] (String): HTTP method, default is GET.

    • [redirects] (Object.<Object>): An object which key is a redirection source path and value is an object with the following properties:

      • to (String): Redirection target path.

      • [method] (String): HTTP method, default is GET.

      • [status] (Number): HTTP status code for redirection, default is 301.

    • [compression] (Object): See here for compression options.

    • [defaultLocale] (String): A locale string used as fallback locale, e.g. id-id, en-id, etc.

    • [siteLocales] (Array.<String>): An array of locale string supported by your app.

Returns

(Express.Router): An object of express router.

Examples

Basic Usage

Options

compression

defaultLocale and siteLocales

redirects

routes

Last updated