Files
backstage-test/apis/hello-world-trpc-api.yaml
2023-05-08 11:13:35 +02:00

26 lines
680 B
YAML

apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: hello-world-trpc
description: Hello World example for tRPC
spec:
type: trpc
lifecycle: experimental
owner: team-c
definition: |
import { z } from 'zod';
import { publicProcedure, router } from '../trpc';
export const apiRouter = router({
version: publicProcedure.query(() => {
return { version: '0.42.0' };
}),
hello: publicProcedure
.input(z.object({ username: z.string().nullish() }).nullish())
.query(({ input, ctx }) => {
return {
text: `hello ${input?.username ?? ctx.user?.name ?? 'world'}`,
};
}),
});