Run linter

This commit is contained in:
Tuan Dang
2023-08-07 11:25:06 +07:00
parent 373dfff8e0
commit 648968c453
40 changed files with 130 additions and 106 deletions
@@ -1,20 +1,19 @@
import { Request, Response } from "express";
import { PipelineStage, Types } from "mongoose";
import { Secret, Membership, User, ServiceTokenData } from "../../../models";
import { Membership, Secret, ServiceTokenData, User } from "../../../models";
import {
ActorType,
AuditLog,
FolderVersion,
IPType,
ISecretVersion,
Log,
SecretSnapshot,
SecretVersion,
ServiceActor,
TFolderRootVersionSchema,
TrustedIP,
AuditLog,
Actor,
ActorType,
UserActor,
ServiceActor
UserActor
} from "../../models";
import { EESecretService } from "../../services";
import { getLatestSecretVersionIds } from "../../helpers/secretVersion";
@@ -599,7 +598,7 @@ export const getWorkspaceLogs = async (req: Request, res: Response) => {
};
/**
* Return trusted ips for workspace with id [workspaceId]
* Return audit logs for workspace with id [workspaceId]
* @param req
* @param res
*/
@@ -608,6 +607,8 @@ export const getWorkspaceAuditLogs = async (req: Request, res: Response) => {
const eventType = req.query.eventType;
const userAgentType = req.query.userAgentType;
const actor = req.query.actor as string | undefined;
const offset: number = parseInt(req.query.offset as string);
const limit: number = parseInt(req.query.limit as string);
const auditLogs = await AuditLog.find({
workspace: new Types.ObjectId(workspaceId),
@@ -626,7 +627,9 @@ export const getWorkspaceAuditLogs = async (req: Request, res: Response) => {
})
} : {})
})
.sort({ createdAt: -1 });
.sort({ createdAt: -1 })
.skip(offset)
.limit(limit);
return res.status(200).send({
auditLogs
@@ -634,7 +637,7 @@ export const getWorkspaceAuditLogs = async (req: Request, res: Response) => {
}
/**
* Return trusted ips for workspace with id [workspaceId]
* Return audit log actor filter options for workspace with id [workspaceId]
* @param req
* @param res
*/
+1 -1
View File
@@ -8,7 +8,7 @@ import {
import { body, param, query } from "express-validator";
import { organizationsController } from "../../controllers/v1";
import {
ACCEPTED, ADMIN, MEMBER, OWNER, AuthMode
ACCEPTED, ADMIN, AuthMode, MEMBER, OWNER
} from "../../../variables";
router.get(
+2 -2
View File
@@ -9,10 +9,10 @@ import { body, param, query } from "express-validator";
import { secretController } from "../../controllers/v1";
import {
ADMIN,
AuthMode,
MEMBER,
PERMISSION_READ_SECRETS,
PERMISSION_WRITE_SECRETS,
AuthMode
PERMISSION_WRITE_SECRETS
} from "../../../variables";
router.get(
+1 -1
View File
@@ -8,7 +8,7 @@ import {
validateRequest,
} from "../../../middleware";
import { param } from "express-validator";
import { ADMIN, MEMBER, AuthMode } from "../../../variables";
import { ADMIN, AuthMode, MEMBER } from "../../../variables";
import { secretSnapshotController } from "../../controllers/v1";
router.get(
+2 -2
View File
@@ -15,8 +15,8 @@ import { authLimiter } from "../../../helpers/rateLimiter";
import {
ACCEPTED,
ADMIN,
OWNER,
AuthMode
AuthMode,
OWNER
} from "../../../variables";
router.get(
+4 -2
View File
@@ -8,8 +8,8 @@ import {
import { body, param, query } from "express-validator";
import {
ADMIN,
MEMBER,
AuthMode
AuthMode,
MEMBER
} from "../../../variables";
import { workspaceController } from "../../controllers/v1";
import { EventType, UserAgentType } from "../../models";
@@ -97,6 +97,8 @@ router.get(
query("eventType").isString().isIn(Object.values(EventType)).optional({ nullable: true }),
query("userAgentType").isString().isIn(Object.values(UserAgentType)).optional({ nullable: true }),
query("actor").isString().optional({ nullable: true }),
query("offset").isString().default("0"),
query("limit").isString().default("20"),
validateRequest,
workspaceController.getWorkspaceAuditLogs
);
+2 -2
View File
@@ -11,8 +11,8 @@ interface EventScope {
}
type ValidEventScope =
| Required<Pick<EventScope, 'workspaceId'>>
| Required<Pick<EventScope, 'organizationId'>>
| Required<Pick<EventScope, "workspaceId">>
| Required<Pick<EventScope, "organizationId">>
| Required<EventScope>
export default class EEAuditLogService {