@nymphjs/server 1.0.0-beta.5 → 1.0.0-beta.51
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 +199 -0
- package/README.md +78 -6
- 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 +153 -41
- 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 +60 -5
- package/dist/testArtifacts.js +161 -29
- package/dist/testArtifacts.js.map +1 -1
- package/package.json +16 -16
- package/src/HttpError.ts +12 -0
- package/src/cache.test.ts +8 -5
- package/src/createServer.ts +971 -0
- package/src/index.test.ts +167 -28
- package/src/index.ts +5 -793
- package/src/statusDescriptions.ts +68 -0
- package/src/testArtifacts.ts +233 -29
- package/typedoc.json +4 -0
package/dist/testArtifacts.d.ts
CHANGED
|
@@ -25,14 +25,19 @@ export declare class EmployeeModel extends EntityServer<EmployeeModelData> {
|
|
|
25
25
|
protected $allowlistTags?: string[] | undefined;
|
|
26
26
|
protected $allowlistData?: string[] | undefined;
|
|
27
27
|
static factory(guid?: string): Promise<EmployeeModel & EmployeeModelData>;
|
|
28
|
-
static factorySync(
|
|
29
|
-
constructor(
|
|
28
|
+
static factorySync(): EmployeeModel & EmployeeModelData;
|
|
29
|
+
constructor();
|
|
30
30
|
$save(): Promise<boolean>;
|
|
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 {
|
|
@@ -41,14 +46,64 @@ export declare class BadFunctionCallError extends Error {
|
|
|
41
46
|
export type EmployeeData = EmployeeBaseData<Employee>;
|
|
42
47
|
export declare class Employee extends Entity<EmployeeData> {
|
|
43
48
|
static class: string;
|
|
44
|
-
constructor(
|
|
49
|
+
constructor();
|
|
45
50
|
static factory(guid?: string): Promise<Employee & EmployeeData>;
|
|
46
|
-
static factorySync(
|
|
51
|
+
static factorySync(): Employee & 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(): RestrictedModel & RestrictedModelData;
|
|
73
|
+
constructor();
|
|
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();
|
|
84
|
+
static factory(guid?: string): Promise<Restricted & RestrictedData>;
|
|
85
|
+
static factorySync(): 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(): PubSubDisabledModel & PubSubDisabledModelData;
|
|
98
|
+
constructor();
|
|
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();
|
|
107
|
+
static factory(guid?: string): Promise<PubSubDisabled & PubSubDisabledData>;
|
|
108
|
+
static factorySync(): PubSubDisabled & PubSubDisabledData;
|
|
109
|
+
}
|
package/dist/testArtifacts.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
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) {
|
|
9
10
|
return (await super.factory(guid));
|
|
10
11
|
}
|
|
11
|
-
static factorySync(
|
|
12
|
-
return super.factorySync(
|
|
12
|
+
static factorySync() {
|
|
13
|
+
return super.factorySync();
|
|
13
14
|
}
|
|
14
|
-
constructor(
|
|
15
|
-
super(
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
16
17
|
this.$clientEnabledMethods = [
|
|
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'];
|
|
@@ -34,22 +37,20 @@ class EmployeeModel extends nymph_1.Entity {
|
|
|
34
37
|
'manager',
|
|
35
38
|
'building',
|
|
36
39
|
];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.$privateData.push('salary');
|
|
44
|
-
}
|
|
40
|
+
this.$addTag('employee');
|
|
41
|
+
this.$data.current = true;
|
|
42
|
+
this.$data.startDate = Date.now();
|
|
43
|
+
this.$data.subordinates = [];
|
|
44
|
+
if (!IS_MANAGER) {
|
|
45
|
+
this.$privateData.push('salary');
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
async $save() {
|
|
48
49
|
const error = new nymph_1.EntityInvalidDataError('Invalid entity data.');
|
|
49
|
-
if (this.$data.name == null || this.$data.name
|
|
50
|
+
if (this.$data.name == null || this.$data.name === '') {
|
|
50
51
|
error.addField('name');
|
|
51
52
|
}
|
|
52
|
-
if (this.$data.title == null || this.$data.title
|
|
53
|
+
if (this.$data.title == null || this.$data.title === '') {
|
|
53
54
|
error.addField('title');
|
|
54
55
|
}
|
|
55
56
|
if (this.$data.startDate == null) {
|
|
@@ -74,12 +75,33 @@ class EmployeeModel extends nymph_1.Entity {
|
|
|
74
75
|
static testStatic(value) {
|
|
75
76
|
return value * 2;
|
|
76
77
|
}
|
|
78
|
+
static *testStaticIterable(value) {
|
|
79
|
+
yield value + 1;
|
|
80
|
+
yield value + 2;
|
|
81
|
+
yield value + 3;
|
|
82
|
+
}
|
|
83
|
+
static *testStaticIterableAbort() {
|
|
84
|
+
let aborted = yield 1;
|
|
85
|
+
if (!aborted) {
|
|
86
|
+
throw new Error("testStaticIterableAbort wasn't aborted after the first iteration.");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
77
89
|
static throwErrorStatic() {
|
|
78
90
|
throw new BadFunctionCallError('This function only throws errors.');
|
|
79
91
|
}
|
|
92
|
+
static *throwErrorStaticIterable() {
|
|
93
|
+
yield 1;
|
|
94
|
+
throw new BadFunctionCallError('This function throws errors after the first iteration.');
|
|
95
|
+
}
|
|
80
96
|
$throwError() {
|
|
81
97
|
throw new BadFunctionCallError('This function only throws errors.');
|
|
82
98
|
}
|
|
99
|
+
$throwHttpError() {
|
|
100
|
+
throw new HttpError_1.HttpError('A 501 HTTP error.', 501);
|
|
101
|
+
}
|
|
102
|
+
$throwHttpErrorWithDescription() {
|
|
103
|
+
throw new HttpError_1.HttpError('A 512 HTTP error.', 512, 'Some Error');
|
|
104
|
+
}
|
|
83
105
|
static inaccessibleMethod() {
|
|
84
106
|
return true;
|
|
85
107
|
}
|
|
@@ -87,7 +109,13 @@ class EmployeeModel extends nymph_1.Entity {
|
|
|
87
109
|
exports.EmployeeModel = EmployeeModel;
|
|
88
110
|
EmployeeModel.ETYPE = 'employee';
|
|
89
111
|
EmployeeModel.class = 'Employee';
|
|
90
|
-
EmployeeModel.clientEnabledStaticMethods = [
|
|
112
|
+
EmployeeModel.clientEnabledStaticMethods = [
|
|
113
|
+
'testStatic',
|
|
114
|
+
'testStaticIterable',
|
|
115
|
+
'testStaticIterableAbort',
|
|
116
|
+
'throwErrorStatic',
|
|
117
|
+
'throwErrorStaticIterable',
|
|
118
|
+
];
|
|
91
119
|
class BadFunctionCallError extends Error {
|
|
92
120
|
constructor(message) {
|
|
93
121
|
super(message);
|
|
@@ -96,19 +124,17 @@ class BadFunctionCallError extends Error {
|
|
|
96
124
|
}
|
|
97
125
|
exports.BadFunctionCallError = BadFunctionCallError;
|
|
98
126
|
class Employee extends client_1.Entity {
|
|
99
|
-
constructor(
|
|
100
|
-
super(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.$data.subordinates = [];
|
|
105
|
-
}
|
|
127
|
+
constructor() {
|
|
128
|
+
super();
|
|
129
|
+
this.$addTag('employee');
|
|
130
|
+
this.$data.current = true;
|
|
131
|
+
this.$data.subordinates = [];
|
|
106
132
|
}
|
|
107
133
|
static async factory(guid) {
|
|
108
134
|
return (await super.factory(guid));
|
|
109
135
|
}
|
|
110
|
-
static factorySync(
|
|
111
|
-
return super.factorySync(
|
|
136
|
+
static factorySync() {
|
|
137
|
+
return super.factorySync();
|
|
112
138
|
}
|
|
113
139
|
$testMethod(value) {
|
|
114
140
|
return this.$serverCall('$testMethod', [value]);
|
|
@@ -119,17 +145,123 @@ class Employee extends client_1.Entity {
|
|
|
119
145
|
$throwError() {
|
|
120
146
|
return this.$serverCall('$throwError', []);
|
|
121
147
|
}
|
|
148
|
+
$throwHttpError() {
|
|
149
|
+
return this.$serverCall('$throwHttpError', []);
|
|
150
|
+
}
|
|
151
|
+
$throwHttpErrorWithDescription() {
|
|
152
|
+
return this.$serverCall('$throwHttpErrorWithDescription', []);
|
|
153
|
+
}
|
|
122
154
|
static testStatic(value) {
|
|
123
|
-
return
|
|
155
|
+
return this.serverCallStatic('testStatic', [value]);
|
|
156
|
+
}
|
|
157
|
+
static testStaticIterable(value) {
|
|
158
|
+
return this.serverCallStaticIterator('testStaticIterable', [value]);
|
|
159
|
+
}
|
|
160
|
+
static testStaticIterableAbort() {
|
|
161
|
+
return this.serverCallStaticIterator('testStaticIterableAbort', []);
|
|
124
162
|
}
|
|
125
163
|
static throwErrorStatic() {
|
|
126
|
-
return
|
|
164
|
+
return this.serverCallStatic('throwErrorStatic', []);
|
|
165
|
+
}
|
|
166
|
+
static throwErrorStaticIterable() {
|
|
167
|
+
return this.serverCallStaticIterator('throwErrorStaticIterable', []);
|
|
127
168
|
}
|
|
128
169
|
static inaccessibleMethod() {
|
|
129
|
-
return
|
|
170
|
+
return this.serverCallStatic('inaccessibleMethod', []);
|
|
130
171
|
}
|
|
131
172
|
}
|
|
132
173
|
exports.Employee = Employee;
|
|
133
174
|
Employee.class = 'Employee';
|
|
134
|
-
|
|
175
|
+
class RestrictedModel extends nymph_1.Entity {
|
|
176
|
+
static async factory(guid) {
|
|
177
|
+
return (await super.factory(guid));
|
|
178
|
+
}
|
|
179
|
+
static factorySync() {
|
|
180
|
+
return super.factorySync();
|
|
181
|
+
}
|
|
182
|
+
constructor() {
|
|
183
|
+
super();
|
|
184
|
+
this.$data.name = '';
|
|
185
|
+
}
|
|
186
|
+
async $save() {
|
|
187
|
+
const error = new nymph_1.EntityInvalidDataError('Invalid entity data.');
|
|
188
|
+
if (this.$data.name == null || this.$data.name === '') {
|
|
189
|
+
error.addField('name');
|
|
190
|
+
}
|
|
191
|
+
if (error.getFields().length) {
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
return await super.$save();
|
|
195
|
+
}
|
|
196
|
+
$testMethod(value) {
|
|
197
|
+
return value;
|
|
198
|
+
}
|
|
199
|
+
static testStatic(value) {
|
|
200
|
+
return value;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
exports.RestrictedModel = RestrictedModel;
|
|
204
|
+
RestrictedModel.ETYPE = 'restricted';
|
|
205
|
+
RestrictedModel.class = 'Restricted';
|
|
206
|
+
RestrictedModel.restEnabled = false;
|
|
207
|
+
class Restricted extends client_1.Entity {
|
|
208
|
+
constructor() {
|
|
209
|
+
super();
|
|
210
|
+
this.$data.name = '';
|
|
211
|
+
}
|
|
212
|
+
static async factory(guid) {
|
|
213
|
+
return (await super.factory(guid));
|
|
214
|
+
}
|
|
215
|
+
static factorySync() {
|
|
216
|
+
return super.factorySync();
|
|
217
|
+
}
|
|
218
|
+
$testMethod(value) {
|
|
219
|
+
return this.$serverCall('$testMethod', [value]);
|
|
220
|
+
}
|
|
221
|
+
static testStatic(value) {
|
|
222
|
+
return this.serverCallStatic('testStatic', [value]);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
exports.Restricted = Restricted;
|
|
226
|
+
Restricted.class = 'Restricted';
|
|
227
|
+
class PubSubDisabledModel extends nymph_1.Entity {
|
|
228
|
+
static async factory(guid) {
|
|
229
|
+
return (await super.factory(guid));
|
|
230
|
+
}
|
|
231
|
+
static factorySync() {
|
|
232
|
+
return super.factorySync();
|
|
233
|
+
}
|
|
234
|
+
constructor() {
|
|
235
|
+
super();
|
|
236
|
+
this.$data.name = '';
|
|
237
|
+
}
|
|
238
|
+
async $save() {
|
|
239
|
+
const error = new nymph_1.EntityInvalidDataError('Invalid entity data.');
|
|
240
|
+
if (this.$data.name == null || this.$data.name === '') {
|
|
241
|
+
error.addField('name');
|
|
242
|
+
}
|
|
243
|
+
if (error.getFields().length) {
|
|
244
|
+
throw error;
|
|
245
|
+
}
|
|
246
|
+
return await super.$save();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
exports.PubSubDisabledModel = PubSubDisabledModel;
|
|
250
|
+
PubSubDisabledModel.ETYPE = 'pubsub_disabled';
|
|
251
|
+
PubSubDisabledModel.class = 'PubSubDisabled';
|
|
252
|
+
PubSubDisabledModel.pubSubEnabled = false;
|
|
253
|
+
class PubSubDisabled extends client_1.Entity {
|
|
254
|
+
constructor() {
|
|
255
|
+
super();
|
|
256
|
+
this.$data.name = '';
|
|
257
|
+
}
|
|
258
|
+
static async factory(guid) {
|
|
259
|
+
return (await super.factory(guid));
|
|
260
|
+
}
|
|
261
|
+
static factorySync() {
|
|
262
|
+
return super.factorySync();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
exports.PubSubDisabled = PubSubDisabled;
|
|
266
|
+
PubSubDisabled.class = 'PubSubDisabled';
|
|
135
267
|
//# 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;QAChB,OAAO,KAAK,CAAC,WAAW,EAAuC,CAAC;IAClE,CAAC;IAED;QACE,KAAK,EAAE,CAAC;QA1CA,0BAAqB,GAAG;YAChC,sBAAsB;YACtB,aAAa;YACb,aAAa;YACb,iBAAiB;YACjB,gCAAgC;SACjC,CAAC;QAQQ,mBAAc,GAAG,CAAC,UAAU,CAAC,CAAC;QAC9B,mBAAc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I,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;IACvB,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;QAChB,OAAO,KAAK,CAAC,WAAW,EAAyC,CAAC;IACpE,CAAC;;AAlBH,wCAmBC;AAjBe,oBAAK,GAAG,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nymphjs/server",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0-beta.51",
|
|
4
|
+
"description": "Nymph.js - REST Server",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -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.51",
|
|
35
35
|
"cookie-parser": "^1.4.6",
|
|
36
|
-
"express": "^4.18.
|
|
36
|
+
"express": "^4.18.3"
|
|
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.
|
|
43
|
-
"@types/cookie-parser": "^1.4.
|
|
44
|
-
"@types/express": "^4.17.
|
|
45
|
-
"@types/jest": "^29.
|
|
46
|
-
"jest": "^29.
|
|
47
|
-
"ts-jest": "^29.
|
|
48
|
-
"typescript": "^
|
|
39
|
+
"@nymphjs/client": "^1.0.0-beta.51",
|
|
40
|
+
"@nymphjs/client-node": "^1.0.0-beta.51",
|
|
41
|
+
"@nymphjs/driver-sqlite3": "^1.0.0-beta.51",
|
|
42
|
+
"@tsconfig/recommended": "^1.0.3",
|
|
43
|
+
"@types/cookie-parser": "^1.4.7",
|
|
44
|
+
"@types/express": "^4.17.21",
|
|
45
|
+
"@types/jest": "^29.5.12",
|
|
46
|
+
"jest": "^29.7.0",
|
|
47
|
+
"ts-jest": "^29.1.2",
|
|
48
|
+
"typescript": "^5.3.3"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "2e0d0c5470edef84323ce9d176fba6a71b468d18"
|
|
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() {
|
|
@@ -45,7 +48,7 @@ describe('Nymph REST Server and Client with Client Weak Ref Cache', () => {
|
|
|
45
48
|
// @ts-ignore TS doesn't know about WeakRef.
|
|
46
49
|
if (typeof WeakRef === 'undefined') {
|
|
47
50
|
throw new Error(
|
|
48
|
-
'You must run this test in an environment that includes WeakRef.'
|
|
51
|
+
'You must run this test in an environment that includes WeakRef.',
|
|
49
52
|
);
|
|
50
53
|
}
|
|
51
54
|
|
|
@@ -58,7 +61,7 @@ describe('Nymph REST Server and Client with Client Weak Ref Cache', () => {
|
|
|
58
61
|
const checkA = await Employee.factory(employee.guid);
|
|
59
62
|
const checkB = await nymph.getEntity(
|
|
60
63
|
{ class: Employee },
|
|
61
|
-
{ type: '&', guid: employee.guid }
|
|
64
|
+
{ type: '&', guid: employee.guid },
|
|
62
65
|
);
|
|
63
66
|
|
|
64
67
|
if (!checkB) {
|