Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Bring back express-async-errors
Tuan Dang0deba5e3455f
diff --git a/backend/package-lock.json b/backend/package-lock.jsonindex a883ca9e1b..4d4b9fd237 100644--- a/backend/package-lock.json+++ b/backend/package-lock.json@@ -29,6 +29,7 @@"crypto-js": "^4.1.1","dotenv": "^16.0.1","express": "^4.18.1",+ "express-async-errors": "^3.1.1","express-rate-limit": "^6.7.0","express-validator": "^6.14.2","handlebars": "^4.7.7",@@ -40,8 +41,8 @@"libsodium-wrappers": "^0.7.10","lodash": "^4.17.21","mongoose": "^6.10.5",- "node-cache": "^5.1.2","nanoid": "^3.3.6",+ "node-cache": "^5.1.2","nodemailer": "^6.8.0","passport": "^0.6.0","passport-google-oauth20": "^2.0.0",@@ -5190,6 +5191,14 @@"node": ">= 0.10.0"}},+ "node_modules/express-async-errors": {+ "version": "3.1.1",+ "resolved": "https://registry.npmjs.org/express-async-errors/-/express-async-errors-3.1.1.tgz",+ "integrity": "sha512-h6aK1da4tpqWSbyCa3FxB/V6Ehd4EEB15zyQq9qe75OZBp0krinNKuH4rAY+S/U/2I36vdLAUFSjQJ+TFmODng==",+ "peerDependencies": {+ "express": "^4.16.2"+ }+ },"node_modules/express-rate-limit": {"version": "6.7.0","resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-6.7.0.tgz",@@ -16415,6 +16424,12 @@}}},+ "express-async-errors": {+ "version": "3.1.1",+ "resolved": "https://registry.npmjs.org/express-async-errors/-/express-async-errors-3.1.1.tgz",+ "integrity": "sha512-h6aK1da4tpqWSbyCa3FxB/V6Ehd4EEB15zyQq9qe75OZBp0krinNKuH4rAY+S/U/2I36vdLAUFSjQJ+TFmODng==",+ "requires": {}+ },"express-rate-limit": {"version": "6.7.0","resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-6.7.0.tgz",diff --git a/backend/package.json b/backend/package.jsonindex 6a054de94b..26d953356a 100644--- a/backend/package.json+++ b/backend/package.json@@ -20,6 +20,7 @@"crypto-js": "^4.1.1","dotenv": "^16.0.1","express": "^4.18.1",+ "express-async-errors": "^3.1.1","express-rate-limit": "^6.7.0","express-validator": "^6.14.2","handlebars": "^4.7.7",@@ -31,8 +32,8 @@"libsodium-wrappers": "^0.7.10","lodash": "^4.17.21","mongoose": "^6.10.5",- "node-cache": "^5.1.2","nanoid": "^3.3.6",+ "node-cache": "^5.1.2","nodemailer": "^6.8.0","passport": "^0.6.0","passport-google-oauth20": "^2.0.0",diff --git a/backend/src/index.ts b/backend/src/index.tsindex dd6642141d..51cddcde55 100644--- a/backend/src/index.ts+++ b/backend/src/index.ts@@ -1,6 +1,8 @@import dotenv from "dotenv";dotenv.config();import express from "express";+// eslint-disable-next-line @typescript-eslint/no-var-requires+require('express-async-errors');import helmet from "helmet";import cors from "cors";import { DatabaseService } from "./services";diff --git a/backend/src/utils/patchAsyncRoutes.js b/backend/src/utils/patchAsyncRoutes.jsdeleted file mode 100644index 24fe007f99..0000000000--- a/backend/src/utils/patchAsyncRoutes.js+++ /dev/null@@ -1,69 +0,0 @@-/*-Original work Copyright (c) 2016, Nikolay Nemshilov <[email protected]>-Modified work Copyright (c) 2016, David Banham <[email protected]>--Permission to use, copy, modify, and/or distribute this software for any purpose-with or without fee is hereby granted, provided that the above copyright notice-and this permission notice appear in all copies.--THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH-REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND-FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,-INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS-OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER-TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF-THIS SOFTWARE.--*/--/* eslint-disable @typescript-eslint/no-var-requires */-/* eslint-env node */-const Layer = require('express/lib/router/layer');-const Router = require('express/lib/router');--const last = (arr = []) => arr[arr.length - 1];-const noop = Function.prototype;--function copyFnProps(oldFn, newFn) {- Object.keys(oldFn).forEach((key) => {- newFn[key] = oldFn[key];- });- return newFn;-}--function wrap(fn) {- const newFn = function newFn(...args) {- const ret = fn.apply(this, args);- const next = (args.length === 5 ? args[2] : last(args)) || noop;- if (ret && ret.catch) ret.catch(err => next(err));- return ret;- };- Object.defineProperty(newFn, 'length', {- value: fn.length,- writable: false,- });- return copyFnProps(fn, newFn);-}--function patchRouterParam() {- const originalParam = Router.prototype.constructor.param;- Router.prototype.constructor.param = function param(name, fn) {- fn = wrap(fn);- return originalParam.call(this, name, fn);- };-}--Object.defineProperty(Layer.prototype, 'handle', {- enumerable: true,- get() {- return this.__handle;- },- set(fn) {- fn = wrap(fn);- this.__handle = fn;- },-});--module.exports = {- patchRouterParam-};diff --git a/backend/src/utils/setup/index.ts b/backend/src/utils/setup/index.tsindex 0ef14bfe66..61f17bebb3 100644--- a/backend/src/utils/setup/index.ts+++ b/backend/src/utils/setup/index.ts@@ -5,7 +5,6 @@ import { EELicenseService } from '../../ee/services';import { initSmtp } from '../../services/smtp';import { createTestUserForDevelopment } from '../addDevelopmentUser';// eslint-disable-next-line @typescript-eslint/no-var-requires-const { patchRouterParam } = require('../patchAsyncRoutes');import { validateEncryptionKeysConfig } from './validateConfig';import {backfillSecretVersions,@@ -38,7 +37,6 @@ import { initializePassport } from '../auth';* - Re-encrypting data*/export const setup = async () => {- patchRouterParam();await validateEncryptionKeysConfig();await TelemetryService.logTelemetryMessage();