This commit is contained in:
2026-07-05 16:09:32 +05:00
parent 5d18bb7965
commit 3841faa810
9 changed files with 14 additions and 8 deletions

View File

@@ -10,9 +10,7 @@ COPY src ./src
RUN npm run build && npm prune --omit=dev
# app/public/index.html has content for video preview
# TODO move all static files (html, mappers) to a separate folder "assets"
COPY public ./public
COPY assets ./assets
ENV NODE_ENV=production
CMD ["node", "dist/index.js"]

View File

@@ -1,3 +1,6 @@
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { postCloudIngest } from '../cloud-ingest.js'
import { log } from '../helpers/log.js'
import { createMetricMapper, type MappedMetric } from '../mapping.js'
@@ -5,8 +8,13 @@ import type { TopicHandler } from '../types.js'
const REGISTER_COUNT = 125
const defaultMappingFile = join(
dirname(fileURLToPath(import.meta.url)),
'../../assets/edge5-modbus.json',
)
const mapper = createMetricMapper({
filePath: process.env.EDGE5_MODBUS_V2_MAPPING_FILE as string,
filePath: process.env.EDGE5_MODBUS_V2_MAPPING_FILE ?? defaultMappingFile,
})
function parseValues(payload: Buffer): number[] {

View File

@@ -6,8 +6,8 @@ import { fileURLToPath } from 'node:url'
import { log } from '../helpers/log.js'
const httpPort = Number(process.env.HTTP_PORT)
const publicDir = join(dirname(fileURLToPath(import.meta.url)), '../../public')
const indexPath = join(publicDir, 'index.html')
const assetsDir = join(dirname(fileURLToPath(import.meta.url)), '../../assets')
const indexPath = join(assetsDir, 'index.html')
createServer(async (req, res) => {
const path = req.url?.split('?')[0]

View File

@@ -19,7 +19,7 @@ export type MetricMapper = {
type MetricMapperOptions = {
// filePath contract:
// - built-in mappings are passed as URL via new URL('../mappings/*.json', import.meta.url);
// - built-in mappings live in app/assets/*.json (resolved relative to dist/ at runtime);
// - env overrides are expected as absolute paths inside the runtime container.
filePath: string | URL
}