@nymphjs/server 1.0.0-beta.4 → 1.0.0-beta.40
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/CHANGELOG.md +156 -0
- package/README.md +77 -5
- package/dist/HttpError.d.ts +5 -0
- package/dist/HttpError.js +13 -0
- package/dist/HttpError.js.map +1 -0
- package/dist/cache.test.js +5 -5
- package/dist/cache.test.js.map +1 -1
- package/dist/createServer.d.ts +8 -0
- package/dist/createServer.js +869 -0
- package/dist/createServer.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +18 -712
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +151 -39
- package/dist/index.test.js.map +1 -1
- package/dist/statusDescriptions.d.ts +3 -0
- package/dist/statusDescriptions.js +69 -0
- package/dist/statusDescriptions.js.map +1 -0
- package/dist/testArtifacts.d.ts +56 -1
- package/dist/testArtifacts.js +152 -8
- package/dist/testArtifacts.js.map +1 -1
- package/package.json +13 -13
- package/src/HttpError.ts +12 -0
- package/src/cache.test.ts +6 -3
- package/src/createServer.ts +971 -0
- package/src/index.test.ts +144 -6
- package/src/index.ts +5 -793
- package/src/statusDescriptions.ts +68 -0
- package/src/testArtifacts.ts +226 -7
- package/typedoc.json +4 -0
package/dist/testArtifacts.d.ts
CHANGED
|
@@ -31,8 +31,13 @@ export declare class EmployeeModel extends EntityServer<EmployeeModelData> {
|
|
|
31
31
|
$testMethodStateless(value: number): number;
|
|
32
32
|
$testMethod(value: number): number;
|
|
33
33
|
static testStatic(value: number): number;
|
|
34
|
+
static testStaticIterable(value: number): Generator<number, void, unknown>;
|
|
35
|
+
static testStaticIterableAbort(): Iterator<number, void, boolean>;
|
|
34
36
|
static throwErrorStatic(): void;
|
|
37
|
+
static throwErrorStaticIterable(): Generator<number, void, unknown>;
|
|
35
38
|
$throwError(): void;
|
|
39
|
+
$throwHttpError(): void;
|
|
40
|
+
$throwHttpErrorWithDescription(): void;
|
|
36
41
|
static inaccessibleMethod(): boolean;
|
|
37
42
|
}
|
|
38
43
|
export declare class BadFunctionCallError extends Error {
|
|
@@ -47,8 +52,58 @@ export declare class Employee extends Entity<EmployeeData> {
|
|
|
47
52
|
$testMethod(value: number): Promise<any>;
|
|
48
53
|
$testMethodStateless(value: number): Promise<any>;
|
|
49
54
|
$throwError(): Promise<any>;
|
|
55
|
+
$throwHttpError(): Promise<any>;
|
|
56
|
+
$throwHttpErrorWithDescription(): Promise<any>;
|
|
50
57
|
static testStatic(value: number): Promise<any>;
|
|
58
|
+
static testStaticIterable(value: number): Promise<import("@nymphjs/client").AbortableAsyncIterator<any>>;
|
|
59
|
+
static testStaticIterableAbort(): Promise<import("@nymphjs/client").AbortableAsyncIterator<any>>;
|
|
51
60
|
static throwErrorStatic(): Promise<any>;
|
|
61
|
+
static throwErrorStaticIterable(): Promise<import("@nymphjs/client").AbortableAsyncIterator<any>>;
|
|
52
62
|
static inaccessibleMethod(): Promise<any>;
|
|
53
63
|
}
|
|
54
|
-
export
|
|
64
|
+
export type RestrictedModelData = {
|
|
65
|
+
name: string;
|
|
66
|
+
};
|
|
67
|
+
export declare class RestrictedModel extends EntityServer<RestrictedModelData> {
|
|
68
|
+
static ETYPE: string;
|
|
69
|
+
static class: string;
|
|
70
|
+
static restEnabled: boolean;
|
|
71
|
+
static factory(guid?: string): Promise<RestrictedModel & RestrictedModelData>;
|
|
72
|
+
static factorySync(guid?: string): RestrictedModel & RestrictedModelData;
|
|
73
|
+
constructor(guid?: string);
|
|
74
|
+
$save(): Promise<boolean>;
|
|
75
|
+
$testMethod(value: string): string;
|
|
76
|
+
static testStatic(value: number): number;
|
|
77
|
+
}
|
|
78
|
+
export type RestrictedData = {
|
|
79
|
+
name: string;
|
|
80
|
+
};
|
|
81
|
+
export declare class Restricted extends Entity<RestrictedData> {
|
|
82
|
+
static class: string;
|
|
83
|
+
constructor(guid?: string);
|
|
84
|
+
static factory(guid?: string): Promise<Restricted & RestrictedData>;
|
|
85
|
+
static factorySync(guid?: string): Restricted & RestrictedData;
|
|
86
|
+
$testMethod(value: number): Promise<any>;
|
|
87
|
+
static testStatic(value: number): Promise<any>;
|
|
88
|
+
}
|
|
89
|
+
export type PubSubDisabledModelData = {
|
|
90
|
+
name: string;
|
|
91
|
+
};
|
|
92
|
+
export declare class PubSubDisabledModel extends EntityServer<PubSubDisabledModelData> {
|
|
93
|
+
static ETYPE: string;
|
|
94
|
+
static class: string;
|
|
95
|
+
static pubSubEnabled: boolean;
|
|
96
|
+
static factory(guid?: string): Promise<PubSubDisabledModel & PubSubDisabledModelData>;
|
|
97
|
+
static factorySync(guid?: string): PubSubDisabledModel & PubSubDisabledModelData;
|
|
98
|
+
constructor(guid?: string);
|
|
99
|
+
$save(): Promise<boolean>;
|
|
100
|
+
}
|
|
101
|
+
export type PubSubDisabledData = {
|
|
102
|
+
name: string;
|
|
103
|
+
};
|
|
104
|
+
export declare class PubSubDisabled extends Entity<PubSubDisabledData> {
|
|
105
|
+
static class: string;
|
|
106
|
+
constructor(guid?: string);
|
|
107
|
+
static factory(guid?: string): Promise<PubSubDisabled & PubSubDisabledData>;
|
|
108
|
+
static factorySync(guid?: string): PubSubDisabled & PubSubDisabledData;
|
|
109
|
+
}
|
package/dist/testArtifacts.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Employee = exports.BadFunctionCallError = exports.EmployeeModel = void 0;
|
|
3
|
+
exports.PubSubDisabled = exports.PubSubDisabledModel = exports.Restricted = exports.RestrictedModel = exports.Employee = exports.BadFunctionCallError = exports.EmployeeModel = void 0;
|
|
4
4
|
const nymph_1 = require("@nymphjs/nymph");
|
|
5
5
|
const client_1 = require("@nymphjs/client");
|
|
6
|
+
const HttpError_1 = require("./HttpError");
|
|
6
7
|
const IS_MANAGER = true;
|
|
7
8
|
class EmployeeModel extends nymph_1.Entity {
|
|
8
9
|
static async factory(guid) {
|
|
@@ -17,6 +18,8 @@ class EmployeeModel extends nymph_1.Entity {
|
|
|
17
18
|
'$testMethodStateless',
|
|
18
19
|
'$testMethod',
|
|
19
20
|
'$throwError',
|
|
21
|
+
'$throwHttpError',
|
|
22
|
+
'$throwHttpErrorWithDescription',
|
|
20
23
|
];
|
|
21
24
|
this.$protectedTags = ['employee'];
|
|
22
25
|
this.$allowlistTags = ['boss', 'bigcheese'];
|
|
@@ -46,10 +49,10 @@ class EmployeeModel extends nymph_1.Entity {
|
|
|
46
49
|
}
|
|
47
50
|
async $save() {
|
|
48
51
|
const error = new nymph_1.EntityInvalidDataError('Invalid entity data.');
|
|
49
|
-
if (this.$data.name == null || this.$data.name
|
|
52
|
+
if (this.$data.name == null || this.$data.name === '') {
|
|
50
53
|
error.addField('name');
|
|
51
54
|
}
|
|
52
|
-
if (this.$data.title == null || this.$data.title
|
|
55
|
+
if (this.$data.title == null || this.$data.title === '') {
|
|
53
56
|
error.addField('title');
|
|
54
57
|
}
|
|
55
58
|
if (this.$data.startDate == null) {
|
|
@@ -74,12 +77,33 @@ class EmployeeModel extends nymph_1.Entity {
|
|
|
74
77
|
static testStatic(value) {
|
|
75
78
|
return value * 2;
|
|
76
79
|
}
|
|
80
|
+
static *testStaticIterable(value) {
|
|
81
|
+
yield value + 1;
|
|
82
|
+
yield value + 2;
|
|
83
|
+
yield value + 3;
|
|
84
|
+
}
|
|
85
|
+
static *testStaticIterableAbort() {
|
|
86
|
+
let aborted = yield 1;
|
|
87
|
+
if (!aborted) {
|
|
88
|
+
throw new Error("testStaticIterableAbort wasn't aborted after the first iteration.");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
77
91
|
static throwErrorStatic() {
|
|
78
92
|
throw new BadFunctionCallError('This function only throws errors.');
|
|
79
93
|
}
|
|
94
|
+
static *throwErrorStaticIterable() {
|
|
95
|
+
yield 1;
|
|
96
|
+
throw new BadFunctionCallError('This function throws errors after the first iteration.');
|
|
97
|
+
}
|
|
80
98
|
$throwError() {
|
|
81
99
|
throw new BadFunctionCallError('This function only throws errors.');
|
|
82
100
|
}
|
|
101
|
+
$throwHttpError() {
|
|
102
|
+
throw new HttpError_1.HttpError('A 501 HTTP error.', 501);
|
|
103
|
+
}
|
|
104
|
+
$throwHttpErrorWithDescription() {
|
|
105
|
+
throw new HttpError_1.HttpError('A 512 HTTP error.', 512, 'Some Error');
|
|
106
|
+
}
|
|
83
107
|
static inaccessibleMethod() {
|
|
84
108
|
return true;
|
|
85
109
|
}
|
|
@@ -87,7 +111,13 @@ class EmployeeModel extends nymph_1.Entity {
|
|
|
87
111
|
exports.EmployeeModel = EmployeeModel;
|
|
88
112
|
EmployeeModel.ETYPE = 'employee';
|
|
89
113
|
EmployeeModel.class = 'Employee';
|
|
90
|
-
EmployeeModel.clientEnabledStaticMethods = [
|
|
114
|
+
EmployeeModel.clientEnabledStaticMethods = [
|
|
115
|
+
'testStatic',
|
|
116
|
+
'testStaticIterable',
|
|
117
|
+
'testStaticIterableAbort',
|
|
118
|
+
'throwErrorStatic',
|
|
119
|
+
'throwErrorStaticIterable',
|
|
120
|
+
];
|
|
91
121
|
class BadFunctionCallError extends Error {
|
|
92
122
|
constructor(message) {
|
|
93
123
|
super(message);
|
|
@@ -119,17 +149,131 @@ class Employee extends client_1.Entity {
|
|
|
119
149
|
$throwError() {
|
|
120
150
|
return this.$serverCall('$throwError', []);
|
|
121
151
|
}
|
|
152
|
+
$throwHttpError() {
|
|
153
|
+
return this.$serverCall('$throwHttpError', []);
|
|
154
|
+
}
|
|
155
|
+
$throwHttpErrorWithDescription() {
|
|
156
|
+
return this.$serverCall('$throwHttpErrorWithDescription', []);
|
|
157
|
+
}
|
|
122
158
|
static testStatic(value) {
|
|
123
|
-
return
|
|
159
|
+
return this.serverCallStatic('testStatic', [value]);
|
|
160
|
+
}
|
|
161
|
+
static testStaticIterable(value) {
|
|
162
|
+
return this.serverCallStaticIterator('testStaticIterable', [value]);
|
|
163
|
+
}
|
|
164
|
+
static testStaticIterableAbort() {
|
|
165
|
+
return this.serverCallStaticIterator('testStaticIterableAbort', []);
|
|
124
166
|
}
|
|
125
167
|
static throwErrorStatic() {
|
|
126
|
-
return
|
|
168
|
+
return this.serverCallStatic('throwErrorStatic', []);
|
|
169
|
+
}
|
|
170
|
+
static throwErrorStaticIterable() {
|
|
171
|
+
return this.serverCallStaticIterator('throwErrorStaticIterable', []);
|
|
127
172
|
}
|
|
128
173
|
static inaccessibleMethod() {
|
|
129
|
-
return
|
|
174
|
+
return this.serverCallStatic('inaccessibleMethod', []);
|
|
130
175
|
}
|
|
131
176
|
}
|
|
132
177
|
exports.Employee = Employee;
|
|
133
178
|
Employee.class = 'Employee';
|
|
134
|
-
|
|
179
|
+
class RestrictedModel extends nymph_1.Entity {
|
|
180
|
+
static async factory(guid) {
|
|
181
|
+
return (await super.factory(guid));
|
|
182
|
+
}
|
|
183
|
+
static factorySync(guid) {
|
|
184
|
+
return super.factorySync(guid);
|
|
185
|
+
}
|
|
186
|
+
constructor(guid) {
|
|
187
|
+
super(guid);
|
|
188
|
+
if (this.guid == null) {
|
|
189
|
+
this.$data.name = '';
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
async $save() {
|
|
193
|
+
const error = new nymph_1.EntityInvalidDataError('Invalid entity data.');
|
|
194
|
+
if (this.$data.name == null || this.$data.name === '') {
|
|
195
|
+
error.addField('name');
|
|
196
|
+
}
|
|
197
|
+
if (error.getFields().length) {
|
|
198
|
+
throw error;
|
|
199
|
+
}
|
|
200
|
+
return await super.$save();
|
|
201
|
+
}
|
|
202
|
+
$testMethod(value) {
|
|
203
|
+
return value;
|
|
204
|
+
}
|
|
205
|
+
static testStatic(value) {
|
|
206
|
+
return value;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.RestrictedModel = RestrictedModel;
|
|
210
|
+
RestrictedModel.ETYPE = 'restricted';
|
|
211
|
+
RestrictedModel.class = 'Restricted';
|
|
212
|
+
RestrictedModel.restEnabled = false;
|
|
213
|
+
class Restricted extends client_1.Entity {
|
|
214
|
+
constructor(guid) {
|
|
215
|
+
super(guid);
|
|
216
|
+
if (guid == null) {
|
|
217
|
+
this.$data.name = '';
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
static async factory(guid) {
|
|
221
|
+
return (await super.factory(guid));
|
|
222
|
+
}
|
|
223
|
+
static factorySync(guid) {
|
|
224
|
+
return super.factorySync(guid);
|
|
225
|
+
}
|
|
226
|
+
$testMethod(value) {
|
|
227
|
+
return this.$serverCall('$testMethod', [value]);
|
|
228
|
+
}
|
|
229
|
+
static testStatic(value) {
|
|
230
|
+
return this.serverCallStatic('testStatic', [value]);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
exports.Restricted = Restricted;
|
|
234
|
+
Restricted.class = 'Restricted';
|
|
235
|
+
class PubSubDisabledModel extends nymph_1.Entity {
|
|
236
|
+
static async factory(guid) {
|
|
237
|
+
return (await super.factory(guid));
|
|
238
|
+
}
|
|
239
|
+
static factorySync(guid) {
|
|
240
|
+
return super.factorySync(guid);
|
|
241
|
+
}
|
|
242
|
+
constructor(guid) {
|
|
243
|
+
super(guid);
|
|
244
|
+
if (guid == null) {
|
|
245
|
+
this.$data.name = '';
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
async $save() {
|
|
249
|
+
const error = new nymph_1.EntityInvalidDataError('Invalid entity data.');
|
|
250
|
+
if (this.$data.name == null || this.$data.name === '') {
|
|
251
|
+
error.addField('name');
|
|
252
|
+
}
|
|
253
|
+
if (error.getFields().length) {
|
|
254
|
+
throw error;
|
|
255
|
+
}
|
|
256
|
+
return await super.$save();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
exports.PubSubDisabledModel = PubSubDisabledModel;
|
|
260
|
+
PubSubDisabledModel.ETYPE = 'pubsub_disabled';
|
|
261
|
+
PubSubDisabledModel.class = 'PubSubDisabled';
|
|
262
|
+
PubSubDisabledModel.pubSubEnabled = false;
|
|
263
|
+
class PubSubDisabled extends client_1.Entity {
|
|
264
|
+
constructor(guid) {
|
|
265
|
+
super(guid);
|
|
266
|
+
if (guid == null) {
|
|
267
|
+
this.$data.name = '';
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
static async factory(guid) {
|
|
271
|
+
return (await super.factory(guid));
|
|
272
|
+
}
|
|
273
|
+
static factorySync(guid) {
|
|
274
|
+
return super.factorySync(guid);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
exports.PubSubDisabled = PubSubDisabled;
|
|
278
|
+
PubSubDisabled.class = 'PubSubDisabled';
|
|
135
279
|
//# sourceMappingURL=testArtifacts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testArtifacts.js","sourceRoot":"","sources":["../src/testArtifacts.ts"],"names":[],"mappings":";;;AAAA,0CAAgF;AAChF,4CAAyC;
|
|
1
|
+
{"version":3,"file":"testArtifacts.js","sourceRoot":"","sources":["../src/testArtifacts.ts"],"names":[],"mappings":";;;AAAA,0CAAgF;AAChF,4CAAyC;AAEzC,2CAAwC;AAsBxC,MAAM,UAAU,GAAG,IAAI,CAAC;AAKxB,MAAa,aAAc,SAAQ,cAA+B;IAmChE,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,IAAa;QAEb,OAAO,CAAC,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAsC,CAAC;IAC1E,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAa;QAC9B,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,CAAsC,CAAC;IACtE,CAAC;IAED,YAAY,IAAa;QACvB,KAAK,CAAC,IAAI,CAAC,CAAC;QA1CJ,0BAAqB,GAAG;YAChC,sBAAsB;YACtB,aAAa;YACb,aAAa;YACb,iBAAiB;YACjB,gCAAgC;SACjC,CAAC;QAQQ,mBAAc,GAAG,CAAC,UAAU,CAAC,CAAC;QAC9B,mBAAc,GAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACxC,mBAAc,GAAI;YA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AM,KAAK,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;;AAtCH,kDAuCC;AAtCQ,yBAAK,GAAG,iBAAiB,CAAC;AAC1B,yBAAK,GAAG,gBAAgB,CAAC;AAElB,iCAAa,GAAG,KAAK,CAAC;AAyCtC,MAAa,cAAe,SAAQ,eAA0B;IAI5D,YAAY,IAAa;QACvB,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,IAAI,IAAI,IAAI,EAAE;YAChB,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;SACtB;IACH,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,IAAa;QAEb,OAAO,CAAC,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAwC,CAAC;IAC5E,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAa;QAC9B,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,CAAwC,CAAC;IACxE,CAAC;;AApBH,wCAqBC;AAnBe,oBAAK,GAAG,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nymphjs/server",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.40",
|
|
4
4
|
"description": "NymphJS - REST Server",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"clean": "test -d dist && rm -r dist || true",
|
|
15
15
|
"build": "tsc",
|
|
16
16
|
"watch": "tsc --watch",
|
|
17
|
-
"
|
|
17
|
+
"prepublish": "npm run clean && npm run build",
|
|
18
18
|
"test": "jest",
|
|
19
19
|
"test:watch": "jest --watch"
|
|
20
20
|
},
|
|
@@ -31,21 +31,21 @@
|
|
|
31
31
|
},
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@nymphjs/nymph": "^1.0.0-beta.
|
|
34
|
+
"@nymphjs/nymph": "^1.0.0-beta.40",
|
|
35
35
|
"cookie-parser": "^1.4.6",
|
|
36
36
|
"express": "^4.18.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@nymphjs/client": "^1.0.0-beta.
|
|
40
|
-
"@nymphjs/client-node": "^1.0.0-beta.
|
|
41
|
-
"@nymphjs/driver-sqlite3": "^1.0.0-beta.
|
|
42
|
-
"@tsconfig/recommended": "^1.0.
|
|
39
|
+
"@nymphjs/client": "^1.0.0-beta.40",
|
|
40
|
+
"@nymphjs/client-node": "^1.0.0-beta.40",
|
|
41
|
+
"@nymphjs/driver-sqlite3": "^1.0.0-beta.40",
|
|
42
|
+
"@tsconfig/recommended": "^1.0.2",
|
|
43
43
|
"@types/cookie-parser": "^1.4.3",
|
|
44
|
-
"@types/express": "^4.17.
|
|
45
|
-
"@types/jest": "^29.2
|
|
46
|
-
"jest": "^29.
|
|
47
|
-
"ts-jest": "^29.0
|
|
48
|
-
"typescript": "^
|
|
44
|
+
"@types/express": "^4.17.17",
|
|
45
|
+
"@types/jest": "^29.5.2",
|
|
46
|
+
"jest": "^29.5.0",
|
|
47
|
+
"ts-jest": "^29.1.0",
|
|
48
|
+
"typescript": "^5.1.3"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "35e19ed33ad831221c3c15c8005361eb0c6a15cf"
|
|
51
51
|
}
|
package/src/HttpError.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class HttpError extends Error {
|
|
2
|
+
status?: number;
|
|
3
|
+
statusText?: string;
|
|
4
|
+
|
|
5
|
+
constructor(message: string, status?: number, statusText?: string) {
|
|
6
|
+
super(message);
|
|
7
|
+
|
|
8
|
+
this.name = 'HttpError';
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.statusText = statusText;
|
|
11
|
+
}
|
|
12
|
+
}
|
package/src/cache.test.ts
CHANGED
|
@@ -4,14 +4,17 @@ import { Nymph as NymphServer } from '@nymphjs/nymph';
|
|
|
4
4
|
import { Nymph } from '@nymphjs/client-node';
|
|
5
5
|
|
|
6
6
|
import createServer from './index';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
EmployeeModel as EmployeeModelClass,
|
|
9
|
+
Employee as EmployeeClass,
|
|
10
|
+
} from './testArtifacts';
|
|
8
11
|
|
|
9
12
|
const sqliteConfig = {
|
|
10
13
|
filename: ':memory:',
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
const nymphServer = new NymphServer({}, new SQLite3Driver(sqliteConfig));
|
|
14
|
-
nymphServer.addEntityClass(
|
|
17
|
+
const EmployeeModel = nymphServer.addEntityClass(EmployeeModelClass);
|
|
15
18
|
|
|
16
19
|
const app = express();
|
|
17
20
|
app.use('/test', createServer(nymphServer));
|
|
@@ -21,7 +24,7 @@ const nymph = new Nymph({
|
|
|
21
24
|
restUrl: 'http://localhost:5081/test/',
|
|
22
25
|
weakCache: true,
|
|
23
26
|
});
|
|
24
|
-
nymph.addEntityClass(
|
|
27
|
+
const Employee = nymph.addEntityClass(EmployeeClass);
|
|
25
28
|
|
|
26
29
|
describe('Nymph REST Server and Client with Client Weak Ref Cache', () => {
|
|
27
30
|
async function createJane() {
|