@goldstack/utils-aws-http-api-local 0.1.28 → 0.1.31

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@goldstack/utils-aws-http-api-local",
3
- "version": "0.1.28",
3
+ "version": "0.1.31",
4
4
  "description": "Starts a local AWS HTTP API for testing",
5
5
  "keywords": [
6
6
  "goldstack",
@@ -36,34 +36,34 @@
36
36
  "compile": "tsc -p tsconfig.json",
37
37
  "compile-watch": "tsc -p tsconfig.json --watch",
38
38
  "compile-watch:light": "nodemon --watch ./src/ -e '*' --exec 'yarn compile'",
39
- "coverage": "jest --collect-coverage --passWithNoTests --config=./jest.config.js",
39
+ "coverage": "jest --collect-coverage --passWithNoTests --config=./jest.config.js --runInBand",
40
40
  "prepublishOnly": "yarn run build",
41
41
  "publish": "utils-git changed --exec \"yarn npm publish $@\"",
42
- "test-ci": "jest --passWithNoTests --config=./jest.config.js",
43
- "test-watch": "jest --watch --passWithNoTests --config=./jest.config.js",
42
+ "test-ci": "jest --passWithNoTests --config=./jest.config.js --runInBand",
43
+ "test-watch": "jest --watch --passWithNoTests --config=./jest.config.js --runInBand",
44
44
  "version:apply": "utils-git changed --exec \"yarn version $@ && yarn version apply\"",
45
45
  "version:apply:force": "yarn version $@ && yarn version apply"
46
46
  },
47
47
  "dependencies": {
48
- "@goldstack/utils-aws-lambda": "0.1.26",
48
+ "@goldstack/utils-aws-lambda": "0.1.29",
49
49
  "@types/aws-lambda": "^8.10.88",
50
50
  "cookie": "^0.4.1",
51
51
  "cors": "^2.8.5",
52
52
  "express": "^4.17.1"
53
53
  },
54
54
  "devDependencies": {
55
- "@goldstack/utils-git": "0.1.32",
55
+ "@goldstack/utils-git": "0.1.35",
56
56
  "@types/cookie": "^0",
57
57
  "@types/express": "^4.17.13",
58
- "@types/jest": "^27.4.1",
59
- "@types/node": "^16.11.0",
58
+ "@types/jest": "^27.5.1",
59
+ "@types/node": "^17.0.33",
60
60
  "@types/node-fetch": "2",
61
61
  "find-free-port": "^2.0.0",
62
- "jest": "^27.5.1",
62
+ "jest": "^28.1.0",
63
63
  "node-fetch": "2.6.7",
64
64
  "rimraf": "^3.0.2",
65
- "ts-jest": "^27.1.4",
66
- "typescript": "^4.4.3"
65
+ "ts-jest": "^28.0.2",
66
+ "typescript": "^4.6.4"
67
67
  },
