MCPcopy Index your code
hub / github.com/Effect-TS/effect / layerHttpApi

Function layerHttpApi

packages/workflow/src/WorkflowProxyServer.ts:19–79  ·  view source on GitHub ↗
(
  api: HttpApi.HttpApi<ApiId, Groups, ApiE, ApiR>,
  name: Name,
  workflows: Workflows
)

Source from the content-addressed store, hash-verified

17 * @category Layers
18 */
19export const layerHttpApi = <
20 ApiId extends string,
21 Groups extends HttpApiGroup.Any,
22 ApiE,
23 ApiR,
24 Name extends HttpApiGroup.Name<Groups>,
25 const Workflows extends NonEmptyReadonlyArray<Workflow.Any>
26>(
27 api: HttpApi.HttpApi<ApiId, Groups, ApiE, ApiR>,
28 name: Name,
29 workflows: Workflows
30): Layer.Layer<
31 ApiGroup<ApiId, Name>,
32 never,
33 WorkflowEngine | Workflow.Requirements<Workflows[number]>
34> =>
35 HttpApiBuilder.group(
36 api,
37 name,
38 Effect.fnUntraced(function*(handlers_) {
39 let handlers = handlers_ as any
40 for (const workflow_ of workflows) {
41 const workflow = workflow_ as Workflow.Workflow<string, any, any, any>
42 handlers = handlers
43 .handle(
44 workflow.name as any,
45 ({ payload }: { payload: any }) =>
46 workflow.execute(payload).pipe(
47 Effect.tapDefect(Effect.logError),
48 Effect.annotateLogs({
49 module: "WorkflowProxyServer",
50 method: workflow.name
51 })
52 )
53 )
54 .handle(
55 workflow.name + "Discard" as any,
56 ({ payload }: { payload: any }) =>
57 workflow.execute(payload, { discard: true } as any).pipe(
58 Effect.tapDefect(Effect.logError),
59 Effect.annotateLogs({
60 module: "WorkflowProxyServer",
61 method: workflow.name + "Discard"
62 })
63 )
64 )
65 .handle(
66 workflow.name + "Resume" as any,
67 ({ payload }: { payload: any }) =>
68 workflow.resume(payload.executionId).pipe(
69 Effect.tapDefect(Effect.logError),
70 Effect.annotateLogs({
71 module: "WorkflowProxyServer",
72 method: workflow.name + "Resume"
73 })
74 )
75 )
76 }

Callers

nothing calls this directly

Calls 5

resumeMethod · 0.80
groupMethod · 0.65
handleMethod · 0.65
pipeMethod · 0.65
executeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…