style(@integration): app boostrap methods
MODIFY
packages/@integration/src/http/index.ts
packages/@integration/src/http/index.ts
+import { IO } from 'fp-ts/lib/IO';
import { createServer } from '@marblejs/core';
+import { isTestEnv } from '@marblejs/core/dist/+internal/utils';
import httpListener from './http.listener';
const port = process.env.PORT
@@ -10,10 +12,7 @@ export const server = createServer({
httpListener,
});
-export const bootstrap = async () => {
- const app = await server;
+const main: IO<void> = async () =>
+ !isTestEnv() && await (await server)();
- if (process.env.NODE_ENV !== 'test') app();
-};
-
-bootstrap();
+main();

MODIFY
packages/@integration/src/messaging/client.ts
packages/@integration/src/messaging/client.ts
@@ -2,6 +2,8 @@ import { logger$ } from '@marblejs/middleware-logger';
import { requestValidator$, t } from '@marblejs/middleware-io';
import { messagingClient, MessagingClient, Transport } from '@marblejs/messaging';
import { r, createServer, createContextToken, httpListener, use, useContext, bindEagerlyTo } from '@marblejs/core';
+import { isTestEnv } from '@marblejs/core/dist/+internal/utils';
+import { IO } from 'fp-ts/lib/IO';
import { forkJoin } from 'rxjs';
import { map, mergeMap, mapTo } from 'rxjs/operators';
@@ -84,10 +86,7 @@ export const server = createServer({
],
});
-export const bootstrap = async () => {
- const app = await server;
+const main: IO<void> = async () =>
+ !isTestEnv() && await (await server)();
- if (process.env.NODE_ENV !== 'test') app();
-};
-
-bootstrap();
+main();

MODIFY
packages/@integration/src/messaging/server.ts
packages/@integration/src/messaging/server.ts
@@ -3,6 +3,8 @@ import { map, tap, mergeMap, bufferCount, mapTo, catchError, delay } from 'rxjs/
import { matchEvent, use, Event } from '@marblejs/core';
import { eventValidator$, t } from '@marblejs/middleware-io';
import { createMicroservice, messagingListener, Transport, MsgEffect } from '@marblejs/messaging';
+import { isTestEnv } from '@marblejs/core/dist/+internal/utils';
+import { IO } from 'fp-ts/lib/IO';
const fib = (n: number): number =>
(n === 0 || n === 1) ? n : fib(n - 1) + fib(n - 2);
@@ -53,10 +55,7 @@ export const microservice = createMicroservice({
}),
});
-export const bootstrap = async () => {
- const app = await microservice;
+const main: IO<void> = async () =>
+ !isTestEnv() && await (await microservice)();
- if (process.env.NODE_ENV !== 'test') app();
-};
-
-bootstrap();
+main();

MODIFY
packages/@integration/src/websockets/http.server.ts
packages/@integration/src/websockets/http.server.ts
@@ -11,6 +11,8 @@ import {
} from '@marblejs/core';
import { mapToServer, WebSocketServerConnection } from '@marblejs/websockets';
import { logger$ } from '@marblejs/middleware-logger';
+import { isTestEnv } from '@marblejs/core/dist/+internal/utils';
+import { IO } from 'fp-ts/lib/IO';
import { merge } from 'rxjs';
import { tap, map } from 'rxjs/operators';
import { webSocketServer } from './websockets.server';
@@ -55,10 +57,7 @@ export const server = createServer({
),
});
-export const bootstrap = async () => {
- const app = await server;
+const main: IO<void> = async () =>
+ !isTestEnv() && await (await server)();
- if (process.env.NODE_ENV !== 'test') app();
-};
-
-bootstrap();
+main();

style(@integration): app boostrap methods