correction after review

This commit is contained in:
Первов Артем
2026-06-19 08:17:35 +03:00
parent 7cf4aacd11
commit 10dbdb2120
2 changed files with 7 additions and 18 deletions

View File

@@ -3,10 +3,9 @@
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "node --env-file-if-exists=.env ./node_modules/tsx/dist/cli.mjs watch src/index.ts", "dev": "tsx watch --env-file=.env src/index.ts",
"start": "node --env-file-if-exists=.env ./node_modules/tsx/dist/cli.mjs src/index.ts",
"build": "tsc", "build": "tsc",
"typecheck": "tsc --noEmit" "start": "node --env-file=.env dist/index.js"
}, },
"dependencies": { "dependencies": {
"@types/node": "^25.9.1", "@types/node": "^25.9.1",

View File

@@ -1,25 +1,15 @@
const DEFAULT_CLOUD_INGEST_URL = 'http://localhost:3100/ingest' const DEFAULT_CLOUD_INGEST_URL = 'http://localhost:3101/ingest'
export const cloudIngestUrl = export const cloudIngestUrl =
process.env.CLOUD_INGEST_URL ?? DEFAULT_CLOUD_INGEST_URL 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> { export function postCloudIngest(body: unknown): Promise<Response> {
return fetch(cloudIngestUrl, { return fetch(cloudIngestUrl, {
method: 'POST', method: 'POST',
headers: getHeaders(), headers: {
'content-type': 'application/json',
'x-api-key': process.env.CLOUD_INGEST_API_KEY as string,
},
body: JSON.stringify(body), body: JSON.stringify(body),
}) })
} }