@ask-ell/back-end 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ask-ell/back-end",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"@ask-ell/ask": "^0.0.4",
|
|
11
11
|
"keyv": "^5.6.0",
|
|
12
12
|
"@keyv/postgres": "^2.2.3",
|
|
13
|
-
"@keyv/sqlite": "^4.0.8"
|
|
13
|
+
"@keyv/sqlite": "^4.0.8",
|
|
14
|
+
"@nestjs/common": "^11.1.7"
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ILogger } from "@ask-ell/core";
|
|
2
1
|
import { KeyvStoreAdapter } from "keyv";
|
|
3
2
|
type CreateKeyvStoreAdapterOptions = {
|
|
4
3
|
postgresUri: string;
|
|
@@ -6,7 +5,6 @@ type CreateKeyvStoreAdapterOptions = {
|
|
|
6
5
|
};
|
|
7
6
|
export declare class KeyvStoreAdapterFactory {
|
|
8
7
|
private logger;
|
|
9
|
-
constructor(logger: ILogger);
|
|
10
8
|
create(options: CreateKeyvStoreAdapterOptions): KeyvStoreAdapter;
|
|
11
9
|
private getKeyvStoreAdapter;
|
|
12
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyv.store.adapter.factory.d.ts","sourceRoot":"","sources":["../../../../packages/back-end/src/keyv.store.adapter.factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keyv.store.adapter.factory.d.ts","sourceRoot":"","sources":["../../../../packages/back-end/src/keyv.store.adapter.factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAQxC,KAAK,6BAA6B,GAAG;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,MAAM,CAAC;CAChC,CAAA;AAED,qBACa,uBAAuB;IAChC,OAAO,CAAC,MAAM,CAA0D;IAExE,MAAM,CAAC,OAAO,EAAE,6BAA6B,GAAG,gBAAgB;IAMhE,OAAO,CAAC,mBAAmB;CAS9B"}
|
|
@@ -2,27 +2,41 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.KeyvStoreAdapterFactory = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
5
6
|
const sqlite_1 = tslib_1.__importDefault(require("@keyv/sqlite"));
|
|
6
7
|
const postgres_1 = tslib_1.__importDefault(require("@keyv/postgres"));
|
|
8
|
+
const nest_1 = require("@ask-ell/nest");
|
|
7
9
|
const ask_1 = require("@ask-ell/ask");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
(
|
|
21
|
-
return new sqlite_1.default(databaseRelativePath);
|
|
10
|
+
let KeyvStoreAdapterFactory = (() => {
|
|
11
|
+
let _classDecorators = [(0, common_1.Injectable)()];
|
|
12
|
+
let _classDescriptor;
|
|
13
|
+
let _classExtraInitializers = [];
|
|
14
|
+
let _classThis;
|
|
15
|
+
var KeyvStoreAdapterFactory = class {
|
|
16
|
+
static { _classThis = this; }
|
|
17
|
+
static {
|
|
18
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
19
|
+
tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
20
|
+
KeyvStoreAdapterFactory = _classThis = _classDescriptor.value;
|
|
21
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
22
|
+
tslib_1.__runInitializers(_classThis, _classExtraInitializers);
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
logger = nest_1.NestLogger.fromClass(KeyvStoreAdapterFactory);
|
|
25
|
+
create(options) {
|
|
26
|
+
const adapter = this.getKeyvStoreAdapter(options);
|
|
27
|
+
this.logger.log(`Connected to database with adapter "${adapter.constructor.name}"`);
|
|
28
|
+
return adapter;
|
|
29
|
+
}
|
|
30
|
+
getKeyvStoreAdapter({ postgresUri, databaseRelativePath }) {
|
|
31
|
+
if (!postgresUri) {
|
|
32
|
+
(0, ask_1.createTmpFolder)(this.logger);
|
|
33
|
+
return new sqlite_1.default(databaseRelativePath);
|
|
34
|
+
}
|
|
35
|
+
return new postgres_1.default({
|
|
36
|
+
uri: postgresUri,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return KeyvStoreAdapterFactory = _classThis;
|
|
41
|
+
})();
|
|
28
42
|
exports.KeyvStoreAdapterFactory = KeyvStoreAdapterFactory;
|