Refactor code for consistency; remove unnecessary whitespace and improve formatting in multiple files

This commit is contained in:
Simon Larsen 2024-09-26 15:07:02 +01:00
parent 98fe5deba7
commit 4982febd74
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
8 changed files with 14 additions and 25 deletions

View File

@ -94,7 +94,9 @@ export default class ProjectMiddleware {
// (req as OneUptimeRequest).permissions =
// apiKeyModel.permissions || [];
(req as OneUptimeRequest).userGlobalAccessPermission =
await APIKeyAccessPermission.getDefaultApiGlobalPermission(tenantId);
await APIKeyAccessPermission.getDefaultApiGlobalPermission(
tenantId,
);
const userTenantAccessPermission: UserTenantAccessPermission | null =
await APIKeyAccessPermission.getApiTenantAccessPermission(

View File

@ -31,7 +31,6 @@ import {
} from "Common/Types/Permission";
import UserType from "Common/Types/UserType";
import Project from "Common/Models/DatabaseModels/Project";
import { Socket } from "../Infrastructure/SocketIO";
import UserPermissionUtil from "../Utils/UserPermission/UserPermission";
export default class UserMiddleware {
@ -59,8 +58,6 @@ export default class UserMiddleware {
return accessToken;
}
public static getAccessTokenFromExpressRequest(
req: ExpressRequest,
): string | undefined {

View File

@ -16,8 +16,6 @@ import TeamPermission from "Common/Models/DatabaseModels/TeamPermission";
import UserPermissionUtil from "../Utils/UserPermission/UserPermission";
import PermissionNamespace from "../Types/Permission/PermissionNamespace";
export class AccessTokenService extends BaseService {
public constructor() {
super();
@ -61,8 +59,6 @@ export class AccessTokenService extends BaseService {
}
}
public async refreshUserGlobalAccessPermission(
userId: ObjectID,
): Promise<UserGlobalAccessPermission> {
@ -110,16 +106,14 @@ export class AccessTokenService extends BaseService {
public async getUserGlobalAccessPermission(
userId: ObjectID,
): Promise<UserGlobalAccessPermission | null> {
const json: UserGlobalAccessPermission | null = await UserPermissionUtil.getUserGlobalAccessPermissionFromCache(
userId,
)
const json: UserGlobalAccessPermission | null =
await UserPermissionUtil.getUserGlobalAccessPermissionFromCache(userId);
if (!json) {
return await this.refreshUserGlobalAccessPermission(userId);
}
return json;
}
public async refreshUserTenantAccessPermission(

View File

@ -1,6 +1,6 @@
enum PermissionNamespace {
GlobalPermission = "global-permissions",
ProjectPermission = "project-permissions",
}
}
export default PermissionNamespace;
export default PermissionNamespace;

View File

@ -11,7 +11,6 @@ import ApiKeyPermissionService from "../../Services/ApiKeyPermissionService";
import UserPermissionUtil from "../UserPermission/UserPermission";
export default class APIKeyAccessPermission {
public static async getDefaultApiGlobalPermission(
projectId: ObjectID,
): Promise<UserGlobalAccessPermission> {
@ -60,7 +59,6 @@ export default class APIKeyAccessPermission {
return permission;
}
public static async getApiTenantAccessPermission(
projectId: ObjectID,
apiKeyId: ObjectID,

View File

@ -93,7 +93,8 @@ export default abstract class Realtime {
// and to this model and to this event type
logger.debug("Extracting user access token from socket");
const userAccessToken: string | undefined = this.getAccessTokenFromSocket(socket);
const userAccessToken: string | undefined =
this.getAccessTokenFromSocket(socket);
if (!userAccessToken) {
logger.debug(

View File

@ -9,7 +9,6 @@ import GlobalCache from "../../Infrastructure/GlobalCache";
import PermissionNamespace from "../../Types/Permission/PermissionNamespace";
export default class UserPermissionUtil {
public static async getUserTenantAccessPermissionFromCache(
userId: ObjectID,
projectId: ObjectID,

View File

@ -1,5 +1,4 @@
Error.stackTraceLimit = Infinity
Error.stackTraceLimit = Infinity;
import WorkflowRoutes from "./Routes";
import { PromiseVoidFunction } from "Common/Types/FunctionTypes";
@ -13,7 +12,6 @@ import Redis from "Common/Server/Infrastructure/Redis";
import { ClickhouseAppInstance } from "Common/Server/Infrastructure/ClickhouseDatabase";
import "ejs";
const APP_NAME: string = "workflow";
const init: PromiseVoidFunction = async (): Promise<void> => {