1 import { v4 as uuidv4 } from "uuid"
2 import os from "os"
3 import { join } from "path"
4
5 export class InMemoryConfigStore {
6 config = {}
7 path = join(os.tmpdir(), `medusa`)
8
9 constructor() {
10 this.config = this.createBaseConfig()
11 }
12
13 createBaseConfig() {
14 return {
15 "telemetry.enabled": true,
16 "telemetry.machine_id": `not-a-machine-id-${uuidv4()}`,
17 }
18 }
19
20 get(key) {
21 return this.config[key]
22 }
23
24 set(key, value) {
25 this.config[key] = value
26 }
27
28 all() {
29 return this.config
30 }
31
32 size() {
33 return Object.keys(this.config).length
34 }
35
36 has(key) {
37 return !!this.config[key]
38 }
39
40 del(key) {
41 delete this.config[key]
42 }
43
44 clear() {
45 this.config = this.createBaseConfig()
46 }
47 }