@tsed/adapters 7.0.0-beta.2 → 7.0.0-beta.20
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/lib/cjs/adapters/FileSyncAdapter.js +6 -6
- package/lib/cjs/adapters/FileSyncAdapter.js.map +1 -1
- package/lib/cjs/adapters/LowDbAdapter.js +8 -6
- package/lib/cjs/adapters/LowDbAdapter.js.map +1 -1
- package/lib/cjs/adapters/MemoryAdapter.js +6 -6
- package/lib/cjs/adapters/MemoryAdapter.js.map +1 -1
- package/lib/cjs/domain/Adapter.js +11 -6
- package/lib/cjs/domain/Adapter.js.map +1 -1
- package/lib/cjs/index.js +11 -8
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/services/Adapters.js +7 -5
- package/lib/cjs/services/Adapters.js.map +1 -1
- package/lib/esm/adapters/FileSyncAdapter.js +1 -1
- package/lib/esm/adapters/LowDbAdapter.js +8 -6
- package/lib/esm/adapters/LowDbAdapter.js.map +1 -1
- package/lib/esm/adapters/MemoryAdapter.js +1 -1
- package/lib/esm/decorators/injectAdapter.js +1 -1
- package/lib/esm/domain/Adapter.js +5 -0
- package/lib/esm/domain/Adapter.js.map +1 -1
- package/lib/esm/index.js +11 -8
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/package.json +3 -0
- package/lib/esm/services/Adapters.js +3 -1
- package/lib/esm/services/Adapters.js.map +1 -1
- package/lib/types/adapters/LowDbAdapter.d.ts +6 -0
- package/lib/types/domain/Adapter.d.ts +13 -13
- package/lib/types/index.d.ts +5 -2
- package/package.json +26 -21
- package/readme.md +3 -60
- package/tsconfig.compile.esm.json +1 -12
- package/.nycrc +0 -26
|
@@ -5,8 +5,8 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const core_1 = require("@tsed/core");
|
|
6
6
|
const di_1 = require("@tsed/di");
|
|
7
7
|
const fs_extra_1 = require("fs-extra");
|
|
8
|
-
const lowdb_1 =
|
|
9
|
-
const FileSync_1 =
|
|
8
|
+
const lowdb_1 = tslib_1.__importDefault(require("lowdb"));
|
|
9
|
+
const FileSync_1 = tslib_1.__importDefault(require("lowdb/adapters/FileSync"));
|
|
10
10
|
const path_1 = require("path");
|
|
11
11
|
const LowDbAdapter_1 = require("./LowDbAdapter");
|
|
12
12
|
let FileSyncAdapter = class FileSyncAdapter extends LowDbAdapter_1.LowDbAdapter {
|
|
@@ -27,12 +27,12 @@ let FileSyncAdapter = class FileSyncAdapter extends LowDbAdapter_1.LowDbAdapter
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
FileSyncAdapter =
|
|
30
|
+
FileSyncAdapter = tslib_1.__decorate([
|
|
31
31
|
(0, di_1.Injectable)(),
|
|
32
32
|
(0, di_1.Scope)(di_1.ProviderScope.INSTANCE),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
tslib_1.__param(0, di_1.Opts),
|
|
34
|
+
tslib_1.__param(1, (0, di_1.Configuration)()),
|
|
35
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
36
36
|
], FileSyncAdapter);
|
|
37
37
|
exports.FileSyncAdapter = FileSyncAdapter;
|
|
38
38
|
//# sourceMappingURL=FileSyncAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileSyncAdapter.js","sourceRoot":"","sources":["../../../src/adapters/FileSyncAdapter.ts"],"names":[],"mappings":";;;;AAAA,qCAAkC;AAClC,iCAA+E;AAC/E,uCAAuC;AACvC
|
|
1
|
+
{"version":3,"file":"FileSyncAdapter.js","sourceRoot":"","sources":["../../../src/adapters/FileSyncAdapter.ts"],"names":[],"mappings":";;;;AAAA,qCAAkC;AAClC,iCAA+E;AAC/E,uCAAuC;AACvC,0DAAwB;AACxB,+EAA+C;AAC/C,+BAA6B;AAE7B,iDAA0D;AAQ1D,IAAa,eAAe,GAA5B,MAAa,eAAwC,SAAQ,2BAAe;IAC1E,YAAkB,OAA0C,EAAmB,aAA4B;QACzG,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAE9B,IAAA,wBAAa,EAAC,IAAA,cAAO,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAExC,MAAM,IAAI,GAAG,IAAI,kBAAQ,CAAoB,IAAI,CAAC,UAAU,CAAC,CAAC;QAE9D,IAAI,CAAC,EAAE,GAAG,IAAA,eAAG,EAAC,IAAI,CAAC,CAAC;QACpB,IAAI,CAAC,EAAE;aACJ,QAAQ,CAAC;YACR,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,SAAS,EAAE,IAAA,aAAM,EAAC,IAAI,CAAC,KAAK,CAAC;YAC7B,UAAU,EAAE,EAAE;SACf,CAAC;aACD,KAAK,EAAE,CAAC;QAEX,IAAI,OAAO,CAAC,QAAQ,EAAE;YACpB,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;SACvB;IACH,CAAC;CACF,CAAA;AArBY,eAAe;IAF3B,IAAA,eAAU,GAAE;IACZ,IAAA,UAAK,EAAC,kBAAa,CAAC,QAAQ,CAAC;IAEf,mBAAA,SAAI,CAAA;IAA8C,mBAAA,IAAA,kBAAa,GAAE,CAAA;;GADnE,eAAe,CAqB3B;AArBY,0CAAe","sourcesContent":["import {nameOf} from \"@tsed/core\";\nimport {Configuration, Injectable, Opts, ProviderScope, Scope} from \"@tsed/di\";\nimport {ensureDirSync} from \"fs-extra\";\nimport low from \"lowdb\";\nimport FileSync from \"lowdb/adapters/FileSync\";\nimport {dirname} from \"path\";\nimport {AdapterConstructorOptions} from \"../domain/Adapter\";\nimport {AdapterModel, LowDbAdapter} from \"./LowDbAdapter\";\n\nexport interface FileSyncAdapterConstructorOptions extends AdapterConstructorOptions {\n readOnly: true;\n}\n\n@Injectable()\n@Scope(ProviderScope.INSTANCE)\nexport class FileSyncAdapter<T extends AdapterModel> extends LowDbAdapter<T> {\n constructor(@Opts options: FileSyncAdapterConstructorOptions, @Configuration() configuration: Configuration) {\n super(options, configuration);\n\n ensureDirSync(dirname(this.dbFilePath));\n\n const file = new FileSync<{collection: T[]}>(this.dbFilePath);\n\n this.db = low(file);\n this.db\n .defaults({\n collectionName: this.collectionName,\n modelName: nameOf(this.model),\n collection: []\n })\n .write();\n\n if (options.readOnly) {\n file.write = () => {};\n }\n }\n}\n"]}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LowDbAdapter = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const core_1 = require("@tsed/core");
|
|
6
|
+
const isMatch_1 = tslib_1.__importDefault(require("lodash/isMatch"));
|
|
6
7
|
const uuid_1 = require("uuid");
|
|
7
8
|
const Adapter_1 = require("../domain/Adapter");
|
|
8
9
|
class LowDbAdapter extends Adapter_1.Adapter {
|
|
10
|
+
db;
|
|
9
11
|
get collection() {
|
|
10
12
|
return this.db.get("collection");
|
|
11
13
|
}
|
|
@@ -36,7 +38,7 @@ class LowDbAdapter extends Adapter_1.Adapter {
|
|
|
36
38
|
return this.updateOne({ _id: id }, payload, expiresAt);
|
|
37
39
|
}
|
|
38
40
|
async updateOne(predicate, payload, expiresAt) {
|
|
39
|
-
let index = this.collection.findIndex(predicate).value();
|
|
41
|
+
let index = this.collection.findIndex((0, core_1.cleanObject)(predicate)).value();
|
|
40
42
|
if (index === -1) {
|
|
41
43
|
return;
|
|
42
44
|
}
|
|
@@ -51,7 +53,7 @@ class LowDbAdapter extends Adapter_1.Adapter {
|
|
|
51
53
|
return this.deserialize(item);
|
|
52
54
|
}
|
|
53
55
|
async findOne(predicate) {
|
|
54
|
-
const item = this.collection.find(predicate).value();
|
|
56
|
+
const item = this.collection.find((0, core_1.cleanObject)(predicate)).value();
|
|
55
57
|
return this.deserialize(item);
|
|
56
58
|
}
|
|
57
59
|
async findById(_id) {
|
|
@@ -59,12 +61,12 @@ class LowDbAdapter extends Adapter_1.Adapter {
|
|
|
59
61
|
}
|
|
60
62
|
async findAll(predicate = {}) {
|
|
61
63
|
return this.collection
|
|
62
|
-
.filter(predicate)
|
|
64
|
+
.filter((0, core_1.cleanObject)(predicate))
|
|
63
65
|
.value()
|
|
64
66
|
.map((item) => this.deserialize(item));
|
|
65
67
|
}
|
|
66
68
|
async deleteOne(predicate) {
|
|
67
|
-
const item = this.collection.find(predicate).value();
|
|
69
|
+
const item = this.collection.find((0, core_1.cleanObject)(predicate)).value();
|
|
68
70
|
if (item) {
|
|
69
71
|
this.collection.remove(({ _id }) => _id === item._id).write();
|
|
70
72
|
return this.deserialize(item);
|
|
@@ -77,7 +79,7 @@ class LowDbAdapter extends Adapter_1.Adapter {
|
|
|
77
79
|
let removedItems = [];
|
|
78
80
|
await this.collection
|
|
79
81
|
.remove((item) => {
|
|
80
|
-
if ((0, isMatch_1.default)(item, predicate)) {
|
|
82
|
+
if ((0, isMatch_1.default)(item, (0, core_1.cleanObject)(predicate))) {
|
|
81
83
|
removedItems.push(this.deserialize(item));
|
|
82
84
|
return true;
|
|
83
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LowDbAdapter.js","sourceRoot":"","sources":["../../../src/adapters/LowDbAdapter.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"LowDbAdapter.js","sourceRoot":"","sources":["../../../src/adapters/LowDbAdapter.ts"],"names":[],"mappings":";;;;AAAA,qCAAuC;AACvC,qEAAqC;AAErC,+BAAgC;AAChC,+CAA0C;AAS1C,MAAa,YAAqC,SAAQ,iBAAU;IACxD,EAAE,CAAmC;IAE/C,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACnC,CAAC;IAED,IAAc,UAAU;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAA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AAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3C,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,SAA2B;QAChD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAA,kBAAW,EAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;QAElE,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAC,GAAG,EAAC,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;YAE5D,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SAC/B;IACH,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,GAAW;QACjC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAC,GAAG,EAAQ,CAAC,CAAC;IACtC,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,SAAqB;QAC3C,IAAI,YAAY,GAAQ,EAAE,CAAC;QAE3B,MAAM,IAAI,CAAC,UAAU;aAClB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACf,IAAI,IAAA,iBAAO,EAAC,IAAI,EAAE,IAAA,kBAAW,EAAC,SAAS,CAAC,CAAC,EAAE;gBACzC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC1C,OAAO,IAAI,CAAC;aACb;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;aACD,KAAK,EAAE,CAAC;QAEX,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AAhHD,oCAgHC","sourcesContent":["import {cleanObject} from \"@tsed/core\";\nimport isMatch from \"lodash/isMatch\";\nimport low from \"lowdb\";\nimport {v4 as uuid} from \"uuid\";\nimport {Adapter} from \"../domain/Adapter\";\n\nexport interface AdapterModel {\n _id: string;\n expires_at?: Date;\n\n [key: string]: any;\n}\n\nexport class LowDbAdapter<T extends AdapterModel> extends Adapter<T> {\n protected db: low.LowdbSync<{collection: T[]}>;\n\n get collection() {\n return this.db.get(\"collection\");\n }\n\n protected get dbFilePath() {\n const lowdbDir = this.configuration.get(\"adapters.lowdbDir\", \".db\");\n return `${lowdbDir}/${this.collectionName}.json`;\n }\n\n public async create(payload: Partial<T>, expiresAt?: Date): Promise<T> {\n if (expiresAt) {\n payload.expires_at = expiresAt;\n }\n\n payload._id = uuid();\n\n await this.validate(payload as T);\n\n await this.collection.push(payload as T).write();\n\n return this.deserialize(payload);\n }\n\n public async upsert(id: string, payload: T, expiresAt?: Date): Promise<T> {\n let item = await this.findById(id);\n\n if (!item) {\n payload = {...payload, _id: id || uuid(), expires_at: expiresAt};\n\n await this.validate(payload as T);\n await this.collection.push(payload as T).write();\n\n return this.deserialize(payload);\n }\n\n return (await this.update(id, payload, expiresAt)) as T;\n }\n\n public async update(id: string, payload: T, expiresAt?: Date): Promise<T | undefined> {\n return this.updateOne({_id: id}, payload, expiresAt);\n }\n\n public async updateOne(predicate: Partial<T & any>, payload: T, expiresAt?: Date): Promise<T | undefined> {\n let index = this.collection.findIndex(cleanObject(predicate)).value();\n\n if (index === -1) {\n return;\n }\n\n let item = this.collection.get(index).value();\n\n item = {\n _id: item._id,\n expires_at: expiresAt || item.expires_at,\n ...this.updateInstance(item, payload)\n };\n\n await this.validate(item as T);\n await this.collection.set(index, item).write();\n\n return this.deserialize(item);\n }\n\n async findOne(predicate: Partial<T & any>): Promise<T | undefined> {\n const item = this.collection.find(cleanObject(predicate)).value();\n\n return this.deserialize(item);\n }\n\n async findById(_id: string): Promise<T | undefined> {\n return this.findOne({_id});\n }\n\n public async findAll(predicate: Partial<T & any> = {}): Promise<T[]> {\n return this.collection\n .filter(cleanObject(predicate))\n .value()\n .map((item) => this.deserialize(item));\n }\n\n public async deleteOne(predicate: Partial<T & any>): Promise<T | undefined> {\n const item = this.collection.find(cleanObject(predicate)).value();\n\n if (item) {\n this.collection.remove(({_id}) => _id === item._id).write();\n\n return this.deserialize(item);\n }\n }\n\n public async deleteById(_id: string): Promise<T | undefined> {\n return this.deleteOne({_id} as any);\n }\n\n public async deleteMany(predicate: Partial<T>): Promise<T[]> {\n let removedItems: T[] = [];\n\n await this.collection\n .remove((item) => {\n if (isMatch(item, cleanObject(predicate))) {\n removedItems.push(this.deserialize(item));\n return true;\n }\n return false;\n })\n .write();\n\n return removedItems;\n }\n}\n"]}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MemoryAdapter = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const di_1 = require("@tsed/di");
|
|
6
|
-
const lowdb_1 =
|
|
7
|
-
const Memory_1 =
|
|
6
|
+
const lowdb_1 = tslib_1.__importDefault(require("lowdb"));
|
|
7
|
+
const Memory_1 = tslib_1.__importDefault(require("lowdb/adapters/Memory"));
|
|
8
8
|
const LowDbAdapter_1 = require("./LowDbAdapter");
|
|
9
9
|
let MemoryAdapter = class MemoryAdapter extends LowDbAdapter_1.LowDbAdapter {
|
|
10
10
|
constructor(options, configuration) {
|
|
@@ -17,12 +17,12 @@ let MemoryAdapter = class MemoryAdapter extends LowDbAdapter_1.LowDbAdapter {
|
|
|
17
17
|
.write();
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
MemoryAdapter =
|
|
20
|
+
MemoryAdapter = tslib_1.__decorate([
|
|
21
21
|
(0, di_1.Injectable)(),
|
|
22
22
|
(0, di_1.Scope)(di_1.ProviderScope.INSTANCE),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
tslib_1.__param(0, di_1.Opts),
|
|
24
|
+
tslib_1.__param(1, (0, di_1.Configuration)()),
|
|
25
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
26
26
|
], MemoryAdapter);
|
|
27
27
|
exports.MemoryAdapter = MemoryAdapter;
|
|
28
28
|
//# sourceMappingURL=MemoryAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryAdapter.js","sourceRoot":"","sources":["../../../src/adapters/MemoryAdapter.ts"],"names":[],"mappings":";;;;AAAA,iCAA+E;AAC/E
|
|
1
|
+
{"version":3,"file":"MemoryAdapter.js","sourceRoot":"","sources":["../../../src/adapters/MemoryAdapter.ts"],"names":[],"mappings":";;;;AAAA,iCAA+E;AAC/E,0DAAwB;AACxB,2EAA2C;AAC3C,iDAA0D;AAI1D,IAAa,aAAa,GAA1B,MAAa,aAAsC,SAAQ,2BAAe;IACxE,YAAkB,OAAY,EAAmB,aAA4B;QAC3E,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAE9B,IAAI,CAAC,EAAE,GAAG,IAAA,eAAG,EAAC,IAAI,gBAAM,CAAoB,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAC9D,IAAI,CAAC,EAAE;aACJ,QAAQ,CAAC;YACR,UAAU,EAAE,EAAE;SACf,CAAC;aACD,KAAK,EAAE,CAAC;IACb,CAAC;CACF,CAAA;AAXY,aAAa;IAFzB,IAAA,eAAU,GAAE;IACZ,IAAA,UAAK,EAAC,kBAAa,CAAC,QAAQ,CAAC;IAEf,mBAAA,SAAI,CAAA;IAAgB,mBAAA,IAAA,kBAAa,GAAE,CAAA;;GADrC,aAAa,CAWzB;AAXY,sCAAa","sourcesContent":["import {Configuration, Injectable, Opts, ProviderScope, Scope} from \"@tsed/di\";\nimport low from \"lowdb\";\nimport Memory from \"lowdb/adapters/Memory\";\nimport {AdapterModel, LowDbAdapter} from \"./LowDbAdapter\";\n\n@Injectable()\n@Scope(ProviderScope.INSTANCE)\nexport class MemoryAdapter<T extends AdapterModel> extends LowDbAdapter<T> {\n constructor(@Opts options: any, @Configuration() configuration: Configuration) {\n super(options, configuration);\n\n this.db = low(new Memory<{collection: T[]}>(this.dbFilePath));\n this.db\n .defaults({\n collection: []\n })\n .write();\n }\n}\n"]}
|
|
@@ -29,6 +29,11 @@ function pluralize(name) {
|
|
|
29
29
|
return name.slice(-1) === "y" ? `${name.slice(0, name.length - 1)}ies` : name + "s";
|
|
30
30
|
}
|
|
31
31
|
let Adapter = class Adapter {
|
|
32
|
+
configuration;
|
|
33
|
+
model;
|
|
34
|
+
collectionName;
|
|
35
|
+
indexes;
|
|
36
|
+
ajvService;
|
|
32
37
|
constructor(options, configuration) {
|
|
33
38
|
this.configuration = configuration;
|
|
34
39
|
this.model = options.model;
|
|
@@ -69,14 +74,14 @@ let Adapter = class Adapter {
|
|
|
69
74
|
});
|
|
70
75
|
}
|
|
71
76
|
};
|
|
72
|
-
|
|
77
|
+
tslib_1.__decorate([
|
|
73
78
|
(0, di_1.Inject)(),
|
|
74
|
-
|
|
79
|
+
tslib_1.__metadata("design:type", ajv_1.AjvService)
|
|
75
80
|
], Adapter.prototype, "ajvService", void 0);
|
|
76
|
-
Adapter =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
Adapter = tslib_1.__decorate([
|
|
82
|
+
tslib_1.__param(0, di_1.Opts),
|
|
83
|
+
tslib_1.__param(1, (0, di_1.Configuration)()),
|
|
84
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
80
85
|
], Adapter);
|
|
81
86
|
exports.Adapter = Adapter;
|
|
82
87
|
//# sourceMappingURL=Adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Adapter.js","sourceRoot":"","sources":["../../../src/domain/Adapter.ts"],"names":[],"mappings":";;;;AAAA,mCAAqC;AACrC,qCAA2D;AAC3D,iCAAqD;AACrD,mDAAyD;AACzD,yCAAiD;AAUjD,SAAS,UAAU,CAAC,KAAU;IAC5B,OAAO,CAAC,GAAG,IAAA,4BAAmB,EAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;SAC7C,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,M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uBAAS,EAAC,GAAG,EAAE;YACpB,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAtEC;IADC,IAAA,WAAM,GAAE;sCACW,gBAAU;2CAAC;AANX,OAAO;IAQd,mBAAA,SAAI,CAAA;IAAsC,mBAAA,IAAA,kBAAa,GAAE,CAAA;;GARlD,OAAO,CA4E5B;AA5EqB,0BAAO","sourcesContent":["import {AjvService} from \"@tsed/ajv\";\nimport {isArray, isObject, nameOf, Type} from \"@tsed/core\";\nimport {Configuration, Inject, Opts} from \"@tsed/di\";\nimport {deserialize, serialize} from \"@tsed/json-mapper\";\nimport {getPropertiesStores} from \"@tsed/schema\";\n\nexport interface AdapterConstructorOptions<T = any> {\n model: Type<T> | Object;\n collectionName?: string;\n indexes?: {\n [propertyKey: string]: Record<string, any>;\n };\n}\n\nfunction getIndexes(model: any) {\n return [...getPropertiesStores(model).entries()]\n .filter(([, entity]) => entity.store.has(\"adapter:indexed\"))\n .map(([propertyKey, entity]) => {\n return {\n propertyKey: String(propertyKey),\n options: entity.store.get(\"adapter:indexed\")\n };\n });\n}\n\nfunction mapIndexes(indexes: {[p: string]: Record<string, any>} | {propertyKey: string; options: any}[]) {\n return Object.entries(indexes).reduce((indexes: any[], [propertyKey, options]) => {\n return indexes.concat({\n propertyKey,\n options\n });\n }, []);\n}\n\nfunction pluralize(name: string) {\n return name.slice(-1) === \"y\" ? `${name.slice(0, name.length - 1)}ies` : name + \"s\";\n}\n\nexport abstract class Adapter<Model = any> {\n readonly model: Type<Model> | Object;\n readonly collectionName: string;\n readonly indexes: {propertyKey: string; options: any}[];\n\n @Inject()\n private ajvService: AjvService;\n\n constructor(@Opts options: AdapterConstructorOptions, @Configuration() protected configuration: Configuration) {\n this.model = options.model;\n this.collectionName = options.collectionName || pluralize(nameOf(options.model));\n\n let indexes = options.indexes || configuration.get(`adapters.${this.collectionName}.indexes`) || getIndexes(this.model);\n\n if (!isArray(indexes)) {\n indexes = mapIndexes(indexes);\n }\n\n this.indexes = indexes;\n }\n\n async validate(value: Model): Promise<void> {\n if (this.getModel()) {\n await this.ajvService.validate(this.serialize(value), {\n type: this.model\n });\n }\n }\n\n abstract create(value: Partial<Omit<Model, \"_id\">>, expiresAt?: Date): Promise<Model>;\n\n abstract update(id: string, value: Model, expiresAt?: Date): Promise<Model | undefined>;\n\n abstract updateOne(predicate: Partial<Model>, value: Partial<Model>, expiresAt?: Date): Promise<Model | undefined>;\n\n abstract upsert(id: string, value: Model, expiresAt?: Date): Promise<Model>;\n\n abstract findOne(predicate: Partial<Model>): Promise<Model | undefined>;\n\n abstract findById(id: string): Promise<Model | undefined>;\n\n abstract findAll(predicate?: Partial<Model>): Promise<Model[]>;\n\n abstract deleteOne(predicate: Partial<Model>): Promise<Model | undefined>;\n\n abstract deleteMany(predicate: Partial<Model>): Promise<Model[]>;\n\n abstract deleteById(id: string): Promise<Model | undefined>;\n\n getModel() {\n return (this.model as unknown) !== Object ? this.model : undefined;\n }\n\n protected updateInstance(src: any, payload: any) {\n const item = Object.assign({\n ...this.serialize(src),\n ...this.serialize(payload)\n });\n\n item.expires_at = item.expires_at ? new Date(item.expires_at) : item.expires_at;\n\n return item;\n }\n\n protected deserialize(obj: any) {\n return deserialize(obj, {\n type: this.getModel(),\n useAlias: false\n });\n }\n\n protected serialize(obj: any) {\n return serialize(obj, {\n useAlias: false\n });\n }\n}\n"]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Automatically generated by barrelsby.
|
|
4
|
+
*/
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
tslib_1.__exportStar(require("./adapters/FileSyncAdapter"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./adapters/LowDbAdapter"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./adapters/MemoryAdapter"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./decorators/indexed"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./decorators/injectAdapter"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./domain/Adapter"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./domain/AdaptersSettings"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./services/Adapters"), exports);
|
|
12
15
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,qEAA2C;AAC3C,kEAAwC;AACxC,mEAAyC;AACzC,+DAAqC;AACrC,qEAA2C;AAC3C,2DAAiC;AACjC,oEAA0C;AAC1C,8DAAoC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./adapters/FileSyncAdapter\";\nexport * from \"./adapters/LowDbAdapter\";\nexport * from \"./adapters/MemoryAdapter\";\nexport * from \"./decorators/indexed\";\nexport * from \"./decorators/injectAdapter\";\nexport * from \"./domain/Adapter\";\nexport * from \"./domain/AdaptersSettings\";\nexport * from \"./services/Adapters\";\n"]}
|
|
@@ -6,6 +6,8 @@ const core_1 = require("@tsed/core");
|
|
|
6
6
|
const di_1 = require("@tsed/di");
|
|
7
7
|
const MemoryAdapter_1 = require("../adapters/MemoryAdapter");
|
|
8
8
|
let Adapters = class Adapters {
|
|
9
|
+
injector;
|
|
10
|
+
adapter;
|
|
9
11
|
invokeAdapter(options) {
|
|
10
12
|
const { adapter = this.adapter, ...props } = options;
|
|
11
13
|
const locals = options.locals || new Map();
|
|
@@ -13,15 +15,15 @@ let Adapters = class Adapters {
|
|
|
13
15
|
return this.injector.invoke(adapter, locals);
|
|
14
16
|
}
|
|
15
17
|
};
|
|
16
|
-
|
|
18
|
+
tslib_1.__decorate([
|
|
17
19
|
(0, di_1.Inject)(),
|
|
18
|
-
|
|
20
|
+
tslib_1.__metadata("design:type", di_1.InjectorService)
|
|
19
21
|
], Adapters.prototype, "injector", void 0);
|
|
20
|
-
|
|
22
|
+
tslib_1.__decorate([
|
|
21
23
|
(0, di_1.Constant)("adapters.Adapter", MemoryAdapter_1.MemoryAdapter),
|
|
22
|
-
|
|
24
|
+
tslib_1.__metadata("design:type", core_1.Type)
|
|
23
25
|
], Adapters.prototype, "adapter", void 0);
|
|
24
|
-
Adapters =
|
|
26
|
+
Adapters = tslib_1.__decorate([
|
|
25
27
|
(0, di_1.Injectable)()
|
|
26
28
|
], Adapters);
|
|
27
29
|
exports.Adapters = Adapters;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Adapters.js","sourceRoot":"","sources":["../../../src/services/Adapters.ts"],"names":[],"mappings":";;;;AAAA,qCAAgC;AAChC,iCAAyF;AACzF,6DAAwD;AAUxD,IAAa,QAAQ,GAArB,MAAa,QAAQ;
|
|
1
|
+
{"version":3,"file":"Adapters.js","sourceRoot":"","sources":["../../../src/services/Adapters.ts"],"names":[],"mappings":";;;;AAAA,qCAAgC;AAChC,iCAAyF;AACzF,6DAAwD;AAUxD,IAAa,QAAQ,GAArB,MAAa,QAAQ;IAEnB,QAAQ,CAAkB;IAGhB,OAAO,CAAgB;IAEjC,aAAa,CAAU,OAA6B;QAClD,MAAM,EAAC,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,KAAK,EAAC,GAAG,OAAO,CAAC;QACnD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QAC3C,MAAM,CAAC,GAAG,CAAC,qBAAgB,EAAE,KAAK,CAAC,CAAC;QAEpC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAa,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AAZC;IADC,IAAA,WAAM,GAAE;sCACC,oBAAe;0CAAC;AAG1B;IADC,IAAA,aAAQ,EAAC,kBAAkB,EAAE,6BAAa,CAAC;sCACzB,WAAI;yCAAU;AALtB,QAAQ;IADpB,IAAA,eAAU,GAAE;GACA,QAAQ,CAcpB;AAdY,4BAAQ","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Constant, DI_PARAM_OPTIONS, Inject, Injectable, InjectorService} from \"@tsed/di\";\nimport {MemoryAdapter} from \"../adapters/MemoryAdapter\";\nimport {Adapter, AdapterConstructorOptions} from \"../domain/Adapter\";\n\nexport interface AdapterInvokeOptions<T = any> extends AdapterConstructorOptions<T> {\n adapter?: Type<Adapter<T>>;\n\n [key: string]: any;\n}\n\n@Injectable()\nexport class Adapters {\n @Inject()\n injector: InjectorService;\n\n @Constant(\"adapters.Adapter\", MemoryAdapter)\n protected adapter: Type<Adapter>;\n\n invokeAdapter<T = any>(options: AdapterInvokeOptions): Adapter<T> {\n const {adapter = this.adapter, ...props} = options;\n const locals = options.locals || new Map();\n locals.set(DI_PARAM_OPTIONS, props);\n\n return this.injector.invoke<Adapter<T>>(adapter, locals);\n }\n}\n"]}
|
|
@@ -5,7 +5,7 @@ import { ensureDirSync } from "fs-extra";
|
|
|
5
5
|
import low from "lowdb";
|
|
6
6
|
import FileSync from "lowdb/adapters/FileSync";
|
|
7
7
|
import { dirname } from "path";
|
|
8
|
-
import { LowDbAdapter } from "./LowDbAdapter";
|
|
8
|
+
import { LowDbAdapter } from "./LowDbAdapter.js";
|
|
9
9
|
let FileSyncAdapter = class FileSyncAdapter extends LowDbAdapter {
|
|
10
10
|
constructor(options, configuration) {
|
|
11
11
|
super(options, configuration);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { cleanObject } from "@tsed/core";
|
|
1
2
|
import isMatch from "lodash/isMatch";
|
|
2
3
|
import { v4 as uuid } from "uuid";
|
|
3
|
-
import { Adapter } from "../domain/Adapter";
|
|
4
|
+
import { Adapter } from "../domain/Adapter.js";
|
|
4
5
|
export class LowDbAdapter extends Adapter {
|
|
6
|
+
db;
|
|
5
7
|
get collection() {
|
|
6
8
|
return this.db.get("collection");
|
|
7
9
|
}
|
|
@@ -32,7 +34,7 @@ export class LowDbAdapter extends Adapter {
|
|
|
32
34
|
return this.updateOne({ _id: id }, payload, expiresAt);
|
|
33
35
|
}
|
|
34
36
|
async updateOne(predicate, payload, expiresAt) {
|
|
35
|
-
let index = this.collection.findIndex(predicate).value();
|
|
37
|
+
let index = this.collection.findIndex(cleanObject(predicate)).value();
|
|
36
38
|
if (index === -1) {
|
|
37
39
|
return;
|
|
38
40
|
}
|
|
@@ -47,7 +49,7 @@ export class LowDbAdapter extends Adapter {
|
|
|
47
49
|
return this.deserialize(item);
|
|
48
50
|
}
|
|
49
51
|
async findOne(predicate) {
|
|
50
|
-
const item = this.collection.find(predicate).value();
|
|
52
|
+
const item = this.collection.find(cleanObject(predicate)).value();
|
|
51
53
|
return this.deserialize(item);
|
|
52
54
|
}
|
|
53
55
|
async findById(_id) {
|
|
@@ -55,12 +57,12 @@ export class LowDbAdapter extends Adapter {
|
|
|
55
57
|
}
|
|
56
58
|
async findAll(predicate = {}) {
|
|
57
59
|
return this.collection
|
|
58
|
-
.filter(predicate)
|
|
60
|
+
.filter(cleanObject(predicate))
|
|
59
61
|
.value()
|
|
60
62
|
.map((item) => this.deserialize(item));
|
|
61
63
|
}
|
|
62
64
|
async deleteOne(predicate) {
|
|
63
|
-
const item = this.collection.find(predicate).value();
|
|
65
|
+
const item = this.collection.find(cleanObject(predicate)).value();
|
|
64
66
|
if (item) {
|
|
65
67
|
this.collection.remove(({ _id }) => _id === item._id).write();
|
|
66
68
|
return this.deserialize(item);
|
|
@@ -73,7 +75,7 @@ export class LowDbAdapter extends Adapter {
|
|
|
73
75
|
let removedItems = [];
|
|
74
76
|
await this.collection
|
|
75
77
|
.remove((item) => {
|
|
76
|
-
if (isMatch(item, predicate)) {
|
|
78
|
+
if (isMatch(item, cleanObject(predicate))) {
|
|
77
79
|
removedItems.push(this.deserialize(item));
|
|
78
80
|
return true;
|
|
79
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LowDbAdapter.js","sourceRoot":"","sources":["../../../src/adapters/LowDbAdapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LowDbAdapter.js","sourceRoot":"","sources":["../../../src/adapters/LowDbAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AACvC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAC,EAAE,IAAI,IAAI,EAAC,MAAM,MAAM,CAAC;AAChC,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAS1C,MAAM,OAAO,YAAqC,SAAQ,OAAU;IACxD,EAAE,CAAmC;IAE/C,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACnC,CAAC;IAED,IAAc,UAAU;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;QACpE,OAAO,GAAG,QAAQ,IAAI,IAAI,CAAC,cAAc,OAAO,CAAC;IACnD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,OAAmB,EAAE,SAAgB;QACvD,IAAI,SAAS,EAAE;YACb,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;SAChC;QAED,OAAO,CAAC,GAAG,GAAG,IAAI,EAAE,CAAC;QAErB,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAY,CAAC,CAAC;QAElC,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAY,CAAC,CAAC,KAAK,EAAE,CAAC;QAEjD,OAAO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AAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SAC/B;IACH,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,GAAW;QACjC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAC,GAAG,EAAQ,CAAC,CAAC;IACtC,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,SAAqB;QAC3C,IAAI,YAAY,GAAQ,EAAE,CAAC;QAE3B,MAAM,IAAI,CAAC,UAAU;aAClB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACf,IAAI,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE;gBACzC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC1C,OAAO,IAAI,CAAC;aACb;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;aACD,KAAK,EAAE,CAAC;QAEX,OAAO,YAAY,CAAC;IACtB,CAAC;CACF","sourcesContent":["import {cleanObject} from \"@tsed/core\";\nimport isMatch from \"lodash/isMatch\";\nimport low from \"lowdb\";\nimport {v4 as uuid} from \"uuid\";\nimport {Adapter} from \"../domain/Adapter\";\n\nexport interface AdapterModel {\n _id: string;\n expires_at?: Date;\n\n [key: string]: any;\n}\n\nexport class LowDbAdapter<T extends AdapterModel> extends Adapter<T> {\n protected db: low.LowdbSync<{collection: T[]}>;\n\n get collection() {\n return this.db.get(\"collection\");\n }\n\n protected get dbFilePath() {\n const lowdbDir = this.configuration.get(\"adapters.lowdbDir\", \".db\");\n return `${lowdbDir}/${this.collectionName}.json`;\n }\n\n public async create(payload: Partial<T>, expiresAt?: Date): Promise<T> {\n if (expiresAt) {\n payload.expires_at = expiresAt;\n }\n\n payload._id = uuid();\n\n await this.validate(payload as T);\n\n await this.collection.push(payload as T).write();\n\n return this.deserialize(payload);\n }\n\n public async upsert(id: string, payload: T, expiresAt?: Date): Promise<T> {\n let item = await this.findById(id);\n\n if (!item) {\n payload = {...payload, _id: id || uuid(), expires_at: expiresAt};\n\n await this.validate(payload as T);\n await this.collection.push(payload as T).write();\n\n return this.deserialize(payload);\n }\n\n return (await this.update(id, payload, expiresAt)) as T;\n }\n\n public async update(id: string, payload: T, expiresAt?: Date): Promise<T | undefined> {\n return this.updateOne({_id: id}, payload, expiresAt);\n }\n\n public async updateOne(predicate: Partial<T & any>, payload: T, expiresAt?: Date): Promise<T | undefined> {\n let index = this.collection.findIndex(cleanObject(predicate)).value();\n\n if (index === -1) {\n return;\n }\n\n let item = this.collection.get(index).value();\n\n item = {\n _id: item._id,\n expires_at: expiresAt || item.expires_at,\n ...this.updateInstance(item, payload)\n };\n\n await this.validate(item as T);\n await this.collection.set(index, item).write();\n\n return this.deserialize(item);\n }\n\n async findOne(predicate: Partial<T & any>): Promise<T | undefined> {\n const item = this.collection.find(cleanObject(predicate)).value();\n\n return this.deserialize(item);\n }\n\n async findById(_id: string): Promise<T | undefined> {\n return this.findOne({_id});\n }\n\n public async findAll(predicate: Partial<T & any> = {}): Promise<T[]> {\n return this.collection\n .filter(cleanObject(predicate))\n .value()\n .map((item) => this.deserialize(item));\n }\n\n public async deleteOne(predicate: Partial<T & any>): Promise<T | undefined> {\n const item = this.collection.find(cleanObject(predicate)).value();\n\n if (item) {\n this.collection.remove(({_id}) => _id === item._id).write();\n\n return this.deserialize(item);\n }\n }\n\n public async deleteById(_id: string): Promise<T | undefined> {\n return this.deleteOne({_id} as any);\n }\n\n public async deleteMany(predicate: Partial<T>): Promise<T[]> {\n let removedItems: T[] = [];\n\n await this.collection\n .remove((item) => {\n if (isMatch(item, cleanObject(predicate))) {\n removedItems.push(this.deserialize(item));\n return true;\n }\n return false;\n })\n .write();\n\n return removedItems;\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { __decorate, __metadata, __param } from "tslib";
|
|
|
2
2
|
import { Configuration, Injectable, Opts, ProviderScope, Scope } from "@tsed/di";
|
|
3
3
|
import low from "lowdb";
|
|
4
4
|
import Memory from "lowdb/adapters/Memory";
|
|
5
|
-
import { LowDbAdapter } from "./LowDbAdapter";
|
|
5
|
+
import { LowDbAdapter } from "./LowDbAdapter.js";
|
|
6
6
|
let MemoryAdapter = class MemoryAdapter extends LowDbAdapter {
|
|
7
7
|
constructor(options, configuration) {
|
|
8
8
|
super(options, configuration);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { classOf, descriptorOf, isClass, isString } from "@tsed/core";
|
|
2
2
|
import { Inject } from "@tsed/di";
|
|
3
|
-
import { Adapters } from "../services/Adapters";
|
|
3
|
+
import { Adapters } from "../services/Adapters.js";
|
|
4
4
|
function mapOptions(args) {
|
|
5
5
|
return args.reduce((options, item, index) => {
|
|
6
6
|
if (isString(item)) {
|
|
@@ -26,6 +26,11 @@ function pluralize(name) {
|
|
|
26
26
|
return name.slice(-1) === "y" ? `${name.slice(0, name.length - 1)}ies` : name + "s";
|
|
27
27
|
}
|
|
28
28
|
let Adapter = class Adapter {
|
|
29
|
+
configuration;
|
|
30
|
+
model;
|
|
31
|
+
collectionName;
|
|
32
|
+
indexes;
|
|
33
|
+
ajvService;
|
|
29
34
|
constructor(options, configuration) {
|
|
30
35
|
this.configuration = configuration;
|
|
31
36
|
this.model = options.model;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Adapter.js","sourceRoot":"","sources":["../../../src/domain/Adapter.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAC;AACrC,OAAO,EAAC,OAAO,EAAY,MAAM,EAAO,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,UAAU,CAAC;AACrD,OAAO,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAUjD,SAAS,UAAU,CAAC,KAAU;IAC5B,OAAO,CAAC,GAAG,mBAAmB,CAAC,K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AC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;QAEhF,OAAO,IAAI,CAAC;IACd,CAAC;IAES,WAAW,CAAC,GAAQ;QAC5B,OAAO,WAAW,CAAC,GAAG,EAAE;YACtB,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE;YACrB,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;IACL,CAAC;IAES,SAAS,CAAC,GAAQ;QAC1B,OAAO,SAAS,CAAC,GAAG,EAAE;YACpB,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAtEC;IADC,MAAM,EAAE;8BACW,UAAU;2CAAC;AANX,OAAO;IAQd,WAAA,IAAI,CAAA;IAAsC,WAAA,aAAa,EAAE,CAAA;;GARlD,OAAO,CA4E5B;SA5EqB,OAAO","sourcesContent":["import {AjvService} from \"@tsed/ajv\";\nimport {isArray, isObject, nameOf, Type} from \"@tsed/core\";\nimport {Configuration, Inject, Opts} from \"@tsed/di\";\nimport {deserialize, serialize} from \"@tsed/json-mapper\";\nimport {getPropertiesStores} from \"@tsed/schema\";\n\nexport interface AdapterConstructorOptions<T = any> {\n model: Type<T> | Object;\n collectionName?: string;\n indexes?: {\n [propertyKey: string]: Record<string, any>;\n };\n}\n\nfunction getIndexes(model: any) {\n return [...getPropertiesStores(model).entries()]\n .filter(([, entity]) => entity.store.has(\"adapter:indexed\"))\n .map(([propertyKey, entity]) => {\n return {\n propertyKey: String(propertyKey),\n options: entity.store.get(\"adapter:indexed\")\n };\n });\n}\n\nfunction mapIndexes(indexes: {[p: string]: Record<string, any>} | {propertyKey: string; options: any}[]) {\n return Object.entries(indexes).reduce((indexes: any[], [propertyKey, options]) => {\n return indexes.concat({\n propertyKey,\n options\n });\n }, []);\n}\n\nfunction pluralize(name: string) {\n return name.slice(-1) === \"y\" ? `${name.slice(0, name.length - 1)}ies` : name + \"s\";\n}\n\nexport abstract class Adapter<Model = any> {\n readonly model: Type<Model> | Object;\n readonly collectionName: string;\n readonly indexes: {propertyKey: string; options: any}[];\n\n @Inject()\n private ajvService: AjvService;\n\n constructor(@Opts options: AdapterConstructorOptions, @Configuration() protected configuration: Configuration) {\n this.model = options.model;\n this.collectionName = options.collectionName || pluralize(nameOf(options.model));\n\n let indexes = options.indexes || configuration.get(`adapters.${this.collectionName}.indexes`) || getIndexes(this.model);\n\n if (!isArray(indexes)) {\n indexes = mapIndexes(indexes);\n }\n\n this.indexes = indexes;\n }\n\n async validate(value: Model): Promise<void> {\n if (this.getModel()) {\n await this.ajvService.validate(this.serialize(value), {\n type: this.model\n });\n }\n }\n\n abstract create(value: Partial<Omit<Model, \"_id\">>, expiresAt?: Date): Promise<Model>;\n\n abstract update(id: string, value: Model, expiresAt?: Date): Promise<Model | undefined>;\n\n abstract updateOne(predicate: Partial<Model>, value: Partial<Model>, expiresAt?: Date): Promise<Model | undefined>;\n\n abstract upsert(id: string, value: Model, expiresAt?: Date): Promise<Model>;\n\n abstract findOne(predicate: Partial<Model>): Promise<Model | undefined>;\n\n abstract findById(id: string): Promise<Model | undefined>;\n\n abstract findAll(predicate?: Partial<Model>): Promise<Model[]>;\n\n abstract deleteOne(predicate: Partial<Model>): Promise<Model | undefined>;\n\n abstract deleteMany(predicate: Partial<Model>): Promise<Model[]>;\n\n abstract deleteById(id: string): Promise<Model | undefined>;\n\n getModel() {\n return (this.model as unknown) !== Object ? this.model : undefined;\n }\n\n protected updateInstance(src: any, payload: any) {\n const item = Object.assign({\n ...this.serialize(src),\n ...this.serialize(payload)\n });\n\n item.expires_at = item.expires_at ? new Date(item.expires_at) : item.expires_at;\n\n return item;\n }\n\n protected deserialize(obj: any) {\n return deserialize(obj, {\n type: this.getModel(),\n useAlias: false\n });\n }\n\n protected serialize(obj: any) {\n return serialize(obj, {\n useAlias: false\n });\n }\n}\n"]}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./decorators/indexed";
|
|
8
|
-
export * from "./
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./adapters/FileSyncAdapter.js";
|
|
5
|
+
export * from "./adapters/LowDbAdapter.js";
|
|
6
|
+
export * from "./adapters/MemoryAdapter.js";
|
|
7
|
+
export * from "./decorators/indexed.js";
|
|
8
|
+
export * from "./decorators/injectAdapter.js";
|
|
9
|
+
export * from "./domain/Adapter.js";
|
|
10
|
+
export * from "./domain/AdaptersSettings.js";
|
|
11
|
+
export * from "./services/Adapters.js";
|
|
9
12
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./adapters/FileSyncAdapter\";\nexport * from \"./adapters/LowDbAdapter\";\nexport * from \"./adapters/MemoryAdapter\";\nexport * from \"./decorators/indexed\";\nexport * from \"./decorators/injectAdapter\";\nexport * from \"./domain/Adapter\";\nexport * from \"./domain/AdaptersSettings\";\nexport * from \"./services/Adapters\";\n"]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { Type } from "@tsed/core";
|
|
3
3
|
import { Constant, DI_PARAM_OPTIONS, Inject, Injectable, InjectorService } from "@tsed/di";
|
|
4
|
-
import { MemoryAdapter } from "../adapters/MemoryAdapter";
|
|
4
|
+
import { MemoryAdapter } from "../adapters/MemoryAdapter.js";
|
|
5
5
|
let Adapters = class Adapters {
|
|
6
|
+
injector;
|
|
7
|
+
adapter;
|
|
6
8
|
invokeAdapter(options) {
|
|
7
9
|
const { adapter = this.adapter, ...props } = options;
|
|
8
10
|
const locals = options.locals || new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Adapters.js","sourceRoot":"","sources":["../../../src/services/Adapters.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAChC,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AACzF,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAUxD,IAAa,QAAQ,GAArB,MAAa,QAAQ;
|
|
1
|
+
{"version":3,"file":"Adapters.js","sourceRoot":"","sources":["../../../src/services/Adapters.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAChC,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AACzF,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAUxD,IAAa,QAAQ,GAArB,MAAa,QAAQ;IAEnB,QAAQ,CAAkB;IAGhB,OAAO,CAAgB;IAEjC,aAAa,CAAU,OAA6B;QAClD,MAAM,EAAC,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,KAAK,EAAC,GAAG,OAAO,CAAC;QACnD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QAC3C,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QAEpC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAa,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AAZC;IADC,MAAM,EAAE;8BACC,eAAe;0CAAC;AAG1B;IADC,QAAQ,CAAC,kBAAkB,EAAE,aAAa,CAAC;8BACzB,IAAI;yCAAU;AALtB,QAAQ;IADpB,UAAU,EAAE;GACA,QAAQ,CAcpB;SAdY,QAAQ","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Constant, DI_PARAM_OPTIONS, Inject, Injectable, InjectorService} from \"@tsed/di\";\nimport {MemoryAdapter} from \"../adapters/MemoryAdapter\";\nimport {Adapter, AdapterConstructorOptions} from \"../domain/Adapter\";\n\nexport interface AdapterInvokeOptions<T = any> extends AdapterConstructorOptions<T> {\n adapter?: Type<Adapter<T>>;\n\n [key: string]: any;\n}\n\n@Injectable()\nexport class Adapters {\n @Inject()\n injector: InjectorService;\n\n @Constant(\"adapters.Adapter\", MemoryAdapter)\n protected adapter: Type<Adapter>;\n\n invokeAdapter<T = any>(options: AdapterInvokeOptions): Adapter<T> {\n const {adapter = this.adapter, ...props} = options;\n const locals = options.locals || new Map();\n locals.set(DI_PARAM_OPTIONS, props);\n\n return this.injector.invoke<Adapter<T>>(adapter, locals);\n }\n}\n"]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
|
+
/// <reference types="lodash" />
|
|
3
|
+
/// <reference types="lodash" />
|
|
4
|
+
/// <reference types="lodash" />
|
|
5
|
+
/// <reference types="lodash" />
|
|
6
|
+
/// <reference types="lodash" />
|
|
7
|
+
/// <reference types="lodash" />
|
|
2
8
|
import low from "lowdb";
|
|
3
9
|
import { Adapter } from "../domain/Adapter";
|
|
4
10
|
export interface AdapterModel {
|
|
@@ -7,9 +7,9 @@ export interface AdapterConstructorOptions<T = any> {
|
|
|
7
7
|
[propertyKey: string]: Record<string, any>;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
export declare abstract class Adapter<
|
|
10
|
+
export declare abstract class Adapter<Model = any> {
|
|
11
11
|
protected configuration: Configuration;
|
|
12
|
-
readonly model: Type<
|
|
12
|
+
readonly model: Type<Model> | Object;
|
|
13
13
|
readonly collectionName: string;
|
|
14
14
|
readonly indexes: {
|
|
15
15
|
propertyKey: string;
|
|
@@ -17,17 +17,17 @@ export declare abstract class Adapter<T = any> {
|
|
|
17
17
|
}[];
|
|
18
18
|
private ajvService;
|
|
19
19
|
constructor(options: AdapterConstructorOptions, configuration: Configuration);
|
|
20
|
-
validate(value:
|
|
21
|
-
abstract create(value: Partial<Omit<
|
|
22
|
-
abstract update(id: string, value:
|
|
23
|
-
abstract updateOne(predicate: Partial<
|
|
24
|
-
abstract upsert(id: string, value:
|
|
25
|
-
abstract findOne(predicate: Partial<
|
|
26
|
-
abstract findById(id: string): Promise<
|
|
27
|
-
abstract findAll(predicate?: Partial<
|
|
28
|
-
abstract deleteOne(predicate: Partial<
|
|
29
|
-
abstract deleteMany(predicate: Partial<
|
|
30
|
-
abstract deleteById(id: string): Promise<
|
|
20
|
+
validate(value: Model): Promise<void>;
|
|
21
|
+
abstract create(value: Partial<Omit<Model, "_id">>, expiresAt?: Date): Promise<Model>;
|
|
22
|
+
abstract update(id: string, value: Model, expiresAt?: Date): Promise<Model | undefined>;
|
|
23
|
+
abstract updateOne(predicate: Partial<Model>, value: Partial<Model>, expiresAt?: Date): Promise<Model | undefined>;
|
|
24
|
+
abstract upsert(id: string, value: Model, expiresAt?: Date): Promise<Model>;
|
|
25
|
+
abstract findOne(predicate: Partial<Model>): Promise<Model | undefined>;
|
|
26
|
+
abstract findById(id: string): Promise<Model | undefined>;
|
|
27
|
+
abstract findAll(predicate?: Partial<Model>): Promise<Model[]>;
|
|
28
|
+
abstract deleteOne(predicate: Partial<Model>): Promise<Model | undefined>;
|
|
29
|
+
abstract deleteMany(predicate: Partial<Model>): Promise<Model[]>;
|
|
30
|
+
abstract deleteById(id: string): Promise<Model | undefined>;
|
|
31
31
|
getModel(): Object | undefined;
|
|
32
32
|
protected updateInstance(src: any, payload: any): any;
|
|
33
33
|
protected deserialize(obj: any): any;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
1
4
|
export * from "./adapters/FileSyncAdapter";
|
|
2
5
|
export * from "./adapters/LowDbAdapter";
|
|
3
6
|
export * from "./adapters/MemoryAdapter";
|
|
7
|
+
export * from "./decorators/indexed";
|
|
8
|
+
export * from "./decorators/injectAdapter";
|
|
4
9
|
export * from "./domain/Adapter";
|
|
5
10
|
export * from "./domain/AdaptersSettings";
|
|
6
|
-
export * from "./decorators/injectAdapter";
|
|
7
|
-
export * from "./decorators/indexed";
|
|
8
11
|
export * from "./services/Adapters";
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/adapters",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.20",
|
|
4
4
|
"description": "Database adapters for Ts.ED",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/cjs/index.js",
|
|
8
|
+
"module": "./lib/esm/index.js",
|
|
8
9
|
"typings": "./lib/types/index.d.ts",
|
|
9
10
|
"exports": {
|
|
10
11
|
"types": "./lib/types/index.d.ts",
|
|
@@ -13,35 +14,36 @@
|
|
|
13
14
|
"default": "./lib/esm/index.js"
|
|
14
15
|
},
|
|
15
16
|
"scripts": {
|
|
16
|
-
"build": "yarn run build:esm && yarn run build:cjs",
|
|
17
|
+
"build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
|
|
17
18
|
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
18
19
|
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
20
|
+
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
|
|
19
21
|
"test": "cross-env NODE_ENV=test yarn jest"
|
|
20
22
|
},
|
|
21
23
|
"dependencies": {
|
|
22
|
-
"@types/lowdb": "1.0.
|
|
23
|
-
"@types/uuid": "8.3.
|
|
24
|
-
"fs-extra": "
|
|
24
|
+
"@types/lowdb": "1.0.11",
|
|
25
|
+
"@types/uuid": "8.3.4",
|
|
26
|
+
"fs-extra": "10.0.1",
|
|
25
27
|
"lowdb": "1.0.0",
|
|
26
|
-
"tslib": "2.
|
|
28
|
+
"tslib": "2.4.0",
|
|
27
29
|
"uuid": "8.3.2"
|
|
28
30
|
},
|
|
29
31
|
"devDependencies": {
|
|
30
|
-
"@tsed/ajv": "7.0.0-beta.
|
|
31
|
-
"@tsed/common": "7.0.0-beta.
|
|
32
|
-
"@tsed/core": "7.0.0-beta.
|
|
33
|
-
"@tsed/di": "7.0.0-beta.
|
|
34
|
-
"@tsed/json-mapper": "7.0.0-beta.
|
|
35
|
-
"@tsed/schema": "7.0.0-beta.
|
|
36
|
-
"@types/fs-extra": "9.0.
|
|
32
|
+
"@tsed/ajv": "7.0.0-beta.20",
|
|
33
|
+
"@tsed/common": "7.0.0-beta.20",
|
|
34
|
+
"@tsed/core": "7.0.0-beta.20",
|
|
35
|
+
"@tsed/di": "7.0.0-beta.20",
|
|
36
|
+
"@tsed/json-mapper": "7.0.0-beta.20",
|
|
37
|
+
"@tsed/schema": "7.0.0-beta.20",
|
|
38
|
+
"@types/fs-extra": "9.0.13"
|
|
37
39
|
},
|
|
38
40
|
"peerDependencies": {
|
|
39
|
-
"@tsed/ajv": "^7.0.0-beta.
|
|
40
|
-
"@tsed/common": "^7.0.0-beta.
|
|
41
|
-
"@tsed/core": "^7.0.0-beta.
|
|
42
|
-
"@tsed/di": "^7.0.0-beta.
|
|
43
|
-
"@tsed/json-mapper": "^7.0.0-beta.
|
|
44
|
-
"@tsed/schema": "^7.0.0-beta.
|
|
41
|
+
"@tsed/ajv": "^7.0.0-beta.20",
|
|
42
|
+
"@tsed/common": "^7.0.0-beta.20",
|
|
43
|
+
"@tsed/core": "^7.0.0-beta.20",
|
|
44
|
+
"@tsed/di": "^7.0.0-beta.20",
|
|
45
|
+
"@tsed/json-mapper": "^7.0.0-beta.20",
|
|
46
|
+
"@tsed/schema": "^7.0.0-beta.20",
|
|
45
47
|
"change-case": "^4.1.2",
|
|
46
48
|
"lodash": "^4.17.21"
|
|
47
49
|
},
|
|
@@ -49,7 +51,10 @@
|
|
|
49
51
|
"bugs": {
|
|
50
52
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
51
53
|
},
|
|
52
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
54
|
+
"homepage": "https://github.com/tsedio/tsed/tree/beta/packages/orm/adapters",
|
|
53
55
|
"author": "Romain Lenzotti",
|
|
54
|
-
"license": "MIT"
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"tag": "beta"
|
|
59
|
+
}
|
|
55
60
|
}
|
package/readme.md
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
[](https://badge.fury.io/js/%40tsed%2Fcommon)
|
|
12
12
|
[](https://github.com/semantic-release/semantic-release)
|
|
13
13
|
[](https://github.com/prettier/prettier)
|
|
14
|
-
[](https://github.com/sponsors/romakita)
|
|
15
|
+
[](https://opencollective.com/tsed)
|
|
15
16
|
|
|
16
17
|
</div>
|
|
17
18
|
|
|
@@ -29,76 +30,18 @@
|
|
|
29
30
|
|
|
30
31
|
A package of Ts.ED framework. See website: https://tsed.io/tutorials/adapters
|
|
31
32
|
|
|
32
|
-
## Feature
|
|
33
|
-
|
|
34
|
-
Currently, `@tsed/adapters` allows you:
|
|
35
|
-
|
|
36
|
-
- Create
|
|
37
|
-
|
|
38
|
-
## Installation
|
|
39
|
-
|
|
40
|
-
To begin, install the TypeORM module for TS.ED:
|
|
41
|
-
```bash
|
|
42
|
-
npm install --save @tsed/oidc-provider
|
|
43
|
-
npm install --save oidc-provider
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Then import `@tsed/oidc-provider` in your Server:
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
import {Configuration} from "@tsed/common";
|
|
50
|
-
import "@tsed/oidc-provider"; // import typeorm ts.ed module
|
|
51
|
-
import {Accounts} from "../services/Accounts";
|
|
52
|
-
import {MemoryAdapter} from "../adapters/MemoryAdapter";
|
|
53
|
-
|
|
54
|
-
export const rootDir = __dirname;
|
|
55
|
-
|
|
56
|
-
@Configuration({
|
|
57
|
-
oidc: {
|
|
58
|
-
jwksPath: `${rootDir}/../keys/jwks.json`, // don't forget add this path to .gitignore
|
|
59
|
-
Adapter: MemoryAdapter,
|
|
60
|
-
Accounts: Accounts,
|
|
61
|
-
// Clients: Clients,
|
|
62
|
-
clients: [
|
|
63
|
-
{
|
|
64
|
-
client_id: "client_id",
|
|
65
|
-
client_secret: "client_secret",
|
|
66
|
-
redirect_uris: [
|
|
67
|
-
"https://host.fr/"
|
|
68
|
-
]
|
|
69
|
-
}
|
|
70
|
-
],
|
|
71
|
-
options: { // Oidc-provider options See https://github.com/panva/node-oidc-provider/blob/master/docs/README.md
|
|
72
|
-
formats: {
|
|
73
|
-
AccessToken: "jwt"
|
|
74
|
-
},
|
|
75
|
-
features: {
|
|
76
|
-
encryption: {enabled: true},
|
|
77
|
-
introspection: {enabled: true},
|
|
78
|
-
revocation: {enabled: true}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
export class Server {
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
33
|
## Contributors
|
|
89
34
|
|
|
90
35
|
Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)
|
|
91
36
|
|
|
92
37
|
<a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
|
|
93
38
|
|
|
94
|
-
|
|
95
39
|
## Backers
|
|
96
40
|
|
|
97
41
|
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
|
|
98
42
|
|
|
99
43
|
<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/backers.svg?width=890"></a>
|
|
100
44
|
|
|
101
|
-
|
|
102
45
|
## Sponsors
|
|
103
46
|
|
|
104
47
|
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
|
|
@@ -107,7 +50,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
|
|
|
107
50
|
|
|
108
51
|
The MIT License (MIT)
|
|
109
52
|
|
|
110
|
-
Copyright (c) 2016 -
|
|
53
|
+
Copyright (c) 2016 - 2022 Romain Lenzotti
|
|
111
54
|
|
|
112
55
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
113
56
|
|
|
@@ -8,16 +8,5 @@
|
|
|
8
8
|
"declaration": true,
|
|
9
9
|
"declarationDir": "./lib/types"
|
|
10
10
|
},
|
|
11
|
-
"exclude": [
|
|
12
|
-
"node_modules",
|
|
13
|
-
"test",
|
|
14
|
-
"lib",
|
|
15
|
-
"benchmark",
|
|
16
|
-
"coverage",
|
|
17
|
-
"spec",
|
|
18
|
-
"**/*.benchmark.ts",
|
|
19
|
-
"**/*.spec.ts",
|
|
20
|
-
"keys",
|
|
21
|
-
"jest.config.js"
|
|
22
|
-
]
|
|
11
|
+
"exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
|
|
23
12
|
}
|
package/.nycrc
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"include": [
|
|
3
|
-
"src/**/*.ts"
|
|
4
|
-
],
|
|
5
|
-
"exclude": [
|
|
6
|
-
"**/*.d.ts",
|
|
7
|
-
"node_modules",
|
|
8
|
-
"**/interfaces/**",
|
|
9
|
-
"**/index.ts"
|
|
10
|
-
],
|
|
11
|
-
"extension": [
|
|
12
|
-
".ts"
|
|
13
|
-
],
|
|
14
|
-
"require": [],
|
|
15
|
-
"reporter": [
|
|
16
|
-
"text-summary",
|
|
17
|
-
"html",
|
|
18
|
-
"lcov",
|
|
19
|
-
"json"
|
|
20
|
-
],
|
|
21
|
-
"check-coverage": true,
|
|
22
|
-
"statements": 100,
|
|
23
|
-
"branches": 78.57,
|
|
24
|
-
"functions": 100,
|
|
25
|
-
"lines": 100
|
|
26
|
-
}
|