@tabletennisshop/common 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  import { NextFunction } from "express";
2
- export declare const CheckAuthorized: (req: Request, res: Response, next: NextFunction) => Promise<void>;
2
+ export declare const CheckAuthorizedMiddleware: (req: Request, res: Response, next: NextFunction) => Promise<void>;
@@ -12,14 +12,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.CheckAuthorized = void 0;
15
+ exports.CheckAuthorizedMiddleware = void 0;
16
16
  const axios_1 = __importDefault(require("axios"));
17
17
  const not_authorized_error_1 = require("../errors/not-authorized-error");
18
- const CheckAuthorized = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
18
+ const CheckAuthorizedMiddleware = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
19
19
  const axiosRes = yield axios_1.default.get("localhost:3000/api/users/current-user");
20
20
  if (axiosRes.status != 200) {
21
21
  throw new not_authorized_error_1.NotAuthorizedError("Not Authorized");
22
22
  }
23
23
  next();
24
24
  });
25
- exports.CheckAuthorized = CheckAuthorized;
25
+ exports.CheckAuthorizedMiddleware = CheckAuthorizedMiddleware;
@@ -1,2 +1,2 @@
1
1
  import { NextFunction, Request, Response } from "express";
2
- export declare const errorHandler: (err: Error, req: Request, res: Response, next: NextFunction) => void;
2
+ export declare const ErrorHandlerMiddleware: (err: Error, req: Request, res: Response, next: NextFunction) => void;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.errorHandler = void 0;
3
+ exports.ErrorHandlerMiddleware = void 0;
4
4
  const custom_error_1 = require("../errors/custom-error");
5
- const errorHandler = (err, req, res, next) => {
5
+ const ErrorHandlerMiddleware = (err, req, res, next) => {
6
6
  if (err instanceof custom_error_1.CustomError) {
7
7
  res.status(err.statusCode).send({ errors: err.serializeErrors() });
8
8
  return;
@@ -10,4 +10,4 @@ const errorHandler = (err, req, res, next) => {
10
10
  res.status(400).send({ errors: [{ message: "Something is wrong" }] });
11
11
  return;
12
12
  };
13
- exports.errorHandler = errorHandler;
13
+ exports.ErrorHandlerMiddleware = ErrorHandlerMiddleware;
@@ -1,3 +1,3 @@
1
1
  import { NextFunction, Request, Response } from 'express';
2
- declare const validateRequestMiddleware: (req: Request, res: Response, next: NextFunction) => void;
3
- export default validateRequestMiddleware;
2
+ declare const ValidateRequestMiddleware: (req: Request, res: Response, next: NextFunction) => void;
3
+ export default ValidateRequestMiddleware;
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const express_validator_1 = require("express-validator");
4
4
  const request_validate_error_1 = require("../errors/request-validate-error");
5
- const validateRequestMiddleware = (req, res, next) => {
5
+ const ValidateRequestMiddleware = (req, res, next) => {
6
6
  const errors = (0, express_validator_1.validationResult)(req);
7
7
  if (!errors.isEmpty()) {
8
8
  throw new request_validate_error_1.RequestValidateError(errors.array());
9
9
  }
10
10
  next();
11
11
  };
12
- exports.default = validateRequestMiddleware;
12
+ exports.default = ValidateRequestMiddleware;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tabletennisshop/common",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",