@nymphjs/server 1.0.0-beta.13 → 1.0.0-beta.130
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 +520 -0
- package/README.md +78 -4
- package/dist/cache.test.js +14 -18
- package/dist/cache.test.js.map +1 -1
- package/dist/createServer.d.ts +12 -0
- package/dist/createServer.js +317 -167
- package/dist/createServer.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +4 -21
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +139 -26
- package/dist/index.test.js.map +1 -1
- package/dist/statusDescriptions.d.ts +3 -0
- package/dist/statusDescriptions.js +4 -4
- package/dist/statusDescriptions.js.map +1 -1
- package/dist/testArtifacts.d.ts +56 -8
- package/dist/testArtifacts.js +160 -74
- package/dist/testArtifacts.js.map +1 -1
- package/jest.config.js +31 -5
- package/package.json +35 -25
- package/src/cache.test.ts +5 -5
- package/src/createServer.ts +370 -184
- package/src/index.test.ts +172 -29
- package/src/index.ts +3 -4
- package/src/testArtifacts.ts +171 -42
- package/tsconfig.json +6 -3
- package/typedoc.json +4 -0
- package/dist/HttpError.d.ts +0 -5
- package/dist/HttpError.js +0 -13
- package/dist/HttpError.js.map +0 -1
- package/src/HttpError.ts +0 -12
package/dist/cache.test.js
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const driver_sqlite3_1 = __importDefault(require("@nymphjs/driver-sqlite3"));
|
|
8
|
-
const nymph_1 = require("@nymphjs/nymph");
|
|
9
|
-
const client_node_1 = require("@nymphjs/client-node");
|
|
10
|
-
const index_1 = __importDefault(require("./index"));
|
|
11
|
-
const testArtifacts_1 = require("./testArtifacts");
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import SQLite3Driver from '@nymphjs/driver-sqlite3';
|
|
3
|
+
import { Nymph as NymphServer } from '@nymphjs/nymph';
|
|
4
|
+
import { Nymph } from '@nymphjs/client';
|
|
5
|
+
import createServer from './index.js';
|
|
6
|
+
import { EmployeeModel as EmployeeModelClass, Employee as EmployeeClass, } from './testArtifacts.js';
|
|
12
7
|
const sqliteConfig = {
|
|
13
8
|
filename: ':memory:',
|
|
14
9
|
};
|
|
15
|
-
const nymphServer = new
|
|
16
|
-
const EmployeeModel = nymphServer.addEntityClass(
|
|
17
|
-
const app = (
|
|
18
|
-
app.use('/test', (
|
|
10
|
+
const nymphServer = new NymphServer({}, new SQLite3Driver(sqliteConfig));
|
|
11
|
+
const EmployeeModel = nymphServer.addEntityClass(EmployeeModelClass);
|
|
12
|
+
const app = express();
|
|
13
|
+
app.use('/test', createServer(nymphServer));
|
|
19
14
|
const server = app.listen(5081);
|
|
20
|
-
const nymph = new
|
|
15
|
+
const nymph = new Nymph({
|
|
21
16
|
restUrl: 'http://localhost:5081/test/',
|
|
22
17
|
weakCache: true,
|
|
23
18
|
});
|
|
24
|
-
const Employee = nymph.addEntityClass(
|
|
19
|
+
const Employee = nymph.addEntityClass(EmployeeClass);
|
|
25
20
|
describe('Nymph REST Server and Client with Client Weak Ref Cache', () => {
|
|
26
21
|
async function createJane() {
|
|
27
22
|
const jane = await Employee.factory();
|
|
@@ -41,6 +36,7 @@ describe('Nymph REST Server and Client with Client Weak Ref Cache', () => {
|
|
|
41
36
|
return jane;
|
|
42
37
|
}
|
|
43
38
|
it('change an entity and check weakCache', async () => {
|
|
39
|
+
// @ts-ignore TS doesn't know about WeakRef.
|
|
44
40
|
if (typeof WeakRef === 'undefined') {
|
|
45
41
|
throw new Error('You must run this test in an environment that includes WeakRef.');
|
|
46
42
|
}
|
|
@@ -58,7 +54,7 @@ describe('Nymph REST Server and Client with Client Weak Ref Cache', () => {
|
|
|
58
54
|
expect(checkB.current).toEqual(false);
|
|
59
55
|
});
|
|
60
56
|
afterAll(() => {
|
|
61
|
-
server.close();
|
|
57
|
+
server.close(); // avoid jest open handle error
|
|
62
58
|
});
|
|
63
59
|
});
|
|
64
60
|
//# sourceMappingURL=cache.test.js.map
|
package/dist/cache.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.test.js","sourceRoot":"","sources":["../src/cache.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cache.test.js","sourceRoot":"","sources":["../src/cache.test.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,YAAY,MAAM,YAAY,CAAC;AACtC,OAAO,EACL,aAAa,IAAI,kBAAkB,EACnC,QAAQ,IAAI,aAAa,GAC1B,MAAM,oBAAoB,CAAC;AAE5B,MAAM,YAAY,GAAG;IACnB,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,EAAE,EAAE,IAAI,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;AACzE,MAAM,aAAa,GAAG,WAAW,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;AAErE,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;AACtB,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAEhC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC;IACtB,OAAO,EAAE,6BAA6B;IACtC,SAAS,EAAE,IAAI;CAChB,CAAC,CAAC;AACH,MAAM,QAAQ,GAAG,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;AAErD,QAAQ,CAAC,yDAAyD,EAAE,GAAG,EAAE;IACvE,KAAK,UAAU,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AK,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"}
|
package/dist/createServer.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import type { OptionsJson } from 'body-parser';
|
|
2
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@port87.com>
|
|
12
|
+
* @copyright SciActive Inc
|
|
13
|
+
* @see http://nymph.io/
|
|
14
|
+
*/
|
|
3
15
|
export declare function createServer(nymph: Nymph, { jsonOptions }?: {
|
|
4
16
|
jsonOptions?: OptionsJson;
|
|
5
17
|
}): import("express-serve-static-core").Express;
|