• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ckapps / overckd / 13656842746

31 May 2023 01:52PM UTC coverage: 20.328%. First build
13656842746

push

github

web-flow
Merge pull request #17 from ckapps/chore/update-deps

Chore/update deps

32 of 288 branches covered (11.11%)

Branch coverage included in aggregate %.

32 of 270 new or added lines in 73 files covered. (11.85%)

464 of 2152 relevant lines covered (21.56%)

0.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/server/src/route/api/recipe-collection/recipe-collection.effects.ts
NEW
1
import { useContext } from '@marblejs/core';
×
NEW
2
import { HttpStatus, r } from '@marblejs/http';
×
3
import { EventBusClientToken } from '@marblejs/messaging';
×
4
import { requestValidator$ } from '@marblejs/middleware-io';
×
5
import {
×
6
  CreateRecipeCollectionCommand,
7
  GetAllRecipeCollectionsEvent,
8
  GetRecipeCollectionByIdEvent,
9
  RecipeCollectionDto,
10
  RecipeCollectionIdDto,
11
} from '@overckd/domain-rx';
NEW
12
import { pipe } from 'fp-ts/function';
×
NEW
13
import { map, mergeMap } from 'rxjs/operators';
×
14

15
// ----------------------------------------------------------------------------
16
// Validators
17
// ----------------------------------------------------------------------------
18
/**
19
 * Validates request: `POST`
20
 */
21
const validatePostRequest = requestValidator$({
×
22
  body: RecipeCollectionDto,
23
});
24

25
/**
26
 * Validates request: `GET` byId
27
 */
28
const validateGetByIdRequest = requestValidator$({
×
29
  params: RecipeCollectionIdDto,
30
});
31

32
// ----------------------------------------------------------------------------
33
// Effects
34
// ----------------------------------------------------------------------------
35
/**
36
 * `GET` collections (all)
37
 */
38
export const getCollections$ = r.pipe(
×
39
  r.matchPath('/'),
40
  r.matchType('GET'),
41
  r.useEffect((req$, ctx) => {
42
    const eventBusClient = useContext(EventBusClientToken)(ctx.ask);
×
43

44
    return req$.pipe(
×
45
      mergeMap(req => {
46
        return pipe(GetAllRecipeCollectionsEvent.create(), eventBusClient.send);
×
47
      }),
48
      map(value => ({ body: value.payload })),
×
49
      // mapTo({ status: HttpStatus.OK, b }),
50
    );
51
  }),
52
);
53

54
/**
55
 * `POST` collection
56
 */
57
export const postRecipeCollection$ = r.pipe(
×
58
  r.matchPath('/'),
59
  r.matchType('POST'),
60
  r.useEffect((req$, ctx) => {
61
    const eventBusClient = useContext(EventBusClientToken)(ctx.ask);
×
62

63
    return req$.pipe(
×
64
      validatePostRequest,
65
      mergeMap(req => {
66
        const { body } = req;
×
67

68
        return pipe(
×
69
          CreateRecipeCollectionCommand.create(body),
70
          eventBusClient.send,
71
        );
72
      }),
NEW
73
      map(() => ({ status: HttpStatus.CREATED })),
×
74
    );
75
  }),
76
);
77

78
/**
79
 * `GET` collection by ID
80
 */
81
export const getCollectionsById$ = r.pipe(
×
82
  r.matchPath('/:id'),
83
  r.matchType('GET'),
84
  r.useEffect((req$, ctx) => {
85
    const eventBusClient = useContext(EventBusClientToken)(ctx.ask);
×
86

87
    return req$.pipe(
×
88
      validateGetByIdRequest,
89
      mergeMap(req => {
90
        const { params } = req;
×
91

92
        return pipe(
×
93
          GetRecipeCollectionByIdEvent.create(params),
94
          eventBusClient.send,
95
        );
96
      }),
97
      map(value => ({ body: value.payload })),
×
98
      // mapTo({ status: HttpStatus.OK, b }),
99
    );
100
  }),
101
);
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc