Skip to content

Commit

Permalink
Fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nickviola committed Dec 1, 2023
1 parent 7bfef58 commit 5f6f992
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 40 deletions.
34 changes: 14 additions & 20 deletions backend/src/api/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
IsOptional,
IsNotEmpty,
IsNumber,
IsEnum,

IsEnum
} from 'class-validator';
import {
Organization,
Expand Down Expand Up @@ -70,7 +69,6 @@ class PendingDomainBody {
pendingDomains: PendingDomain[];
}


class NewOrganizationNonGlobalAdmins {
@IsString()
name: string;
Expand Down Expand Up @@ -147,7 +145,6 @@ class UpdateOrganizationMetaV2 {
@IsNotEmpty()
@IsOptional()
type: string;

}

class NewDomain {
Expand Down Expand Up @@ -699,7 +696,6 @@ export const removeRole = wrapHandler(async (event) => {
};
});


/**
* @swagger
*
Expand Down Expand Up @@ -751,7 +747,7 @@ export const getByState = wrapHandler(async (event) => {
where: { state: state }
});

if (result) {
if (result) {
return {
statusCode: 200,
body: JSON.stringify(result)
Expand All @@ -760,7 +756,7 @@ export const getByState = wrapHandler(async (event) => {
return NotFound;

Check failure on line 756 in backend/src/api/organizations.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `·`
});

// V2 Endpoints
//V2 Endpoints

/**
* @swagger
Expand Down Expand Up @@ -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();
Expand All @@ -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)
Expand Down Expand Up @@ -887,8 +884,7 @@ export const addUserV2 = wrapHandler(async (event) => {

// Validate the body
const body = await validateBody(

Check failure on line 886 in backend/src/api/organizations.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎····NewOrganizationRoleBody,·event.body⏎··` with `NewOrganizationRoleBody,·event.body`
NewOrganizationRoleBody,
event.body
NewOrganizationRoleBody, event.body
);

// Connect to the database
Expand All @@ -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;
Expand All @@ -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

Check failure on line 917 in backend/src/api/organizations.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `·`
}
// const validatedRoleData = await validateBody(NewOrganizationRoleDB, JSON.stringify(newRoleData));
};

// Add a role to make association to user/organization
const newRole = Role.create(newRoleData);
Expand All @@ -937,4 +931,4 @@ export const addUserV2 = wrapHandler(async (event) => {
};
}
return NotFound;
});
});
19 changes: 9 additions & 10 deletions backend/src/api/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class PendingDomainBody {
pendingDomains: PendingDomain[];
}


class NewOrganizationNonGlobalAdmins {
@IsString()
name: string;
Expand Down Expand Up @@ -145,7 +144,6 @@ class UpdateOrganizationMetaV2 {
@IsNotEmpty()
@IsOptional()
type: string;

}

class NewDomain {
Expand Down Expand Up @@ -668,7 +666,6 @@ export const removeRole = wrapHandler(async (event) => {
};
});


/**
* @swagger
*
Expand All @@ -690,7 +687,7 @@ export const getByRegionId = wrapHandler(async (event) => {
where: { regionId: regionId }
});

if (result) {
if (result) {
return {
statusCode: 200,
body: JSON.stringify(result)
Expand Down Expand Up @@ -720,7 +717,7 @@ export const getByState = wrapHandler(async (event) => {
where: { state: state }
});

if (result) {
if (result) {
return {
statusCode: 200,
body: JSON.stringify(result)
Expand Down Expand Up @@ -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();
Expand All @@ -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)
Expand Down Expand Up @@ -832,4 +831,4 @@ export const updateV2 = wrapHandler(async (event) => {
};
}
return NotFound;
});
});
4 changes: 1 addition & 3 deletions backend/src/api/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ const REGION_STATE_MAP = {
Idaho: '10',
Oregon: '10',
Washington: '10'
}

};

/**
* @swagger
Expand Down Expand Up @@ -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';

Expand Down
16 changes: 9 additions & 7 deletions backend/src/tasks/syncdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5f6f992

Please sign in to comment.