assets
This commit is contained in:
@@ -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"]
|
||||
|
||||
@@ -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[] {
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user