@nu-art/thunderstorm-backend 0.401.0 → 0.401.2

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.
@@ -2,7 +2,7 @@ import { Module, PreDB, TypedMap, UniqueId } from '@nu-art/ts-common';
2
2
  import { DBApiConfigV3, ModuleBE_BaseDB } from '../../modules/db-api-gen/ModuleBE_BaseDB.js';
3
3
  import { FirestoreQuery } from '@nu-art/firebase-shared';
4
4
  import { Readable } from 'stream';
5
- import { FirestoreCollectionV3 } from '@nu-art/firebase-backend/firestore-v3/FirestoreCollectionV3';
5
+ import { FirestoreCollectionV3 } from '@nu-art/firebase-backend';
6
6
  import { DB_BackupDoc, DBProto_BackupDoc, FetchBackupDoc } from '@nu-art/thunderstorm-shared';
7
7
  import { Request_BackupId, Response_BackupDocs } from '@nu-art/thunderstorm-shared/_entity/backup-doc/api-def';
8
8
  export interface OnModuleCleanupV2 {
package/core/Storm.js CHANGED
@@ -19,7 +19,7 @@
19
19
  * limitations under the License.
20
20
  */
21
21
  import { BeLogged, LogClient_Function, LogClient_Terminal, LogLevel } from '@nu-art/ts-common';
22
- import { Firebase_ExpressFunction } from '@nu-art/firebase-backend';
22
+ import { Firebase_ExpressFunction } from '@nu-art/firebase-backend/v1';
23
23
  import { BaseStorm } from './BaseStorm.js';
24
24
  import { HttpServer } from '../modules/server/HttpServer.js';
25
25
  import { ModuleBE_BaseFunction, ModuleBE_Firebase } from '@nu-art/firebase-backend';
@@ -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
- import { TestResetListener } from '@nu-art/ts-common/testing/types';
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
- __resetForTests(): Promise<void>;
5
+ destroy(): Promise<void>;
7
6
  addRoutes: (apis: ServerApi<any>[]) => void;
8
7
  useRoutes: () => ServerApi<any>[];
9
8
  }
@@ -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 __resetForTests() {
6
- this.logWarning('__resetForTests');
5
+ async destroy() {
6
+ this.logWarning('destroy');
7
7
  this.routes.length = 0;
8
8
  }
9
9
  addRoutes = (apis) => {
@@ -1,6 +1,6 @@
1
1
  import { Module } from '@nu-art/ts-common';
2
2
  import { Express, ExpressRequestHandler, HttpErrorHandler } from '../../utils/types.js';
3
- import { Firebase_ExpressFunction, TBR_ExpressFunctionInterface } from '@nu-art/firebase-backend';
3
+ import { Firebase_ExpressFunction, TBR_ExpressFunctionInterface } from '@nu-art/firebase-backend/v1';
4
4
  type ConfigType = {
5
5
  port: number;
6
6
  baseUrl: string;
@@ -27,7 +27,7 @@ import * as fs from 'fs';
27
27
  import { addItemToArray, LogLevel, Module } from '@nu-art/ts-common';
28
28
  import express from 'express';
29
29
  import { DefaultApiErrorMessageComposer } from './server-errors.js';
30
- import { Firebase_ExpressFunction } from '@nu-art/firebase-backend';
30
+ import { Firebase_ExpressFunction } from '@nu-art/firebase-backend/v1';
31
31
  import { ServerApi } from './server-api.js';
32
32
  import compression from 'compression';
33
33
  import cors from 'cors';
@@ -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
- this.getExpress().use(express.json({ limit: parserLimit }));
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.401.0",
3
+ "version": "0.401.2",
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.401.0",
41
- "@nu-art/firebase-backend": "0.401.0",
42
- "@nu-art/firebase-shared": "0.401.0",
43
- "@nu-art/google-services-backend": "0.401.0",
44
- "@nu-art/ts-common": "0.401.0",
40
+ "@nu-art/testalot": "0.401.2",
41
+ "@nu-art/thunderstorm-shared": "0.401.2",
42
+ "@nu-art/firebase-backend": "0.401.2",
43
+ "@nu-art/firebase-shared": "0.401.2",
44
+ "@nu-art/google-services-backend": "0.401.2",
45
+ "@nu-art/ts-common": "0.401.2",
45
46
  "abort-controller": "^3.0.0",
46
47
  "axios": "^1.13.1",
47
48
  "body-parser": "^1.19.0",
@@ -1,5 +1,5 @@
1
1
  import { AsyncVoidFunction, Module, RecursiveObjectOfPrimitives } from '@nu-art/ts-common';
2
- import { TestModel } from '@nu-art/ts-common/testing/types';
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
- cleanup(): Promise<void>;
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 cleanup() {
31
- await dispatcher_resetTests.dispatchModuleAsync();
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.cleanup();
44
+ await stormTest.destroy();
48
45
  }
49
46
  };