How to use the @marblejs/core.use 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 / article / effects / get-article-by-slug.effect.ts View on Github external
export const getArticleBySlugEffect$: HttpEffect = req$ =>
  req$.pipe(
    use(validator$),
    mergeMap(req =>
      of(req.params.slug).pipe(
        mergeMap(ArticleDao.findByTitle),
        mergeMap(neverNullable),
        map(article => ({ body: article })),
        catchError(() => throwError(new HttpError('Article does not exist', HttpStatus.NOT_FOUND)))
      )
    )
  );
github edbzn / reactive-blog / packages / server / src / api / article / effects / get-article-list.effect.ts View on Github external
export const getArticleListEffect$: HttpEffect = req$ =>
  req$.pipe(
    use(articleQueryValidator$()),
    mergeMap(req =>
      of(req).pipe(
        mapTo(req.query),
        mergeMap(ArticleDao.findAllPublished),
        map(articleList => ({ body: articleList }))
      )
    )
  );
github edbzn / reactive-blog / packages / server / src / api / article / effects / get-draft-list.effect.ts View on Github external
export const getDraftListEffect$: HttpEffect = req$ =>
  req$.pipe(
    use(articleQueryValidator$()),
    mergeMap(req =>
      of(req).pipe(
        mapTo(req.query),
        mergeMap(ArticleDao.findAll),
        map(articleList => ({ body: articleList }))
      )
    )
  );
github edbzn / reactive-blog / packages / server / src / api / comment / effects / post-comment-by-article.effect.ts View on Github external
export const postCommentByArticleEffect$: HttpEffect = req$ =>
  req$.pipe(
    use(requestValidator$({ body: commentSchema })),
    map(req => req.body),
    mergeMap(CommentDao.create),
    map(article => ({ body: article }))
  );
github marblejs / marble / packages / messaging / src / server / specs / messaging.server.amqp.spec.ts View on Github external
const rpc$: MsgEffect = event$ =>
      event$.pipe(
        matchEvent('RPC_TEST'),
        delay(250),
        use(eventValidator$(t.number)),
        map(event => event.payload),
        map(payload => ({ type: 'RPC_TEST_RESULT', payload: payload + 1 })),
      );
github edbzn / reactive-blog / packages / server / src / api / article / effects / post-article.effect.ts View on Github external
export const postArticleEffect$: HttpEffect = req$ =>
  req$.pipe(
    use(validator$),
    mergeMap(req =>
      of(req).pipe(
        mapTo(req.body),
        mergeMap(ArticleDao.create),
        map(article => ({ body: article })),
        catchError(err => throwError(err))
      )
    )
  );
github marblejs / example / src / api / common / effects / getFile.effect.ts View on Github external
export const getFileEffect$: HttpEffect = req$ =>
  req$.pipe(
    use(validator$),
    mergeMap(req => of(req.params.dir).pipe(
      mergeMap(FileHelper.readFile(STATIC_PATH)),
      map(body => ({ body })),
      catchError(error => iif(
        () => error.code === 'ENOENT',
        throwError(new HttpError(`Asset not found for path: ${req.url}`, HttpStatus.NOT_FOUND)),
        throwError(new HttpError('Internal server error', HttpStatus.INTERNAL_SERVER_ERROR)),
      )),
    )),
  );
github edbzn / reactive-blog / src / server / api / article / effects / update-article.effect.ts View on Github external
export const updateArticleEffect$: HttpEffect = req$ =>
  req$.pipe(
    use(validator$),
    mergeMap(req =>
      of(req.params.id).pipe(
        mapTo(req.body),
        mergeMap(article => ArticleDao.updateById(req.params.id, article)),
        mergeMap(neverNullable),
        map(article => ({ body: article })),
        catchError(err =>
          throwError(new HttpError(err, HttpStatus.INTERNAL_SERVER_ERROR)),
        ),
      ),
    ),
  );
github edbzn / reactive-blog / packages / server / src / api / article / effects / remove-article.effect.ts View on Github external
export const removeArticleEffect$: HttpEffect = req$ =>
  req$.pipe(
    use(validator$),
    mergeMap(req =>
      of(req.params.id).pipe(
        mergeMap(ArticleDao.removeById),
        map(() => ({ body: null })),
        catchError(err => throwError(new HttpError(err, HttpStatus.INTERNAL_SERVER_ERROR)))
      )
    )
  );
github marblejs / example / src / api / movies / effects / getMovieList.effect.ts View on Github external
export const getMovieListEffect$: HttpEffect = req$ =>
  req$.pipe(
    use(collectionQueryValidator$({ sortBy: SORTING_FIELDS })),
    mergeMap(req => of(req).pipe(
      map(req => req.query),
      mergeMap(MoviesDao.findAll),
      map(applyHostnameForCollection(req)),
      map(movies => ({ body: movies })),
    ))
  );