@riocrypto/common 1.0.349 → 1.0.351

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,5 +1,5 @@
1
1
  import { CustomError } from "./custom-error";
2
- export declare class AdminNotFound extends CustomError {
2
+ export declare class AdminNotFoundError extends CustomError {
3
3
  statusCode: number;
4
4
  constructor();
5
5
  serializeErrors(): {
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AdminNotFound = void 0;
3
+ exports.AdminNotFoundError = void 0;
4
4
  const custom_error_1 = require("./custom-error");
5
- class AdminNotFound extends custom_error_1.CustomError {
5
+ class AdminNotFoundError extends custom_error_1.CustomError {
6
6
  constructor() {
7
7
  super("Admin not found");
8
8
  this.statusCode = 404;
9
- Object.setPrototypeOf(this, AdminNotFound.prototype);
9
+ Object.setPrototypeOf(this, AdminNotFoundError.prototype);
10
10
  }
11
11
  serializeErrors() {
12
12
  return [{ message: "Admin not found" }];
13
13
  }
14
14
  }
15
- exports.AdminNotFound = AdminNotFound;
15
+ exports.AdminNotFoundError = AdminNotFoundError;
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requireAdminApiKey = void 0;
4
4
  const not_authorized_error_1 = require("../errors/not-authorized-error");
5
5
  const requireAdminApiKey = (req, res, next) => {
6
- let apiKey = req.header("x-api-key");
7
- if (!apiKey || apiKey !== process.env.ORIGINAL_ADMIN_API_KEY) {
6
+ if (!req.validAdminApiKey) {
8
7
  throw new not_authorized_error_1.NotAuthorizedError();
9
8
  }
10
9
  next();
@@ -0,0 +1,9 @@
1
+ import { Request, Response, NextFunction } from "express";
2
+ declare global {
3
+ namespace Express {
4
+ interface Request {
5
+ validAdminApiKey?: boolean;
6
+ }
7
+ }
8
+ }
9
+ export declare const requireAdminApiKey: (req: Request, res: Response, next: NextFunction) => void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requireAdminApiKey = void 0;
4
+ const requireAdminApiKey = (req, res, next) => {
5
+ let apiKey = req.header("x-api-key");
6
+ if (apiKey === process.env.ORIGINAL_ADMIN_API_KEY) {
7
+ req.validAdminApiKey = true;
8
+ }
9
+ next();
10
+ };
11
+ exports.requireAdminApiKey = requireAdminApiKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common",
3
- "version": "1.0.349",
3
+ "version": "1.0.351",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",