1.5.5 • Published 5 months ago

exframe-middleware v1.5.5

Weekly downloads
119
License
ISC
Repository
bitbucket
Last release
5 months ago

Exframe Middleware

This module aims to provide a singular repo of commonly used middleware functions for Express apps and RabbitMQ rpc apps

Functions

authorizeUser

Checks for the user object and throws an Unauthorized error if it doesn't exist

buildCspFromMessage

builds the csp object from the message containing companyCode, state, and product on the top most level

buildExpressRequestContext

builds the request context for express, acquiring the requestId, accessToken, log, and user objects into the context object within the request

handleErrors

error handler middleware for mq and express, it handles thrown errors and reports their status and message

  const { handleErrors } = require('exframe-middleware');

  // express instance
  app.use(handleErrors().express);

  // exframe-mq instance
  client.use(handleErrors().mq);

standardRouteResponseBuilder

builds the response object based on input and if single or multi response

example from in production

  subscribe(
    'startBoBTransfers',
    validateRequestRPC(schemas.startBoBTransfer),
    (context, message) => startBoBTransfer.start(context, message).then(standardRouteResponseBuilder.singleItem)
  )
1.5.5

5 months ago

1.5.4

2 years ago

1.5.3

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.2

3 years ago

1.3.0

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago