mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 13:27:22 +00:00
feat(folders): removed old comments
This commit is contained in:
@@ -65,8 +65,7 @@ export const createFolder = async (req: Request, res: Response) => {
|
|||||||
const folderVersion = new FolderVersion({
|
const folderVersion = new FolderVersion({
|
||||||
workspace: workspaceId,
|
workspace: workspaceId,
|
||||||
environment,
|
environment,
|
||||||
// root condition
|
nodes: parentFolder,
|
||||||
nodes: parentFolder || folders.nodes,
|
|
||||||
});
|
});
|
||||||
await folderVersion.save();
|
await folderVersion.save();
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ const takeSecretSnapshotHelper = async ({
|
|||||||
workspace: workspaceId,
|
workspace: workspaceId,
|
||||||
environment,
|
environment,
|
||||||
folder: folderId,
|
folder: folderId,
|
||||||
// undefined means root thus collect all secrets
|
|
||||||
},
|
},
|
||||||
"_id"
|
"_id"
|
||||||
).lean()
|
).lean()
|
||||||
|
|||||||
@@ -1,34 +1,45 @@
|
|||||||
import * as Sentry from '@sentry/node';
|
import * as Sentry from '@sentry/node';
|
||||||
import { ErrorRequestHandler } from "express";
|
import { ErrorRequestHandler } from 'express';
|
||||||
import { InternalServerError } from "../utils/errors";
|
import { InternalServerError } from '../utils/errors';
|
||||||
import { getLogger } from "../utils/logger";
|
import { getLogger } from '../utils/logger';
|
||||||
import RequestError, { LogLevel } from "../utils/requestError";
|
import RequestError, { LogLevel } from '../utils/requestError';
|
||||||
import { getNodeEnv } from '../config';
|
|
||||||
|
|
||||||
export const requestErrorHandler: ErrorRequestHandler = async (error: RequestError | Error, req, res, next) => {
|
export const requestErrorHandler: ErrorRequestHandler = async (
|
||||||
if (res.headersSent) return next();
|
error: RequestError | Error,
|
||||||
if ((await getNodeEnv()) !== "production") {
|
req,
|
||||||
/* eslint-disable no-console */
|
res,
|
||||||
console.log(error)
|
next
|
||||||
/* eslint-enable no-console */
|
) => {
|
||||||
}
|
if (res.headersSent) return next();
|
||||||
|
|
||||||
//TODO: Find better way to type check for error. In current setting you need to cast type to get the functions and variables from RequestError
|
//TODO: Find better way to type check for error. In current setting you need to cast type to get the functions and variables from RequestError
|
||||||
if (!(error instanceof RequestError)) {
|
if (!(error instanceof RequestError)) {
|
||||||
error = InternalServerError({ context: { exception: error.message }, stack: error.stack });
|
error = InternalServerError({
|
||||||
(await getLogger('backend-main')).log((<RequestError>error).levelName.toLowerCase(), (<RequestError>error).message)
|
context: { exception: error.message },
|
||||||
}
|
stack: error.stack,
|
||||||
|
});
|
||||||
|
(await getLogger('backend-main')).log(
|
||||||
|
(<RequestError>error).levelName.toLowerCase(),
|
||||||
|
(<RequestError>error).message
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//* Set Sentry user identification if req.user is populated
|
//* Set Sentry user identification if req.user is populated
|
||||||
if (req.user !== undefined && req.user !== null) {
|
if (req.user !== undefined && req.user !== null) {
|
||||||
Sentry.setUser({ email: (req.user as any).email })
|
Sentry.setUser({ email: (req.user as any).email });
|
||||||
}
|
}
|
||||||
//* Only sent error to Sentry if LogLevel is one of the following level 'ERROR', 'EMERGENCY' or 'CRITICAL'
|
//* Only sent error to Sentry if LogLevel is one of the following level 'ERROR', 'EMERGENCY' or 'CRITICAL'
|
||||||
//* with this we will eliminate false-positive errors like 'BadRequestError', 'UnauthorizedRequestError' and so on
|
//* with this we will eliminate false-positive errors like 'BadRequestError', 'UnauthorizedRequestError' and so on
|
||||||
if ([LogLevel.ERROR, LogLevel.EMERGENCY, LogLevel.CRITICAL].includes((<RequestError>error).level)) {
|
if (
|
||||||
Sentry.captureException(error)
|
[LogLevel.ERROR, LogLevel.EMERGENCY, LogLevel.CRITICAL].includes(
|
||||||
}
|
(<RequestError>error).level
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Sentry.captureException(error);
|
||||||
|
}
|
||||||
|
|
||||||
res.status((<RequestError>error).statusCode).json((<RequestError>error).format(req))
|
res
|
||||||
next()
|
.status((<RequestError>error).statusCode)
|
||||||
}
|
.json((<RequestError>error).format(req));
|
||||||
|
next();
|
||||||
|
};
|
||||||
|
|||||||
@@ -127,7 +127,6 @@ const secretSchema = new Schema<ISecret>(
|
|||||||
required: true,
|
required: true,
|
||||||
default: ENCODING_SCHEME_UTF8,
|
default: ENCODING_SCHEME_UTF8,
|
||||||
},
|
},
|
||||||
// the full path to the secret in relation to folders
|
|
||||||
folder: {
|
folder: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "root",
|
default: "root",
|
||||||
|
|||||||
Reference in New Issue
Block a user