-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathsnyk.ts
More file actions
36 lines (31 loc) · 792 Bytes
/
snyk.ts
File metadata and controls
36 lines (31 loc) · 792 Bytes
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
// Import Third-party Dependencies
import * as httpie from "@openally/httpie";
// Import Internal Dependencies
import { SNYK_ORG, SNYK_TOKEN } from "../constants.ts";
import type { SnykAuditResponse } from "../formats/snyk/index.ts";
// CONSTANTS
export const ROOT_API = "https://snyk.io";
export type SnykFindOneParameters = {
files: {
target: {
contents: string;
};
additional?: {
contents: string;
}[];
};
};
export async function findOne(
parameters: SnykFindOneParameters
): Promise<SnykAuditResponse> {
const { data } = await httpie.post<SnykAuditResponse>(
new URL(`/api/v1/test/npm?org=${SNYK_ORG}`, ROOT_API),
{
headers: {
Authorization: `token ${SNYK_TOKEN}`
},
body: parameters
}
);
return data;
}