@nu-art/thunderstorm-backend 0.400.14 → 0.401.1
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.
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Module } from '@nu-art/ts-common/core/module';
|
|
2
2
|
import { ServerApi } from './server/server-api.js';
|
|
3
|
-
|
|
4
|
-
export declare class ModuleBE_APIs_Class extends Module implements TestResetListener {
|
|
3
|
+
export declare class ModuleBE_APIs_Class extends Module {
|
|
5
4
|
private readonly routes;
|
|
6
|
-
|
|
5
|
+
destroy(): Promise<void>;
|
|
7
6
|
addRoutes: (apis: ServerApi<any>[]) => void;
|
|
8
7
|
useRoutes: () => ServerApi<any>[];
|
|
9
8
|
}
|
package/modules/ModuleBE_APIs.js
CHANGED
|
@@ -2,8 +2,8 @@ import { Module } from '@nu-art/ts-common/core/module';
|
|
|
2
2
|
import { MUSTNeverHappenException } from '@nu-art/ts-common';
|
|
3
3
|
export class ModuleBE_APIs_Class extends Module {
|
|
4
4
|
routes = [];
|
|
5
|
-
async
|
|
6
|
-
this.logWarning('
|
|
5
|
+
async destroy() {
|
|
6
|
+
this.logWarning('destroy');
|
|
7
7
|
this.routes.length = 0;
|
|
8
8
|
}
|
|
9
9
|
addRoutes = (apis) => {
|
|
@@ -92,8 +92,17 @@ export class HttpServer_Class extends Module {
|
|
|
92
92
|
next();
|
|
93
93
|
});
|
|
94
94
|
const parserLimit = this.config.bodyParserLimit;
|
|
95
|
-
if (parserLimit)
|
|
96
|
-
|
|
95
|
+
if (parserLimit) {
|
|
96
|
+
const jsonParser = express.json({ limit: parserLimit, type: 'application/json' });
|
|
97
|
+
this.getExpress().use((req, res, next) => {
|
|
98
|
+
// If upstream already set a body OR the stream is already consumed, skip parsing.
|
|
99
|
+
const alreadyHasBody = req.body !== undefined;
|
|
100
|
+
const notReadable = !req.readable;
|
|
101
|
+
if (alreadyHasBody || notReadable)
|
|
102
|
+
return next();
|
|
103
|
+
return jsonParser(req, res, next);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
97
106
|
this.getExpress().use(compression());
|
|
98
107
|
for (const middleware of HttpServer_Class.expressMiddleware) {
|
|
99
108
|
this.getExpress().use(middleware);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/thunderstorm-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.401.1",
|
|
4
4
|
"description": "Thunderstorm Backend",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"TacB0sS",
|
|
@@ -37,11 +37,12 @@
|
|
|
37
37
|
"linkDirectory": true
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@nu-art/thunderstorm-shared": "0.
|
|
41
|
-
"@nu-art/firebase-backend": "0.
|
|
42
|
-
"@nu-art/firebase-shared": "0.
|
|
43
|
-
"@nu-art/google-services-backend": "0.
|
|
44
|
-
"@nu-art/
|
|
40
|
+
"@nu-art/thunderstorm-shared": "0.401.1",
|
|
41
|
+
"@nu-art/firebase-backend": "0.401.1",
|
|
42
|
+
"@nu-art/firebase-shared": "0.401.1",
|
|
43
|
+
"@nu-art/google-services-backend": "0.401.1",
|
|
44
|
+
"@nu-art/testalot": "0.401.1",
|
|
45
|
+
"@nu-art/ts-common": "0.401.1",
|
|
45
46
|
"abort-controller": "^3.0.0",
|
|
46
47
|
"axios": "^1.13.1",
|
|
47
48
|
"body-parser": "^1.19.0",
|
package/test/StormTest.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncVoidFunction, Module, RecursiveObjectOfPrimitives } from '@nu-art/ts-common';
|
|
2
|
-
import { TestModel } from '@nu-art/
|
|
2
|
+
import { TestModel } from '@nu-art/testalot';
|
|
3
3
|
type StormTestConfig = {
|
|
4
4
|
databaseName?: string;
|
|
5
5
|
modules: Module[];
|
|
@@ -17,7 +17,7 @@ export declare class StormTest {
|
|
|
17
17
|
private testConfig;
|
|
18
18
|
constructor(config: StormTestConfig);
|
|
19
19
|
init(): Promise<this>;
|
|
20
|
-
|
|
20
|
+
destroy(): Promise<void>;
|
|
21
21
|
}
|
|
22
22
|
export declare const stormTester: <TestCase extends TestModel<any, any>>(stormTestInput: StormTestInput, testCaseRunner: () => Promise<void>) => Promise<void>;
|
|
23
23
|
export {};
|
package/test/StormTest.js
CHANGED
|
@@ -3,7 +3,6 @@ import { FIREBASE_DEFAULT_PROJECT_ID } from '@nu-art/firebase-backend';
|
|
|
3
3
|
import { RouteResolver_Dummy } from '../modules/server/route-resolvers/RouteResolver_Dummy.js';
|
|
4
4
|
import { Storm } from '../core/Storm.js';
|
|
5
5
|
import { ModuleBE_Auth } from '@nu-art/google-services-backend';
|
|
6
|
-
import { dispatcher_resetTests } from '@nu-art/ts-common/testing/consts';
|
|
7
6
|
export class StormTest {
|
|
8
7
|
firebaseConfig;
|
|
9
8
|
testConfig;
|
|
@@ -27,10 +26,8 @@ export class StormTest {
|
|
|
27
26
|
.init();
|
|
28
27
|
return this;
|
|
29
28
|
}
|
|
30
|
-
async
|
|
31
|
-
await
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
ModuleManager.__resetForTests();
|
|
29
|
+
async destroy() {
|
|
30
|
+
await ModuleManager.destroy();
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
33
|
export const stormTester = async (stormTestInput, testCaseRunner) => {
|
|
@@ -44,6 +41,6 @@ export const stormTester = async (stormTestInput, testCaseRunner) => {
|
|
|
44
41
|
// first we do all the applicative test cleanups, for example, delete firestore collections
|
|
45
42
|
await stormTestInput.after?.();
|
|
46
43
|
// only then we clean infra stuff, like firebase apps
|
|
47
|
-
await stormTest.
|
|
44
|
+
await stormTest.destroy();
|
|
48
45
|
}
|
|
49
46
|
};
|