-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pass snykHttpClient to plugin.inspect
- Loading branch information
Showing
15 changed files
with
222 additions
and
82 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as needle from 'needle'; | ||
import { OutgoingHttpHeaders } from 'http'; | ||
import { NeedleHttpVerbs } from 'needle'; | ||
import { makeRequest } from '../request/index'; | ||
import { getAuthHeader } from '../api-token'; | ||
import config from '../config'; | ||
import { Payload } from '../request/types'; | ||
|
||
interface RequestInfo { | ||
method: NeedleHttpVerbs; | ||
path: string; | ||
body: any; | ||
headers?: OutgoingHttpHeaders; | ||
qs?: {}; | ||
json?: boolean; | ||
timeout?: number; | ||
family?: number; | ||
} | ||
|
||
export async function snykHttpClient( | ||
requestInfo: RequestInfo, | ||
): Promise<{ | ||
res: needle.NeedleResponse; | ||
body: any; | ||
}> { | ||
let { path } = requestInfo; | ||
if (!path.startsWith('/')) path = `/${path}`; | ||
|
||
const payload: Payload = { | ||
...requestInfo, | ||
url: `${config.API_REST_URL}${path}`, | ||
headers: { | ||
...requestInfo.headers, | ||
Authorization: getAuthHeader(), | ||
}, | ||
}; | ||
|
||
return makeRequest(payload); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.