Files
WRNexusJS/examples/inter-app-api-showcase/packages/shared/src/index.ts
T
ClintchizandClaude Opus 5 247f360ae7
Quality / quality (ubuntu-latest) (push) Failing after 19m36s
Quality / quality (windows-latest) (push) Canceled after 0s
docs: rank the destructive generator as item 0
It was written up in 4.7 but never made the work order, which is exactly how it
stayed dangerous in the first place.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-09 11:18:45 +05:30

31 lines
1.1 KiB
TypeScript

/**
* Shared code for every app in this workspace. Import it anywhere: `@app/shared`.
* The cross-app event bus uses Redis so messages reach every app process/domain.
*/
import { createPubSub } from "../../../../../packages/pubsub/src/index.ts";
import { redisDriver } from "../../../../../packages/pubsub/src/redis.ts";
import { defineService, procedure } from "../../../../../packages/rpc/src/index.ts";
import { v } from "../../../../../packages/validation/src/index.ts";
// One bus per process, backed by Redis (set REDIS_URL, defaults to localhost:6379).
export const bus = createPubSub(redisDriver(process.env.REDIS_URL));
// Shared domain types can live here and be imported by every app.
export interface Tenant {
id: string;
name: string;
}
/** Contract shared by web (caller) and admin (callee). */
export const catalogService = defineService({
name: "catalog",
procedures: {
getProduct: procedure
.input(v.object({ sku: v.string() }))
.output<{ sku: string; name: string; priceCents: number }>()
.permission("catalog:read")
.idempotent()
.build(),
},
});