@maeum/error-controller
TypeScript icon, indicating that this package has built-in type declarations

2.7.1 • Public • Published

@maeum/error-controller

ts Download Status Github Star Github Issues NPM version License ci code style: prettier

Error hander extension of the Maeum boilerplate.

Table of Contents

Getting Start

npm i @maeum/error-controller --save

How it works?

@maeum/error-controller create error handler for fastify.setErrorHandler function.

server.setErrorHandler(
  errorHandler([], {
  [CE_MAEUM_DEFAULT_ERROR_HANDLER.COMMON]: (req, id, param) => getLocales(req.headers['accept-language']).t(id, param),
  [CE_MAEUM_DEFAULT_ERROR_HANDLER.DEFAULT_REST_ERROR]: (req, id, param) => getLocales(req.headers['accept-language']).t(id, param),
}, {
    hooks: {
      [CE_MAEUM_DEFAULT_ERROR_HANDLER.COMMON]: {
        pre: (err: Error & { validation?: ErrorObject[] }, req: FastifyRequest) => {
          req.setRequestError(err);
        },
      },
    },
    encryptor: (code: string): string => {
      if (
        config.server.runMode === CE_RUN_MODE.STAGE ||
        config.server.runMode === CE_RUN_MODE.PRODUCTION
      ) {
        return encrypt(code);
      }

      return code;
    },
  }),
);

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.7.13latest

Version History

VersionDownloads (Last 7 Days)Published
2.7.13
2.7.00
2.6.00
2.5.00
2.4.00
2.3.00
2.2.10
2.2.00
2.1.00
2.0.00
1.2.00
1.1.00

Package Sidebar

Install

npm i @maeum/error-controller

Weekly Downloads

3

Version

2.7.1

License

MIT

Unpacked Size

140 kB

Total Files

8

Last publish

Collaborators

  • jooni