remove redundant parse
This commit is contained in:
25
app/src/cloud-ingest.ts
Normal file
25
app/src/cloud-ingest.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
const DEFAULT_CLOUD_INGEST_URL = 'http://localhost:3100/ingest'
|
||||
|
||||
export const cloudIngestUrl =
|
||||
process.env.CLOUD_INGEST_URL ?? DEFAULT_CLOUD_INGEST_URL
|
||||
|
||||
function getHeaders(): Record<string, string> {
|
||||
const headers: Record<string, string> = {
|
||||
'content-type': 'application/json',
|
||||
}
|
||||
|
||||
const apiKey = process.env.CLOUD_INGEST_API_KEY?.trim()
|
||||
if (apiKey) {
|
||||
headers['x-api-key'] = apiKey
|
||||
}
|
||||
|
||||
return headers
|
||||
}
|
||||
|
||||
export function postCloudIngest(body: unknown): Promise<Response> {
|
||||
return fetch(cloudIngestUrl, {
|
||||
method: 'POST',
|
||||
headers: getHeaders(),
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user