How to use the @marblejs/core.combineRoutes function in @marblejs/core

To help you get started, we’ve selected a few @marblejs/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github edbzn / reactive-blog / packages / server / src / api / comment / index.ts View on Github external
import { getCommentByArticleEffect$ } from './effects/get-comment-by-article.effect';
import { postCommentByArticleEffect$ } from './effects/post-comment-by-article.effect';

const getCommentByArticle$ = EffectFactory.matchPath('/')
  .matchType('GET')
  .use(getCommentByArticleEffect$);

const postCommentByArticle$ = EffectFactory.matchPath('/')
  .matchType('POST')
  .use(postCommentByArticleEffect$);

// const removeCommentByArticle$ = EffectFactory.matchPath("/:commentId")
//   .matchType("DELETE")
//   .use(removeCommentEffect$);

export const comment$ = combineRoutes('/article/:articleId/comment', {
  effects: [getCommentByArticle$, postCommentByArticle$],
});
github marblejs / example / src / api / movies / index.ts View on Github external
import { combineRoutes, EffectFactory } from '@marblejs/core';
import { authorize$ } from '../auth/middlewares/auth.middleware';
import { getMovieEffect$ } from './effects/getMovie.effect';
import { getMovieListEffect$ } from './effects/getMovieList.effect';

const getMovieList$ = EffectFactory
  .matchPath('/')
  .matchType('GET')
  .use(getMovieListEffect$);

const getMovie$ = EffectFactory
  .matchPath('/:id')
  .matchType('GET')
  .use(getMovieEffect$);

export const movies$ = combineRoutes('/movies', {
  effects: [getMovieList$, getMovie$],
  middlewares: [authorize$],
});
github marblejs / example / src / api / users / index.ts View on Github external
import { combineRoutes, EffectFactory } from '@marblejs/core';
import { getUserListEffect$ } from './effects/getUserList.effect';
import { getMeEffect$ } from './effects/getMe.effect';
import { authorize$ } from '../auth/middlewares/auth.middleware';

export const getUserList$ = EffectFactory
  .matchPath('/')
  .matchType('GET')
  .use(getUserListEffect$);

export const getMe$ = EffectFactory
  .matchPath('/me')
  .matchType('GET')
  .use(getMeEffect$);

export const users$ = combineRoutes('/users', {
  effects: [getUserList$, getMe$],
  middlewares: [authorize$],
});
github marblejs / example / src / api / auth / index.ts View on Github external
import { combineRoutes, EffectFactory } from '@marblejs/core';
import { loginEffect$ } from './effects/login.effect';

const login$ = EffectFactory
  .matchPath('/login')
  .matchType('POST')
  .use(loginEffect$);

export const auth$ = combineRoutes('/auth', [login$]);
github edbzn / reactive-blog / packages / server / src / api / article / index.ts View on Github external
.matchType('DELETE')
  .use(removeArticleEffect$);

const updateArticle$ = EffectFactory.matchPath('/:id')
  .matchType('PUT')
  .use(updateArticleEffect$);

const updateArticleReaction$ = EffectFactory.matchPath('/:id/reaction')
  .matchType('POST')
  .use(updateArticleReactionEffect$);

const postArticle$ = EffectFactory.matchPath('/')
  .matchType('POST')
  .use(postArticleEffect$);

export const article$ = combineRoutes('/article', {
  effects: [getArticleList$, getArticleById$, getArticleBySlug$, updateArticleReaction$],
});

export const authorizedArticle$ = combineRoutes('/article', {
  effects: [postArticle$, removeArticle$, updateArticle$],
  middlewares: [authorize$],
});

export const authorizedDraft$ = combineRoutes('/draft', {
  effects: [getDraftList$],
  middlewares: [authorize$],
});
github marblejs / marble / packages / @integration / src / effects / api.effects.ts View on Github external
r.matchPath('/ws'),
  r.matchType('GET'),
  r.useEffect(req$ => req$.pipe(
    switchToProtocol('websocket')
  )));

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',
  [ root$, user$, static$, notImplemented$, webSockets$, notFound$ ],
);
github marblejs / example / src / api / actors / index.ts View on Github external
import { combineRoutes, EffectFactory } from '@marblejs/core';
import { authorize$ } from '../auth/middlewares/auth.middleware';
import { getActorListEffect$ } from './effects/getActorList.effect';
import { getActorEffect$ } from './effects/getActor.effect';

const getActorList$ = EffectFactory
  .matchPath('/')
  .matchType('GET')
  .use(getActorListEffect$);

const getActor$ = EffectFactory
  .matchPath('/:id')
  .matchType('GET')
  .use(getActorEffect$);

export const actors$ = combineRoutes('/actors', {
  effects: [getActorList$, getActor$],
  middlewares: [authorize$],
});
github marblejs / example / src / api / index.ts View on Github external
const preflight$ = EffectFactory
  .matchPath('*')
  .matchType('OPTIONS')
  .use(preflightEffect$);

const getFile$ = EffectFactory
  .matchPath('/assets/:dir*')
  .matchType('GET')
  .use(getFileEffect$);

const notFound$ = EffectFactory
  .matchPath('*')
  .matchType('*')
  .use(notFoundEffect$);

export const api$ = combineRoutes('/api/v1', [
  root$,
  auth$,
  users$,
  actors$,
  movies$,
  getFile$,
  preflight$,
  notFound$
]);
github edbzn / reactive-blog / src / server / api / authentication / index.ts View on Github external
import { combineRoutes, EffectFactory } from "@marblejs/core";
import { loginEffect$ } from "./effects/login.effect";
import { signupEffect$ } from "./effects/signup.effect";

const login$ = EffectFactory.matchPath("/login")
  .matchType("POST")
  .use(loginEffect$);

const signup$ = EffectFactory.matchPath("/signup")
  .matchType("POST")
  .use(signupEffect$);

export const authentication$ = combineRoutes("/auth", [login$, signup$]);
github marblejs / example / src / api / api.controller.ts View on Github external
.matchPath('/')
  .matchType('GET')
  .use(req$ => req$.pipe(
    mapTo({ body: `API version: v1` }),
  ));

const notFound$ = EffectFactory
  .matchPath('*')
  .matchType('*')
  .use(req$ => req$.pipe(
    switchMap(() =>
      throwError(new HttpError('Route not found', HttpStatus.NOT_FOUND))
    )
  ));

export const api$ = combineRoutes(
  '/api/v1',
  [ root$, auth$, user$, notFound$ ],
);