@zdigital/middlewares
v2.0.7
Published
Middleware collection for Express applications.
Downloads
5
Readme
@zdigital/middlewares
Middleware collection for Express applications.
Install
$ npm i @zdigital/middlewares --save
Library
withAlerts
withAuth
withLocale
withModules
withSEO
withState
withStore
Usage
const {
withAlerts,
withAuth,
withLocale,
withModules,
withSEO,
withState,
withStore,
} = require('@zdigital/middlewares');
const withLocaleMap = {
en: require('./locale/en.json'),
pt: require('./locale/pt.json'),
es: require('./locale/es.json'),
it: require('./locale/it.json'),
de: require('./locale/de.json'),
};
const withLocaleOptions = {
isWebsiteLocalized: true,
defaultLocale: 'en',
supportedLocales: Object.keys(withLocaleMap),
};
const { state } = require('@zdigital/core');
app.get('*', [
withAlerts,
withAuth,
withLocale(withLocaleMap, withLocaleOptions),
withModules,
withSEO,
withState(state),
withStore(require('./../path/to/store')),
], (req, res, next) => next());