68
68
  "publishConfig": {
69
69
  "main": "dist/src/utilsAwsHttpApiLocal.js"
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=expressRoutes.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expressRoutes.spec.d.ts","sourceRoot":"","sources":["../../src/expressRoutes.spec.ts"],"names":[],"mappings":""}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const expressRoutes_1 = require("./expressRoutes");
4
- describe('Should create express routes correctly', () => {
5
- it('Should deal with parameters', () => {
6
- expect((0, expressRoutes_1.gatewayRouteToExpressPath)('/hello/{param1}')).toEqual('/hello/:param1');
7
- expect((0, expressRoutes_1.gatewayRouteToExpressPath)('/hello/{param1}/furtherpath')).toEqual('/hello/:param1/furtherpath');
8
- expect((0, expressRoutes_1.gatewayRouteToExpressPath)('/hello/{greedy+}')).toEqual('/hello/:greedy*');
9
- });
10
- });
11
- //# sourceMappingURL=expressRoutes.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expressRoutes.spec.js","sourceRoot":"","sources":["../../src/expressRoutes.spec.ts"],"names":[],"mappings":";;AAAA,mDAA4D;AAE5D,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;IACtD,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,CAAC,IAAA,yCAAyB,EAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAC1D,gBAAgB,CACjB,CAAC;QACF,MAAM,CAAC,IAAA,yCAAyB,EAAC,6BAA6B,CAAC,CAAC,CAAC,OAAO,CACtE,4BAA4B,CAC7B,CAAC;QACF,MAAM,CAAC,IAAA,yCAAyB,EAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAC3D,iBAAiB,CAClB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=utilsAwsHttpApiLocal.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utilsAwsHttpApiLocal.spec.d.ts","sourceRoot":"","sources":["../../src/utilsAwsHttpApiLocal.spec.ts"],"names":[],"mappings":""}
@@ -1,86 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const find_free_port_1 = __importDefault(require("find-free-port"));
7
- const node_fetch_1 = __importDefault(require("node-fetch"));
8
- const utilsAwsHttpApiLocal_1 = require("./utilsAwsHttpApiLocal");
9
- describe('Should create API', () => {
10
- let port = undefined;
11
- let server = undefined;
12
- beforeAll(async () => {
13
- port = await new Promise((resolve, reject) => {
14
- (0, find_free_port_1.default)(50141, (err, p1) => {
15
- if (err) {
16
- reject(err);
17
- return;
18
- }
19
- resolve(p1);
20
- });
21
- });
22
- server = await (0, utilsAwsHttpApiLocal_1.startServer)({
23
- port: `${port}`,
24
- routesDir: './testData/routes',
25
- });
26
- });
27
- test('Should receive response and support parameters', async () => {
28
- const res = await (0, node_fetch_1.default)(`http://localhost:${port}/echo?message=abc`);
29
- expect(await res.text()).toContain('abc');
30
- });
31
- test('Should support non-success status codes and empty body', async () => {
32
- const res = await (0, node_fetch_1.default)(`http://localhost:${port}/keepOut`);
33
- expect(res.status).toEqual(401);
34
- expect(res.bodyUsed).toBeFalsy();
35
- });
36
- test('Should support fallback', async () => {
37
- const res = await (0, node_fetch_1.default)(`http://localhost:${port}/unknownEndpoint`);
38
- expect(await res.text()).toContain('Unknown endpoint');
39
- });
40
- test('Should support path parameters', async () => {
41
- const res = await (0, node_fetch_1.default)(`http://localhost:${port}/cart/123456/items`);
42
- expect(await res.text()).toContain('cart [123456]');
43
- });
44
- test('Should support path parameters at end of path', async () => {
45
- const res = await (0, node_fetch_1.default)(`http://localhost:${port}/order/abcd`);
46
- const response = await res.json();
47
- expect(response.message).toContain('order [abcd]');
48
- });
49
- test('Should support index', async () => {
50
- const res = await (0, node_fetch_1.default)(`http://localhost:${port}/userRepo`);
51
- expect(await res.json()).toHaveProperty('users');
52
- });
53
- test('Should support greedy paths', async () => {
54
- const res = await (0, node_fetch_1.default)(`http://localhost:${port}/admin/my/nested/path`);
55
- const response = await res.json();
56
- expect(response.message).toContain('[my/nested/path]');
57
- });
58
- test('Should support greedy paths', async () => {
59
- const res = await (0, node_fetch_1.default)(`http://localhost:${port}/admin/short`);
60
- const response = await res.json();
61
- expect(response.message).toContain('[short]');
62
- });
63
- test('Should not match root for greedy paths', async () => {
64
- const res = await (0, node_fetch_1.default)(`http://localhost:${port}/admin`);
65
- const response = await res.json();
66
- expect(response.message).toContain('Unknown endpoint');
67
- });
68
- test('Should pass request body', async () => {
69
- const res = await (0, node_fetch_1.default)(`http://localhost:${port}/echoBody`, {
70
- method: 'post',
71
- body: JSON.stringify({ message: 'The body.' }),
72
- headers: { 'Content-Type': 'application/json' },
73
- });
74
- expect(await res.text()).toContain('The body.');
75
- });
76
- test('Should return headers', async () => {
77
- const res = await (0, node_fetch_1.default)(`http://localhost:${port}/echoBody`);
78
- expect(await res.headers.get('location')).toContain('/echoBody');
79
- });
80
- afterAll(async () => {
81
- if (server) {
82
- await server.shutdown();
83
- }
84
- });
85
- });
86
- //# sourceMappingURL=utilsAwsHttpApiLocal.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utilsAwsHttpApiLocal.spec.js","sourceRoot":"","sources":["../../src/utilsAwsHttpApiLocal.spec.ts"],"names":[],"mappings":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