-
Notifications
You must be signed in to change notification settings - Fork 0
/
stateless.patch
71 lines (66 loc) · 2.45 KB
/
stateless.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
diff --git a/api/config/app.ts b/api/config/app.ts
index 30727220..a40c8882 100644
--- a/api/config/app.ts
+++ b/api/config/app.ts
@@ -16,6 +16,11 @@ export const backupsDir: string =
export const nvmBackupsDir: string = joinPath(backupsDir, 'nvm')
export const storeBackupsDir: string = joinPath(backupsDir, 'store')
+export const settingsFile: string = process.env.SETTINGS_FILE || joinPath(storeDir, 'settings.json')
+export const scenesFile: string = process.env.SCENES_FILE || joinPath(storeDir, 'scenes.json')
+export const nodesFile: string = process.env.NODES_FILE || joinPath(storeDir, 'nodes.json')
+export const usersFile: string = process.env.USERS_FILE || joinPath(storeDir, 'users.json')
+
export const defaultUser: string = 'admin'
export const defaultPsw: string = 'zwave'
// lgtm [js/hardcoded-credentials]
diff --git a/api/config/store.ts b/api/config/store.ts
index eb6ae249..b90cee4d 100644
--- a/api/config/store.ts
+++ b/api/config/store.ts
@@ -1,5 +1,6 @@
// config/store.js
+import { settingsFile, scenesFile, nodesFile, usersFile } from '../config/app';
import { GatewayConfig } from '../lib/Gateway'
import { MqttConfig } from '../lib/MqttClient'
import { ZwaveConfig, deviceConfigPriorityDir } from '../lib/ZwaveClient'
@@ -25,7 +26,7 @@ export interface Settings {
const store: Record<StoreKeys, StoreFile> = {
settings: {
- file: 'settings.json',
+ file: settingsFile,
default: {
zwave: {
deviceConfigPriorityDir,
@@ -33,9 +34,9 @@ const store: Record<StoreKeys, StoreFile> = {
},
},
},
- scenes: { file: 'scenes.json', default: [] },
- nodes: { file: 'nodes.json', default: [] },
- users: { file: 'users.json', default: [] },
+ scenes : { file: scenesFile, default: [] },
+ nodes : { file: nodesFile, default: [] },
+ users : { file: usersFile, default: [] }
}
export default store
diff --git a/api/lib/jsonStore.ts b/api/lib/jsonStore.ts
index 92100a55..266ffefd 100644
--- a/api/lib/jsonStore.ts
+++ b/api/lib/jsonStore.ts
@@ -94,7 +94,7 @@ export class StorageHelper {
let err: { code: string } | undefined
let data: any
try {
- data = await readFile(utils.joinPath(storeDir, config.file))
+ data = await readFile(config.file)
} catch (error) {
err = error
}
@@ -127,7 +127,7 @@ export class StorageHelper {
}
async put(model: StoreFile, data: any) {
- await writeFile(utils.joinPath(storeDir, model.file), data)
+ await writeFile(model.file, data)
this._store[model.file] = data
return data
}