Skip to content

Commit

Permalink
Exposed pollOutstandingScan as endpoint for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
azdak committed Nov 20, 2024
1 parent f083183 commit f61d3a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { addPages, getScan, addProperties, addReports, addResults, addScans, del
import { CognitoJwtVerifier } from 'aws-jwt-verify';
import { db } from './utils';
import { suggestIssue } from './routes/suggestIssue';
import { pollOutstandingScans } from './internal';

export const fastify = Fastify();
const cognitoJwtVerifier = CognitoJwtVerifier.create({
Expand Down Expand Up @@ -70,6 +71,9 @@ fastify.post('/help', {}, async (request, reply) => help({ request, reply }));
fastify.post('/track/user', {}, async (request, reply) => trackUser({ request, reply }));
fastify.post('/ai/suggest-issue', {}, async (request, reply) => suggestIssue({ request, reply }));

// TESTING requests
fastify.post('/testing/pollOutstandingScans', {}, (request, reply) => pollOutstandingScans({ request, reply }));

fastify.listen({ port: 3000 }, (err) => {
console.log(`Server listening on ${fastify.server.address().port}`)
if (err) throw err
Expand Down
6 changes: 4 additions & 2 deletions src/internal/pollOutstandingScans.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { chunk, db, isStaging, sleep, hashStringToUuid } from '#src/utils';
export const pollOutstandingScans = async () => {
export const pollOutstandingScans = async ({ request, reply }) => {
console.log(`START POLLING OPEN SCANS`);
const startTime = new Date().getTime();
const jobIds = (await db.query({
Expand All @@ -8,5 +8,7 @@ export const pollOutstandingScans = async () => {
await db.clean();
const deltaTime = new Date().getTime() - startTime;
console.log(`END PROCESS SCANS, took ${deltaTime}`);
return;
return {
jobIds
};
}

0 comments on commit f61d3a0

Please sign in to comment.