Skip to content

Instantly share code, notes, and snippets.

@JozefFlakus
Created August 28, 2018 20:38
Show Gist options
  • Save JozefFlakus/d9b0468c261a272e1fc14e39558d8a32 to your computer and use it in GitHub Desktop.
Save JozefFlakus/d9b0468c261a272e1fc14e39558d8a32 to your computer and use it in GitHub Desktop.
Marble.js - sample controller example
const getUsers$ = EffectFactory
.matchPath('/')
.matchType('GET')
.use(req$ => req$.pipe(
switchMap(Dao.getUsers),
map(users => ({ body: users })),
));
const postUser$ = EffectFactory
.matchPath('/')
.matchType('POST')
.use(req$ => req$.pipe(
map(req => req.body),
switchMap(Dao.postUser),
map(response => ({ body: response })),
));
export const user$ = combineRoutes('/user', {
middlewares: [authorize$],
effects: [getUsers$, postUser$],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment