This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const server = createServer({ | |
| port: 1337, | |
| httpListener, | |
| dependencies: [ | |
| bindTo(WsServerToken)(webSocketListener().run), | |
| ], | |
| }); | |
| // ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { use, r } from '@marblejs/core'; | |
| const postUser$ = r.pipe( | |
| r.matchPath('/'), | |
| r.matchType('POST'), | |
| r.use(authorize$), | |
| r.useEffect(req$ => req$.pipe( | |
| use(postUserValidator$), | |
| map(req => req.body), | |
| mergeMap(createUser), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { use, matchEvent } from '@marblejs/core'; | |
| import { WsEffect } from '@marblejs/websockets'; | |
| import { t, eventValidator$ } from '@marblejs/middleware-io'; | |
| export const sum$: WsEffect = event$ => | |
| event$.pipe( | |
| matchEvent('SUM') | |
| ); | |
| export const add$: WsEffect = (event$, ...args) => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const authorize$: Middleware = (req$) => | |
| req$.pipe( | |
| switchMap(req => iif( | |
| () => !isAuthorized(req), | |
| throwError(new HttpError('Unauthorized', HttpStatus.UNAUTHORIZED)), | |
| of(req), | |
| )), | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const effect$: Effect = (req$) => | |
| req$.pipe( | |
| // ... | |
| ); | |
| const middleware$: Middleware = (req$, res) => | |
| req$.pipe( | |
| // ... | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getUsers$ = EffectFactory | |
| .matchPath('/') | |
| .matchType('GET') | |
| .use(req$ => req$.pipe( | |
| switchMap(Dao.getUsers), | |
| map(users => ({ body: users })), | |
| )); | |
| const postUser$ = EffectFactory | |
| .matchPath('/') |
NewerOlder