UNPKG

1.21 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const config_1 = require("./config");
4const utils_1 = require("../lib/utils");
5class Store {
6 constructor(deps) {
7 this.config = deps(config_1.default);
8 const Store = utils_1.loadModuleOfType('store', this.config.store);
9 this.store = new Store(Object.assign({
10 path: this.config.storePath
11 }, this.config.storeConfig), {});
12 }
13 getPluginStore(name) {
14 if (!name.match(/^[A-Za-z0-9_\-~.]+$/)) {
15 throw new Error('"' + name + '" includes forbidden characters.');
16 }
17 return {
18 get: (key) => {
19 return this.store.get(name + key);
20 },
21 put: (key, value) => {
22 return this.store.put(name + key, value);
23 },
24 del: (key) => {
25 return this.store.del(name + key);
26 }
27 };
28 }
29 async get(key) {
30 return this.store.get(key);
31 }
32 async put(key, value) {
33 return this.store.put(key, value);
34 }
35 async del(key) {
36 return this.store.del(key);
37 }
38}
39exports.default = Store;
40//# sourceMappingURL=store.js.map
\No newline at end of file