From 93d87ada1c4cd4bdfa215458add48dcc3d2de4c8 Mon Sep 17 00:00:00 2001 From: Thomas van Dam Date: Tue, 18 Jun 2024 14:01:21 +0200 Subject: [PATCH] chore(vm): move some magic strings to constants --- libs/vm/src/data-request-vm-adapter.ts | 3 ++- libs/vm/src/index.ts | 1 + libs/vm/src/tally-vm-adapter.ts | 3 ++- libs/vm/src/types/vm-modes.ts | 3 +++ 4 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 libs/vm/src/types/vm-modes.ts diff --git a/libs/vm/src/data-request-vm-adapter.ts b/libs/vm/src/data-request-vm-adapter.ts index bda3ecf..163957b 100644 --- a/libs/vm/src/data-request-vm-adapter.ts +++ b/libs/vm/src/data-request-vm-adapter.ts @@ -1,6 +1,7 @@ import type { HttpFetchAction } from './types/vm-actions.js'; import { HttpFetchResponse } from './types/vm-actions.js'; import type { VmAdapter } from './types/vm-adapter.js'; +import { VM_MODE_ENV_KEY, VM_MODE_DR } from "./types/vm-modes.js"; import fetch from 'node-fetch'; import { PromiseStatus } from './types/vm-promise.js'; import { VmCallData } from './vm.js'; @@ -13,7 +14,7 @@ export default class DataRequestVmAdapter implements VmAdapter { ...input, envs: { ...input.envs, - VM_MODE: 'dr', + [VM_MODE_ENV_KEY]: VM_MODE_DR, }, }; } diff --git a/libs/vm/src/index.ts b/libs/vm/src/index.ts index 20f2e07..be53982 100644 --- a/libs/vm/src/index.ts +++ b/libs/vm/src/index.ts @@ -7,6 +7,7 @@ import { parse, format } from "node:path"; import { HostToWorker } from "./worker-host-communication.js"; import { createProcessId } from "./services/create-process-id.js"; +export * from "./types/vm-modes.js"; export { default as TallyVmAdapter } from './tally-vm-adapter.js'; export { default as DataRequestVmAdapter } from './data-request-vm-adapter.js'; diff --git a/libs/vm/src/tally-vm-adapter.ts b/libs/vm/src/tally-vm-adapter.ts index 08a602d..a033383 100644 --- a/libs/vm/src/tally-vm-adapter.ts +++ b/libs/vm/src/tally-vm-adapter.ts @@ -2,6 +2,7 @@ import type { HttpFetchAction } from './types/vm-actions'; import { HttpFetchResponse } from './types/vm-actions.js'; import type { VmAdapter } from './types/vm-adapter'; import { PromiseStatus } from './types/vm-promise.js'; +import { VM_MODE_ENV_KEY, VM_MODE_TALLY } from "./types/vm-modes.js"; import type { VmCallData } from './vm'; export default class TallyVmAdapter implements VmAdapter { @@ -12,7 +13,7 @@ export default class TallyVmAdapter implements VmAdapter { ...input, envs: { ...input.envs, - VM_MODE: 'tally' + [VM_MODE_ENV_KEY]: VM_MODE_TALLY, } }; } diff --git a/libs/vm/src/types/vm-modes.ts b/libs/vm/src/types/vm-modes.ts new file mode 100644 index 0000000..a0acf4d --- /dev/null +++ b/libs/vm/src/types/vm-modes.ts @@ -0,0 +1,3 @@ +export const VM_MODE_ENV_KEY = "VM_MODE"; +export const VM_MODE_TALLY = "tally"; +export const VM_MODE_DR = "dr";