@zdigital/middlewares

2.0.7 • Public • Published

@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());

License

MIT © Zona Digital

Readme

Keywords

none

Package Sidebar

Install

npm i @zdigital/middlewares

Weekly Downloads

24

Version

2.0.7

License

MIT

Unpacked Size

15.1 kB

Total Files

14

Last publish

Collaborators

  • zonadigital