Skip to content

Commit

Permalink
feat(api/api): create initial user route
Browse files Browse the repository at this point in the history
  • Loading branch information
JowiAoun authored and MFarabi619 committed Oct 5, 2024
1 parent 1a9cca4 commit a6998f3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libs/api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
import { userRouter } from './routes/user'
import { createCallerFactory, createRouter } from './trpc'

export * from './lib/api'

export const appRouter = createRouter({
user: userRouter,
})

export type AppRouter = typeof appRouter

export const createCaller = createCallerFactory(appRouter)

export { createTRPCContext } from './trpc'
9 changes: 9 additions & 0 deletions libs/api/src/routes/user/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createRouter, publicProcedure } from '../../trpc'

export const userRouter = createRouter({
hello: publicProcedure.query(({ ctx }: { ctx: any }) => {
return {
message: `Hello, ${ctx?.user?.name ?? 'world'} from tRPC!`,
}
}),
})

0 comments on commit a6998f3

Please sign in to comment.