Skip to content

Commit

Permalink
Added get filters route to show available filters when creating a report
Browse files Browse the repository at this point in the history
  • Loading branch information
heythisischris committed Jun 30, 2024
1 parent f9bbfc5 commit 898ecb4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Fastify from 'fastify';
import { addProperties, addReports, addResults, addScans, deleteProperties, deleteReports, getProperties, getReports, getResults, getScans, getUpdates, graphql, help, updateProperties, updateReports } from '#src/routes';
import { addProperties, addReports, addResults, addScans, deleteProperties, deleteReports, getFilters, getProperties, getReports, getResults, getScans, getUpdates, graphql, help, updateProperties, updateReports } from '#src/routes';
import { CognitoJwtVerifier } from 'aws-jwt-verify';
export const fastify = Fastify({ logger: true });
const cognitoJwtVerifier = CognitoJwtVerifier.create({
Expand All @@ -25,6 +25,7 @@ fastify.get('/get/properties', {}, async (request, reply) => getProperties({ req
fastify.get('/get/updates', {}, async (request, reply) => getUpdates({ request, reply }));
fastify.get('/get/scans', {}, async (request, reply) => getScans({ request, reply }));
fastify.get('/get/reports', {}, async (request, reply) => getReports({ request, reply }));
fastify.get('/get/filters', {}, async (request, reply) => getFilters({ request, reply }));

// POST requests
fastify.post('/add/results', {}, async (request, reply) => addResults({ request, reply }));
Expand Down
29 changes: 29 additions & 0 deletions src/routes/getFilters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { graphqlQuery } from '#src/utils';

export const getFilters = async ({ request, reply }) => {
const response = (await graphqlQuery({
query: `{
messages {
value: id
label: message
}
tags {
value: id
label: tag
}
properties {
value: id
label: name
}
urls {
value: id
label: url
}
}`
}))?.data;

return {
status: 'success',
result: { ...response, statuses: { label: 'Active', value: 'Active' } },
};
}
3 changes: 2 additions & 1 deletion src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export * from './graphql'
export * from './help'
export * from './updateProperties'
export * from './updateReports'
export * from './webhookMonitorUpdate'
export * from './webhookMonitorUpdate'
export * from './getFilters'

0 comments on commit 898ecb4

Please sign in to comment.