1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40import { graphql } from '#src/utils';
export const getScans = async ({ request, reply }) => {
const response = await graphql({
request,
query: `query($limit: Int, $offset: Int){
scans: scans_aggregate(limit: $limit, offset: $offset, order_by: {created_at: desc}, ${(request.query.scanIds) ? `where: { id: {_in: [
${request.query.scanIds.split(',').map(obj => `"${obj}"`).join()}
]}}` : ''}
) {
nodes {
id
createdAt: created_at
processing
jobId: job_id
results
property {
id
name
}
url {
id
url
}
}
totalCount: aggregate {count}
}
}`,
variables: {
limit: parseInt(request.query.limit ?? 5000),
offset: parseInt(request.query.offset ?? 0),
},
});
return {
status: 'success',
result: response?.scans?.nodes,
total: response?.scans?.totalCount?.count,
};
}