@nymphjs/server 1.0.0-beta.1 → 1.0.0-beta.100

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/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nymphjs/server",
3
- "version": "1.0.0-beta.1",
4
- "description": "NymphJS - REST Server",
5
- "type": "commonjs",
3
+ "version": "1.0.0-beta.100",
4
+ "description": "Nymph.js - REST Server",
5
+ "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "keywords": [
@@ -14,9 +14,9 @@
14
14
  "clean": "test -d dist && rm -r dist || true",
15
15
  "build": "tsc",
16
16
  "watch": "tsc --watch",
17
- "prepare": "npm run clean && npm run build",
18
- "test": "jest",
19
- "test:watch": "jest --watch"
17
+ "prepublish": "npm run clean && npm run build",
18
+ "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest",
19
+ "test:watch": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --watch"
20
20
  },
21
21
  "publishConfig": {
22
22
  "access": "public"
@@ -31,21 +31,21 @@
31
31
  },
32
32
  "license": "Apache-2.0",
33
33
  "dependencies": {
34
- "@nymphjs/nymph": "^1.0.0-beta.1",
35
- "cookie-parser": "^1.4.6",
36
- "express": "^4.18.2"
34
+ "@nymphjs/nymph": "^1.0.0-beta.100",
35
+ "cookie-parser": "^1.4.7",
36
+ "express": "^4.21.2"
37
37
  },
38
38
  "devDependencies": {
39
- "@nymphjs/client": "^1.0.0-beta.1",
40
- "@nymphjs/client-node": "^1.0.0-beta.1",
41
- "@nymphjs/driver-sqlite3": "^1.0.0-beta.1",
42
- "@tsconfig/recommended": "^1.0.1",
43
- "@types/cookie-parser": "^1.4.3",
44
- "@types/express": "^4.17.14",
45
- "@types/jest": "^29.2.3",
46
- "jest": "^29.3.1",
47
- "ts-jest": "^29.0.3",
48
- "typescript": "^4.9.3"
39
+ "@nymphjs/client": "^1.0.0-beta.100",
40
+ "@nymphjs/driver-sqlite3": "^1.0.0-beta.100",
41
+ "@tsconfig/recommended": "^1.0.8",
42
+ "@types/cookie-parser": "^1.4.8",
43
+ "@types/express": "^5.0.0",
44
+ "@types/jest": "^29.5.14",
45
+ "jest": "^29.7.0",
46
+ "ts-jest": "^29.2.5",
47
+ "ts-node": "^10.9.2",
48
+ "typescript": "^5.7.2"
49
49
  },
50
- "gitHead": "648d901c504d57f2d439cd751b60af0ebd4d63b8"
50
+ "gitHead": "254b2ccd1cc7838dcbf08e860d2833475a15b244"
51
51
  }
@@ -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
@@ -1,17 +1,20 @@
1
1
  import express from 'express';
2
2
  import SQLite3Driver from '@nymphjs/driver-sqlite3';
3
3
  import { Nymph as NymphServer } from '@nymphjs/nymph';
4
- import { Nymph } from '@nymphjs/client-node';
4
+ import { Nymph } from '@nymphjs/client';
5
5
 
6
- import createServer from './index';
7
- import { EmployeeModel, Employee } from './testArtifacts';
6
+ import createServer from './index.js';
7
+ import {
8
+ EmployeeModel as EmployeeModelClass,
9
+ Employee as EmployeeClass,
10
+ } from './testArtifacts.js';
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(EmployeeModel);
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(Employee);
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) {