@nymphjs/server 1.0.0-beta.7 → 1.0.0-beta.71

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 CHANGED
@@ -3,6 +3,287 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-beta.71](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.70...v1.0.0-beta.71) (2024-09-20)
7
+
8
+ **Note:** Version bump only for package @nymphjs/server
9
+
10
+ # [1.0.0-beta.70](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.69...v1.0.0-beta.70) (2024-09-20)
11
+
12
+ **Note:** Version bump only for package @nymphjs/server
13
+
14
+ # [1.0.0-beta.69](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.68...v1.0.0-beta.69) (2024-09-19)
15
+
16
+ **Note:** Version bump only for package @nymphjs/server
17
+
18
+ # [1.0.0-beta.68](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.67...v1.0.0-beta.68) (2024-09-19)
19
+
20
+ **Note:** Version bump only for package @nymphjs/server
21
+
22
+ # [1.0.0-beta.67](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.66...v1.0.0-beta.67) (2024-09-03)
23
+
24
+ **Note:** Version bump only for package @nymphjs/server
25
+
26
+ # [1.0.0-beta.66](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.65...v1.0.0-beta.66) (2024-08-06)
27
+
28
+ **Note:** Version bump only for package @nymphjs/server
29
+
30
+ # [1.0.0-beta.65](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.64...v1.0.0-beta.65) (2024-08-05)
31
+
32
+ **Note:** Version bump only for package @nymphjs/server
33
+
34
+ # [1.0.0-beta.64](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.63...v1.0.0-beta.64) (2024-08-04)
35
+
36
+ **Note:** Version bump only for package @nymphjs/server
37
+
38
+ # [1.0.0-beta.63](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.62...v1.0.0-beta.63) (2024-06-18)
39
+
40
+ ### Bug Fixes
41
+
42
+ - undo ts compilation to module change ([84be6d4](https://github.com/sciactive/nymphjs/commit/84be6d434be29f8afd53907d15be2eb77d1736ce))
43
+
44
+ ### Features
45
+
46
+ - export data iterator ([b86aa19](https://github.com/sciactive/nymphjs/commit/b86aa19fc77d744b5a683046dfb697fc4746df5c))
47
+
48
+ # [1.0.0-beta.62](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.61...v1.0.0-beta.62) (2024-06-15)
49
+
50
+ **Note:** Version bump only for package @nymphjs/server
51
+
52
+ # [1.0.0-beta.61](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.60...v1.0.0-beta.61) (2024-06-14)
53
+
54
+ **Note:** Version bump only for package @nymphjs/server
55
+
56
+ # [1.0.0-beta.60](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.59...v1.0.0-beta.60) (2024-06-14)
57
+
58
+ **Note:** Version bump only for package @nymphjs/server
59
+
60
+ # [1.0.0-beta.59](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.58...v1.0.0-beta.59) (2024-06-14)
61
+
62
+ ### Features
63
+
64
+ - add uniqueness constraint feature, refactor some types ([8133d32](https://github.com/sciactive/nymphjs/commit/8133d32b2c04907182dca2e9171b8217ed1b57e4))
65
+
66
+ # [1.0.0-beta.58](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.57...v1.0.0-beta.58) (2024-06-12)
67
+
68
+ **Note:** Version bump only for package @nymphjs/server
69
+
70
+ # [1.0.0-beta.57](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.56...v1.0.0-beta.57) (2024-06-12)
71
+
72
+ **Note:** Version bump only for package @nymphjs/server
73
+
74
+ # [1.0.0-beta.56](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.55...v1.0.0-beta.56) (2024-06-11)
75
+
76
+ ### Features
77
+
78
+ - allow connections where tokens are not renewed ([39071a5](https://github.com/sciactive/nymphjs/commit/39071a545644075190bd8213be25e0a0c46d2b5d))
79
+
80
+ # [1.0.0-beta.55](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.54...v1.0.0-beta.55) (2024-05-26)
81
+
82
+ **Note:** Version bump only for package @nymphjs/server
83
+
84
+ # [1.0.0-beta.54](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.53...v1.0.0-beta.54) (2024-05-26)
85
+
86
+ **Note:** Version bump only for package @nymphjs/server
87
+
88
+ # [1.0.0-beta.53](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.52...v1.0.0-beta.53) (2024-05-26)
89
+
90
+ **Note:** Version bump only for package @nymphjs/server
91
+
92
+ # [1.0.0-beta.52](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.51...v1.0.0-beta.52) (2024-05-25)
93
+
94
+ **Note:** Version bump only for package @nymphjs/server
95
+
96
+ # [1.0.0-beta.51](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.50...v1.0.0-beta.51) (2024-04-12)
97
+
98
+ **Note:** Version bump only for package @nymphjs/server
99
+
100
+ # [1.0.0-beta.50](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.49...v1.0.0-beta.50) (2024-04-08)
101
+
102
+ **Note:** Version bump only for package @nymphjs/server
103
+
104
+ # [1.0.0-beta.49](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.48...v1.0.0-beta.49) (2024-03-04)
105
+
106
+ **Note:** Version bump only for package @nymphjs/server
107
+
108
+ # [1.0.0-beta.48](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.47...v1.0.0-beta.48) (2023-11-10)
109
+
110
+ **Note:** Version bump only for package @nymphjs/server
111
+
112
+ # [1.0.0-beta.47](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.46...v1.0.0-beta.47) (2023-11-10)
113
+
114
+ **Note:** Version bump only for package @nymphjs/server
115
+
116
+ # [1.0.0-beta.46](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.45...v1.0.0-beta.46) (2023-08-29)
117
+
118
+ **Note:** Version bump only for package @nymphjs/server
119
+
120
+ # [1.0.0-beta.45](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.44...v1.0.0-beta.45) (2023-07-17)
121
+
122
+ **Note:** Version bump only for package @nymphjs/server
123
+
124
+ # [1.0.0-beta.44](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.43...v1.0.0-beta.44) (2023-07-13)
125
+
126
+ **Note:** Version bump only for package @nymphjs/server
127
+
128
+ # [1.0.0-beta.43](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.42...v1.0.0-beta.43) (2023-07-12)
129
+
130
+ **Note:** Version bump only for package @nymphjs/server
131
+
132
+ # [1.0.0-beta.42](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.41...v1.0.0-beta.42) (2023-07-12)
133
+
134
+ **Note:** Version bump only for package @nymphjs/server
135
+
136
+ # [1.0.0-beta.41](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.40...v1.0.0-beta.41) (2023-07-12)
137
+
138
+ ### Features
139
+
140
+ - remove synchronous database queries ([b579fb2](https://github.com/sciactive/nymphjs/commit/b579fb2eacd96cdd1b386a62c5c00cdbb2438f6e))
141
+ - rewrite server side async api to match client side api ([9c537a8](https://github.com/sciactive/nymphjs/commit/9c537a8be49e9b989af0822a4c2236e8c2d20f87))
142
+
143
+ # [1.0.0-beta.40](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.39...v1.0.0-beta.40) (2023-07-10)
144
+
145
+ **Note:** Version bump only for package @nymphjs/server
146
+
147
+ # [1.0.0-beta.39](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.38...v1.0.0-beta.39) (2023-07-09)
148
+
149
+ **Note:** Version bump only for package @nymphjs/server
150
+
151
+ # [1.0.0-beta.38](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.37...v1.0.0-beta.38) (2023-07-09)
152
+
153
+ **Note:** Version bump only for package @nymphjs/server
154
+
155
+ # [1.0.0-beta.37](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.36...v1.0.0-beta.37) (2023-07-09)
156
+
157
+ **Note:** Version bump only for package @nymphjs/server
158
+
159
+ # [1.0.0-beta.36](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.35...v1.0.0-beta.36) (2023-07-09)
160
+
161
+ **Note:** Version bump only for package @nymphjs/server
162
+
163
+ # [1.0.0-beta.35](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.34...v1.0.0-beta.35) (2023-06-14)
164
+
165
+ ### Features
166
+
167
+ - add iteratable server call support using event streams ([fa7c1ec](https://github.com/sciactive/nymphjs/commit/fa7c1ec869e1fb52db20c8245e98a681f73dbf83))
168
+
169
+ # [1.0.0-beta.34](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.33...v1.0.0-beta.34) (2023-05-13)
170
+
171
+ **Note:** Version bump only for package @nymphjs/server
172
+
173
+ # [1.0.0-beta.33](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.32...v1.0.0-beta.33) (2023-05-13)
174
+
175
+ **Note:** Version bump only for package @nymphjs/server
176
+
177
+ # [1.0.0-beta.32](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.31...v1.0.0-beta.32) (2023-05-13)
178
+
179
+ **Note:** Version bump only for package @nymphjs/server
180
+
181
+ # [1.0.0-beta.31](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.30...v1.0.0-beta.31) (2023-05-12)
182
+
183
+ **Note:** Version bump only for package @nymphjs/server
184
+
185
+ # [1.0.0-beta.30](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.29...v1.0.0-beta.30) (2023-05-12)
186
+
187
+ **Note:** Version bump only for package @nymphjs/server
188
+
189
+ # [1.0.0-beta.29](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.28...v1.0.0-beta.29) (2023-05-08)
190
+
191
+ **Note:** Version bump only for package @nymphjs/server
192
+
193
+ # [1.0.0-beta.28](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.27...v1.0.0-beta.28) (2023-05-05)
194
+
195
+ **Note:** Version bump only for package @nymphjs/server
196
+
197
+ # [1.0.0-beta.27](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.26...v1.0.0-beta.27) (2023-05-04)
198
+
199
+ **Note:** Version bump only for package @nymphjs/server
200
+
201
+ # [1.0.0-beta.26](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.25...v1.0.0-beta.26) (2023-05-04)
202
+
203
+ **Note:** Version bump only for package @nymphjs/server
204
+
205
+ # [1.0.0-beta.25](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.24...v1.0.0-beta.25) (2023-05-04)
206
+
207
+ ### Features
208
+
209
+ - add flags to disable rest and pubsub support on an entity class ([52106a3](https://github.com/sciactive/nymphjs/commit/52106a3d44065bcfec40d361344bf1eba59a5136)), closes [#1](https://github.com/sciactive/nymphjs/issues/1)
210
+
211
+ # [1.0.0-beta.24](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.23...v1.0.0-beta.24) (2023-05-02)
212
+
213
+ **Note:** Version bump only for package @nymphjs/server
214
+
215
+ # [1.0.0-beta.23](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.22...v1.0.0-beta.23) (2023-05-02)
216
+
217
+ **Note:** Version bump only for package @nymphjs/server
218
+
219
+ # [1.0.0-beta.22](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.21...v1.0.0-beta.22) (2023-05-01)
220
+
221
+ **Note:** Version bump only for package @nymphjs/server
222
+
223
+ # [1.0.0-beta.21](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.20...v1.0.0-beta.21) (2023-05-01)
224
+
225
+ **Note:** Version bump only for package @nymphjs/server
226
+
227
+ # [1.0.0-beta.20](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.19...v1.0.0-beta.20) (2023-04-30)
228
+
229
+ **Note:** Version bump only for package @nymphjs/server
230
+
231
+ # [1.0.0-beta.19](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.18...v1.0.0-beta.19) (2023-04-29)
232
+
233
+ **Note:** Version bump only for package @nymphjs/server
234
+
235
+ # [1.0.0-beta.18](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.17...v1.0.0-beta.18) (2023-04-27)
236
+
237
+ **Note:** Version bump only for package @nymphjs/server
238
+
239
+ # [1.0.0-beta.17](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.16...v1.0.0-beta.17) (2023-04-24)
240
+
241
+ **Note:** Version bump only for package @nymphjs/server
242
+
243
+ # [1.0.0-beta.16](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.15...v1.0.0-beta.16) (2023-03-31)
244
+
245
+ ### Features
246
+
247
+ - add ability to tell tilmeld to log in a specific user during authentication ([922e145](https://github.com/sciactive/nymphjs/commit/922e1452adae44bed2aa9655be16e19796acb39b))
248
+
249
+ # [1.0.0-beta.15](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.14...v1.0.0-beta.15) (2023-03-23)
250
+
251
+ **Note:** Version bump only for package @nymphjs/server
252
+
253
+ # [1.0.0-beta.14](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.13...v1.0.0-beta.14) (2023-03-17)
254
+
255
+ **Note:** Version bump only for package @nymphjs/server
256
+
257
+ # [1.0.0-beta.13](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.12...v1.0.0-beta.13) (2023-03-16)
258
+
259
+ **Note:** Version bump only for package @nymphjs/server
260
+
261
+ # [1.0.0-beta.12](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.11...v1.0.0-beta.12) (2023-03-04)
262
+
263
+ ### Bug Fixes
264
+
265
+ - make sure all default exports are also named exports ([06da9a6](https://github.com/sciactive/nymphjs/commit/06da9a61d444860f70b7f5b95b824547d9880500))
266
+
267
+ # [1.0.0-beta.11](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.10...v1.0.0-beta.11) (2023-02-27)
268
+
269
+ ### Features
270
+
271
+ - allow customizing HTTP status codes in response from server called methods ([8c5c3d4](https://github.com/sciactive/nymphjs/commit/8c5c3d4af741edabc1a8947aaebf026ba546c46a))
272
+
273
+ # [1.0.0-beta.10](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.9...v1.0.0-beta.10) (2023-01-19)
274
+
275
+ **Note:** Version bump only for package @nymphjs/server
276
+
277
+ # [1.0.0-beta.9](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.8...v1.0.0-beta.9) (2023-01-09)
278
+
279
+ **Note:** Version bump only for package @nymphjs/server
280
+
281
+ # [1.0.0-beta.8](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2023-01-09)
282
+
283
+ ### Features
284
+
285
+ - make entities in nymph client instance specific too ([1029f06](https://github.com/sciactive/nymphjs/commit/1029f061a1ad193e4a8a2dab0186b9a4b517f646))
286
+
6
287
  # [1.0.0-beta.7](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2023-01-05)
7
288
 
8
289
  **Note:** Version bump only for package @nymphjs/server
package/README.md CHANGED
@@ -21,16 +21,16 @@ import SQLite3Driver from '@nymphjs/driver-sqlite3';
21
21
  import createServer from '@nymphjs/server';
22
22
 
23
23
  // Import all the entities you will be using on the server.
24
- import MyEntity from './entities/MyEntity';
24
+ import MyEntityClass from './entities/MyEntity';
25
25
 
26
26
  // Configure Nymph.
27
27
  const nymph = new Nymph(
28
28
  {},
29
29
  new SQLite3Driver({
30
30
  filename: ':memory:',
31
- })
31
+ }),
32
32
  );
33
- nymph.addEntityClass(MyEntity);
33
+ const MyEntity = nymph.addEntityClass(MyEntityClass);
34
34
 
35
35
  // Create your Express app.
36
36
  const app = express();
@@ -46,19 +46,91 @@ app.listen(80);
46
46
 
47
47
  You will need to import any entities you use on the server, so they are available to Nymph.
48
48
 
49
- Now you can configure your client using your server's address (and the optional path, if set).
49
+ Now you can configure your **client**, using your server's address (and the optional path, if set).
50
50
 
51
51
  ```ts
52
52
  import { Nymph } from '@nymphjs/client';
53
53
 
54
- import MyEntity from './entities/MyEntityClient';
54
+ import MyEntityClass from './entities/MyEntityClient';
55
55
 
56
56
  const nymph = new Nymph({
57
57
  // You should configure your Express server to
58
58
  // use HTTPS, but you don't have to.
59
59
  restUrl: 'https://mydomain.tld/rest',
60
60
  });
61
- nymph.addEntityClass(MyEntity);
61
+ const MyEntity = nymph.addEntityClass(MyEntityClass);
62
+ ```
63
+
64
+ The REST server will authenticate for you using the Tilmeld auth cookie and XSRF token, but if you need to, you can authenticate in some other way (like OAuth2), and place the user in `response.locals.user`.
65
+
66
+ ```ts
67
+ import express from 'express';
68
+ import { Nymph } from '@nymphjs/nymph';
69
+ import SQLite3Driver from '@nymphjs/driver-sqlite3';
70
+ import { Tilmeld } from '@nymphjs/tilmeld';
71
+ import createServer from '@nymphjs/server';
72
+ import setup from '@nymphjs/tilmeld-setup';
73
+
74
+ // Import all the entities you will be using on the server.
75
+ import MyEntityClass from './entities/MyEntity';
76
+
77
+ // Consfigure Tilmeld.
78
+ const tilmeld = new Tilmeld({
79
+ appName: 'My Awesome App',
80
+ appUrl: 'https://mydomain.tld',
81
+ setupPath: '/user',
82
+ });
83
+
84
+ // Configure Nymph.
85
+ const nymph = new Nymph(
86
+ {},
87
+ new SQLite3Driver({
88
+ filename: ':memory:',
89
+ }),
90
+ tilmeld,
91
+ );
92
+ const MyEntity = nymph.addEntityClass(MyEntityClass);
93
+
94
+ // Create your Express app.
95
+ const app = express();
96
+
97
+ // Authenticate the user manually.
98
+ app.use('/rest', async (request, response, next) => {
99
+ const { User } = tilmeld;
100
+
101
+ try {
102
+ // Somehow authenticate the user...
103
+ const user = await User.factoryUsername(username);
104
+
105
+ if (user.guid != null && user.enabled) {
106
+ response.locals.user = user;
107
+ }
108
+
109
+ next();
110
+ } catch (e: any) {
111
+ response.status(500);
112
+ response.send('Internal server error.');
113
+ }
114
+ });
115
+
116
+ // Create and use the REST server (with an optional path).
117
+ app.use('/rest', createServer(nymph));
118
+
119
+ // Create Tilmeld setup app.
120
+ app.user(
121
+ '/user',
122
+ setup(
123
+ {
124
+ restUrl: 'https://mydomain.tld/rest',
125
+ },
126
+ nymph,
127
+ ),
128
+ );
129
+
130
+ // Do anything else you need to do...
131
+
132
+ // Start your server.
133
+ app.listen(80);
62
134
  ```
63
135
 
64
136
  # License
@@ -0,0 +1,5 @@
1
+ export declare class HttpError extends Error {
2
+ status?: number;
3
+ statusText?: string;
4
+ constructor(message: string, status?: number, statusText?: string);
5
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpError = void 0;
4
+ class HttpError extends Error {
5
+ status;
6
+ statusText;
7
+ constructor(message, status, statusText) {
8
+ super(message);
9
+ this.name = 'HttpError';
10
+ this.status = status;
11
+ this.statusText = statusText;
12
+ }
13
+ }
14
+ exports.HttpError = HttpError;
15
+ //# sourceMappingURL=HttpError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpError.js","sourceRoot":"","sources":["../src/HttpError.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAU,SAAQ,KAAK;IAClC,MAAM,CAAU;IAChB,UAAU,CAAU;IAEpB,YAAY,OAAe,EAAE,MAAe,EAAE,UAAmB;QAC/D,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAXD,8BAWC"}
@@ -13,7 +13,7 @@ const sqliteConfig = {
13
13
  filename: ':memory:',
14
14
  };
15
15
  const nymphServer = new nymph_1.Nymph({}, new driver_sqlite3_1.default(sqliteConfig));
16
- nymphServer.addEntityClass(testArtifacts_1.EmployeeModel);
16
+ const EmployeeModel = nymphServer.addEntityClass(testArtifacts_1.EmployeeModel);
17
17
  const app = (0, express_1.default)();
18
18
  app.use('/test', (0, index_1.default)(nymphServer));
19
19
  const server = app.listen(5081);
@@ -21,10 +21,10 @@ const nymph = new client_node_1.Nymph({
21
21
  restUrl: 'http://localhost:5081/test/',
22
22
  weakCache: true,
23
23
  });
24
- nymph.addEntityClass(testArtifacts_1.Employee);
24
+ const Employee = nymph.addEntityClass(testArtifacts_1.Employee);
25
25
  describe('Nymph REST Server and Client with Client Weak Ref Cache', () => {
26
26
  async function createJane() {
27
- const jane = await testArtifacts_1.Employee.factory();
27
+ const jane = await Employee.factory();
28
28
  jane.name = 'Jane Doe';
29
29
  jane.current = true;
30
30
  jane.salary = 8000000;
@@ -41,6 +41,7 @@ describe('Nymph REST Server and Client with Client Weak Ref Cache', () => {
41
41
  return jane;
42
42
  }
43
43
  it('change an entity and check weakCache', async () => {
44
+ // @ts-ignore TS doesn't know about WeakRef.
44
45
  if (typeof WeakRef === 'undefined') {
45
46
  throw new Error('You must run this test in an environment that includes WeakRef.');
46
47
  }
@@ -48,8 +49,8 @@ describe('Nymph REST Server and Client with Client Weak Ref Cache', () => {
48
49
  if (employee.guid == null) {
49
50
  throw new Error('Entity is null.');
50
51
  }
51
- const checkA = await testArtifacts_1.Employee.factory(employee.guid);
52
- const checkB = await nymph.getEntity({ class: testArtifacts_1.Employee }, { type: '&', guid: employee.guid });
52
+ const checkA = await Employee.factory(employee.guid);
53
+ const checkB = await nymph.getEntity({ class: Employee }, { type: '&', guid: employee.guid });
53
54
  if (!checkB) {
54
55
  throw new Error("Couldn't fetch entity.");
55
56
  }
@@ -58,7 +59,7 @@ describe('Nymph REST Server and Client with Client Weak Ref Cache', () => {
58
59
  expect(checkB.current).toEqual(false);
59
60
  });
60
61
  afterAll(() => {
61
- server.close();
62
+ server.close(); // avoid jest open handle error
62
63
  });
63
64
  });
64
65
  //# sourceMappingURL=cache.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cache.test.js","sourceRoot":"","sources":["../src/cache.test.ts"],"names":[],"mappings":";;;;;AAAA,sDAA8B;AAC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AK,IAAI,EAAE;QACpD,4CAA4C;QAC5C,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,UAAU,EAAE,CAAC;QAEpC,IAAI,QAAQ,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACrC,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,SAAS,CAClC,EAAE,KAAK,EAAE,QAAQ,EAAE,EACnB,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CACnC,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;QAEzB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAG,EAAE;QACZ,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,+BAA+B;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { OptionsJson } from 'body-parser';
2
+ import { Nymph } from '@nymphjs/nymph';
3
+ export declare class ForbiddenClassError extends Error {
4
+ constructor(message: string);
5
+ }
6
+ /**
7
+ * A REST server middleware creator for Nymph.
8
+ *
9
+ * Written by Hunter Perrin for SciActive.
10
+ *
11
+ * @author Hunter Perrin <hperrin@gmail.com>
12
+ * @copyright SciActive Inc
13
+ * @see http://nymph.io/
14
+ */
15
+ export declare function createServer(nymph: Nymph, { jsonOptions }?: {
16
+ jsonOptions?: OptionsJson;
17
+ }): import("express-serve-static-core").Express;