@maon/middlewares

0.3.1 • Public • Published

Middlewares

middlewares

Overview

Middlewares is a simple wrapper around the required middlewares for an express app at maon.

Usage

Just like above:

import middlewares from '@maon/middlewares';
import express from 'express';

const app = express();

app.use(middlewares());

Import the module and use it. It works with CJS require as well.

Included packages

Configuration

All the included modules are imported with standard options but you can customize them by passing in an object

import middlewares from '@maon/middlewares';
import express from 'express';

const app = express();

app.use(middlewares({
    cors: {
        origin: 'http://example.com,
    },
}));

All configuration options in the documentations of the modules are available. If you want to disable a certain module, just pass in false as an option:

middlewares({
  cors: false,
});

The configurations are accessible via the names:

  • pino
  • helmet
  • validator
  • bodyParserJson
  • bodyParserUrl
  • serviceVersion
  • cors

Logger

To use the integrated logging function with the included request object write the following call:

app.get('/', (request, response) => {
  try {
    // Some working
  } catch (error) {
    request.log.error(error);
  }
});

Have fun coding!

Readme

Keywords

none

Package Sidebar

Install

npm i @maon/middlewares

Weekly Downloads

50

Version

0.3.1

License

UNLICENSED

Unpacked Size

95.6 kB

Total Files

6

Last publish

Collaborators

  • maon_fp
  • nicolaischmid