clone data for demo/dev env
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
export const cloudIngestUrl = process.env.CLOUD_INGEST_URL as string
|
export const cloudIngestUrl = process.env.CLOUD_INGEST_URL as string
|
||||||
|
export const demoCloudIngestUrl = process.env.DEMO_CLOUD_INGEST_URL as string
|
||||||
|
|
||||||
export function postCloudIngest(body: unknown): Promise<Response> {
|
export function postCloudIngest(body: unknown): Promise<Response> {
|
||||||
return fetch(cloudIngestUrl, {
|
return fetch(cloudIngestUrl, {
|
||||||
@@ -10,3 +11,14 @@ export function postCloudIngest(body: unknown): Promise<Response> {
|
|||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function postDemoCloudIngest(body: unknown): Promise<Response> {
|
||||||
|
return fetch(demoCloudIngestUrl, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
'x-api-key': process.env.CLOUD_INGEST_API_KEY as string,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { postCloudIngest } from '../cloud-ingest.js'
|
import { postCloudIngest, postDemoCloudIngest } from '../cloud-ingest.js'
|
||||||
import { log } from '../helpers/log.js'
|
import { log } from '../helpers/log.js'
|
||||||
import type { TopicHandler } from '../types.js'
|
import type { TopicHandler } from '../types.js'
|
||||||
|
|
||||||
@@ -97,6 +97,9 @@ async function postMetrics(metrics: Edge5ModbusV3Metric[]): Promise<void> {
|
|||||||
const text = await response.text()
|
const text = await response.text()
|
||||||
throw new Error(text || `${response.status} ${response.statusText}`)
|
throw new Error(text || `${response.status} ${response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void postDemoCloudIngest(metric); // для демо-системы
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = error instanceof Error ? error.message : String(error)
|
const message = error instanceof Error ? error.message : String(error)
|
||||||
errors.push(new Error(`${metric.tag}: ${message}`))
|
errors.push(new Error(`${metric.tag}: ${message}`))
|
||||||
|
|||||||
Reference in New Issue
Block a user