From 5f6f99247f28eb017c365657f4aee5ef3dfd6946 Mon Sep 17 00:00:00 2001 From: nickviola Date: Fri, 1 Dec 2023 08:11:29 -0600 Subject: [PATCH] Fix linter issues --- backend/src/api/organizations.ts | 34 +++++++++++++------------------- backend/src/api/roles.ts | 19 +++++++++--------- backend/src/api/users.ts | 4 +--- backend/src/tasks/syncdb.ts | 16 ++++++++------- 4 files changed, 33 insertions(+), 40 deletions(-) diff --git a/backend/src/api/organizations.ts b/backend/src/api/organizations.ts index 379e530dd..b70c0e95b 100644 --- a/backend/src/api/organizations.ts +++ b/backend/src/api/organizations.ts @@ -7,8 +7,7 @@ import { IsOptional, IsNotEmpty, IsNumber, - IsEnum, - + IsEnum } from 'class-validator'; import { Organization, @@ -70,7 +69,6 @@ class PendingDomainBody { pendingDomains: PendingDomain[]; } - class NewOrganizationNonGlobalAdmins { @IsString() name: string; @@ -147,7 +145,6 @@ class UpdateOrganizationMetaV2 { @IsNotEmpty() @IsOptional() type: string; - } class NewDomain { @@ -699,7 +696,6 @@ export const removeRole = wrapHandler(async (event) => { }; }); - /** * @swagger * @@ -751,7 +747,7 @@ export const getByState = wrapHandler(async (event) => { where: { state: state } }); - if (result) { + if (result) { return { statusCode: 200, body: JSON.stringify(result) @@ -760,7 +756,7 @@ export const getByState = wrapHandler(async (event) => { return NotFound; }); -// V2 Endpoints +//V2 Endpoints /** * @swagger @@ -789,14 +785,13 @@ export const getByState = wrapHandler(async (event) => { */ export const getAllV2 = wrapHandler(async (event) => { if (!isRegionalAdmin(event)) return Unauthorized; - - const filterParams = {} + const filterParams = {}; if (event.query && event.query.state) { - filterParams["state"] = event.query.state; + filterParams['state'] = event.query.state; } if (event.query && event.query.regionId) { - filterParams["regionId"] = event.query.regionId; + filterParams['regionId'] = event.query.regionId; } await connectToDatabase(); @@ -805,9 +800,11 @@ export const getAllV2 = wrapHandler(async (event) => { return { statusCode: 200, body: JSON.stringify(result) - } + }; } else { - const result = await Organization.find({where: filterParams}); + const result = await Organization.find({ + where: filterParams + }); return { statusCode: 200, body: JSON.stringify(result) @@ -887,8 +884,7 @@ export const addUserV2 = wrapHandler(async (event) => { // Validate the body const body = await validateBody( - NewOrganizationRoleBody, - event.body + NewOrganizationRoleBody, event.body ); // Connect to the database @@ -904,7 +900,7 @@ export const addUserV2 = wrapHandler(async (event) => { const org = await Organization.findOne(orgId); // Get the user id from the body - const userId = body.userId + const userId = body.userId; // confirm that the userId is a valid UUID if (!userId || !isUUID(userId)) { return NotFound; @@ -916,12 +912,10 @@ export const addUserV2 = wrapHandler(async (event) => { user: user, organization: org, approved: true, - // role: body.role, role: body.role, approvedBy: event.requestContext.authorizer!.id, createdBy: event.requestContext.authorizer!.id - } - // const validatedRoleData = await validateBody(NewOrganizationRoleDB, JSON.stringify(newRoleData)); + }; // Add a role to make association to user/organization const newRole = Role.create(newRoleData); @@ -937,4 +931,4 @@ export const addUserV2 = wrapHandler(async (event) => { }; } return NotFound; -}); \ No newline at end of file +}); diff --git a/backend/src/api/roles.ts b/backend/src/api/roles.ts index f11b42f35..f72b445f2 100644 --- a/backend/src/api/roles.ts +++ b/backend/src/api/roles.ts @@ -68,7 +68,6 @@ class PendingDomainBody { pendingDomains: PendingDomain[]; } - class NewOrganizationNonGlobalAdmins { @IsString() name: string; @@ -145,7 +144,6 @@ class UpdateOrganizationMetaV2 { @IsNotEmpty() @IsOptional() type: string; - } class NewDomain { @@ -668,7 +666,6 @@ export const removeRole = wrapHandler(async (event) => { }; }); - /** * @swagger * @@ -690,7 +687,7 @@ export const getByRegionId = wrapHandler(async (event) => { where: { regionId: regionId } }); - if (result) { + if (result) { return { statusCode: 200, body: JSON.stringify(result) @@ -720,7 +717,7 @@ export const getByState = wrapHandler(async (event) => { where: { state: state } }); - if (result) { + if (result) { return { statusCode: 200, body: JSON.stringify(result) @@ -762,10 +759,10 @@ export const getAllV2 = wrapHandler(async (event) => { const filterParams = {} if (event.query && event.query.state) { - filterParams["state"] = event.query.state; + filterParams['state'] = event.query.state; } if (event.query && event.query.regionId) { - filterParams["regionId"] = event.query.regionId; + filterParams['regionId'] = event.query.regionId; } await connectToDatabase(); @@ -774,9 +771,11 @@ export const getAllV2 = wrapHandler(async (event) => { return { statusCode: 200, body: JSON.stringify(result) - } + }; } else { - const result = await Organization.find({where: filterParams}); + const result = await Organization.find({ + where: filterParams + }); return { statusCode: 200, body: JSON.stringify(result) @@ -832,4 +831,4 @@ export const updateV2 = wrapHandler(async (event) => { }; } return NotFound; -}); \ No newline at end of file +}); diff --git a/backend/src/api/users.ts b/backend/src/api/users.ts index a3c5e6b27..7ac61155a 100644 --- a/backend/src/api/users.ts +++ b/backend/src/api/users.ts @@ -199,8 +199,7 @@ const REGION_STATE_MAP = { Idaho: '10', Oregon: '10', Washington: '10' -} - +}; /** * @swagger @@ -278,7 +277,6 @@ export const update = wrapHandler(async (event) => { return NotFound; }); - const sendInviteEmail = async (email: string, organization?: Organization) => { const staging = process.env.NODE_ENV !== 'production'; diff --git a/backend/src/tasks/syncdb.ts b/backend/src/tasks/syncdb.ts index ccc9d6d7e..18e9d3e06 100644 --- a/backend/src/tasks/syncdb.ts +++ b/backend/src/tasks/syncdb.ts @@ -25,14 +25,14 @@ const NUM_SAMPLE_DOMAINS = 10; // Number of sample domains per org const PROB_SAMPLE_SERVICES = 0.5; // Higher number means more services per domain const PROB_SAMPLE_VULNERABILITIES = 0.5; // Higher number means more vulnerabilities per domain const SAMPLE_STATES = [ - "VA", - "CA", - "CO" + 'VA', + 'CA', + 'CO' ] const SAMPLE_REGIONIDS = [ - "1", - "2", - "3" + '1', + '2', + '3' ] export const handler: Handler = async (event) => { @@ -90,7 +90,9 @@ export const handler: Handler = async (event) => { isPassive: false, tags: [tag], state: SAMPLE_STATES[Math.floor(Math.random() * SAMPLE_STATES.length)], - regionId: SAMPLE_REGIONIDS[Math.floor(Math.random() * SAMPLE_REGIONIDS.length)], + regionId: SAMPLE_REGIONIDS[ + Math.floor(Math.random() * SAMPLE_REGIONIDS.length) + ], }).save(); console.log(organization.name); organizationIds.push(organization.id);