add the tRPC hello world example
Signed-off-by: Oleg S <97077423+RobotSail@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
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'}`,
|
||||
};
|
||||
}),
|
||||
});
|
||||
Reference in New Issue
Block a user