-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathstorageService.ts
More file actions
37 lines (29 loc) · 1.08 KB
/
storageService.ts
File metadata and controls
37 lines (29 loc) · 1.08 KB
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
import IConfigFetcher from "../interfaces/configFetcherInterface";
import ILogSink from "../interfaces/logSinkInterface";
import { Log } from "../types";
class StorageService {
configFetcher ?: IConfigFetcher|null = null;
logSink ?: ILogSink|null = null;
constructor(configFetcher ?: IConfigFetcher, logSink ?: ILogSink) {
this.configFetcher = configFetcher;
this.logSink = logSink;
}
// TODO: This should be set when starting the mock server
setConfigFetcher = (configFetcher: IConfigFetcher) => {
this.configFetcher = configFetcher;
}
setLogSink(logSink: ILogSink) {
this.logSink = logSink;
}
getMockSelectorMap = async (kwargs ?: any): Promise<any> => {
return this.configFetcher?.getMockSelectorMap(kwargs);
};
getMock = async (id: string, kwargs?: any): Promise<any> => {
return this.configFetcher?.getMock(id, kwargs);
}
storeLog = async (log: Log): Promise<void> => {
await this.logSink?.store(log);
}
}
const storageService = new StorageService();
export default storageService;