2.7.1 • Published 5 months ago

@maeum/error-controller v2.7.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@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;
    },
  }),
);
2.7.0

5 months ago

2.6.0

5 months ago

2.7.1

5 months ago

2.5.0

6 months ago

2.4.0

6 months ago

2.3.0

9 months ago

2.2.1

10 months ago

2.2.0

12 months ago

2.1.0

12 months ago

2.0.0

12 months ago

1.2.0

1 year ago

1.1.0

1 year ago