imp(@integration): replaced EffectFactory with `r` builder
MODIFY
packages/@integration/src/effects/api.effects.ts
packages/@integration/src/effects/api.effects.ts
-import { EffectFactory, HttpError, HttpStatus, combineRoutes, use, switchToProtocol } from '@marblejs/core';
+import { r, HttpError, HttpStatus, combineRoutes, use, switchToProtocol } from '@marblejs/core';
import { requestValidator$, t } from '@marblejs/middleware-io';
import { throwError } from 'rxjs';
import { map, mergeMap, tap } from 'rxjs/operators';
@@ -15,41 +15,41 @@ const rootValiadtor$ = requestValidator$({
}),
});
-const root$ = EffectFactory
- .matchPath('/')
- .matchType('GET')
- .use((req$, _, { inject }) => req$.pipe(
+const root$ = r.pipe(
+ r.matchPath('/'),
+ r.matchType('GET'),
+ r.useEffect((req$, _, { inject }) => req$.pipe(
use(rootValiadtor$),
map(req => req.params.version),
map(version => `API version: ${version}`),
tap(message => inject(WebSocketsToken).sendBroadcastResponse({ type: 'ROOT', payload: message })),
map(message => ({ body: message })),
- ));
+ )));
-const notImplemented$ = EffectFactory
- .matchPath('/error')
- .matchType('GET')
- .use(req$ => req$.pipe(
+const notImplemented$ = r.pipe(
+ r.matchPath('/error'),
+ r.matchType('GET'),
+ r.useEffect(req$ => req$.pipe(
mergeMap(() => throwError(
new HttpError('Route not implemented', HttpStatus.NOT_IMPLEMENTED, { reason: 'Not implemented' })
)),
- ));
+ )));
-const webSockets$ = EffectFactory
- .matchPath('/ws')
- .matchType('GET')
- .use(req$ => req$.pipe(
+const webSockets$ = r.pipe(
+ r.matchPath('/ws'),
+ r.matchType('GET'),
+ r.useEffect(req$ => req$.pipe(
switchToProtocol('websocket')
- ));
+ )));
-const notFound$ = EffectFactory
- .matchPath('*')
- .matchType('*')
- .use(req$ => req$.pipe(
+const notFound$ = r.pipe(
+ r.matchPath('*'),
+ r.matchType('*'),
+ r.useEffect(req$ => req$.pipe(
mergeMap(() => throwError(
new HttpError('Route not found', HttpStatus.NOT_FOUND)
)),
- ));
+ )));
export const api$ = combineRoutes(
'/api/:version',

MODIFY
packages/@integration/src/effects/static.effects.ts
packages/@integration/src/effects/static.effects.ts
import * as path from 'path';
-import { EffectFactory, combineRoutes, use } from '@marblejs/core';
+import { r, combineRoutes, use } from '@marblejs/core';
import { requestValidator$, t } from '@marblejs/middleware-io';
import { readFile } from '@marblejs/core/dist/+internal';
import { map, mergeMap } from 'rxjs/operators';
@@ -10,15 +10,15 @@ const getFileValidator$ = requestValidator$({
params: t.type({ dir: t.string })
});
-const getFile$ = EffectFactory
- .matchPath('/:dir*')
- .matchType('GET')
- .use(req$ => req$.pipe(
+const getFile$ = r.pipe(
+ r.matchPath('/:dir*'),
+ r.matchType('GET'),
+ r.useEffect(req$ => req$.pipe(
use(getFileValidator$),
map(req => req.params.dir),
mergeMap(readFile(STATIC_PATH)),
map(body => ({ body }))
- ));
+ )));
export const static$ = combineRoutes(
'/static',

imp(@integration): replaced EffectFactory with `r` builder