const Endpoint = Rpc.make("Endpoint", {
error: InternalServerError,
payload: Schema.Struct({
query: Schema.String.pipe(
Schema.nonEmptyString({ message: () => "..." }),
Schema.maxLength(20, { message: () => "..." }),
),
}),
});
class ExampleRpc extends RpcGroup.make(Endpoint) {}
const ExampleRpcGroupLive = ExampleRpc.toLayer({
"Endpoint": (payload) =>
Effect.gen(function* () {
const fallible = yield* Effect.tryPromise(...).pipe(
Effect.tapErrorCause((error) =>
Effect.annotateCurrentSpan({ error: error.toJSON() }),
),
Effect.mapError(() => new InternalServerError()),
);
return fallible;
}).pipe(
Effect.withSpan("@project-name/file/ExampleRpcGroupLive/Endpoint"),
),
});
const Endpoint = Rpc.make("Endpoint", {
error: InternalServerError,
payload: Schema.Struct({
query: Schema.String.pipe(
Schema.nonEmptyString({ message: () => "..." }),
Schema.maxLength(20, { message: () => "..." }),
),
}),
});
class ExampleRpc extends RpcGroup.make(Endpoint) {}
const ExampleRpcGroupLive = ExampleRpc.toLayer({
"Endpoint": (payload) =>
Effect.gen(function* () {
const fallible = yield* Effect.tryPromise(...).pipe(
Effect.tapErrorCause((error) =>
Effect.annotateCurrentSpan({ error: error.toJSON() }),
),
Effect.mapError(() => new InternalServerError()),
);
return fallible;
}).pipe(
Effect.withSpan("@project-name/file/ExampleRpcGroupLive/Endpoint"),
),
});