mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-21 01:21:17 +00:00
feat(backend): add location router with tRPC factory pattern
- Add createLocationRouter with location.update mutation - Refactor tRPC to factory pattern (createTRPC, createTRPCRouter) - Protected procedure by default (all routes require auth) - Replace zod with arktype for input validation - Wire location router in main() with dependency injection Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -2,22 +2,33 @@ import { trpcServer } from "@hono/trpc-server"
|
||||
import { Hono } from "hono"
|
||||
|
||||
import { registerAuthHandlers } from "./auth/http.ts"
|
||||
import { LocationService } from "./location/service.ts"
|
||||
import { createContext } from "./trpc/context.ts"
|
||||
import { appRouter } from "./trpc/router.ts"
|
||||
import { createTRPCRouter } from "./trpc/router.ts"
|
||||
|
||||
const app = new Hono()
|
||||
function main() {
|
||||
const locationService = new LocationService()
|
||||
|
||||
app.get("/health", (c) => c.json({ status: "ok" }))
|
||||
const trpcRouter = createTRPCRouter({ locationService })
|
||||
|
||||
registerAuthHandlers(app)
|
||||
const app = new Hono()
|
||||
|
||||
app.use(
|
||||
"/trpc/*",
|
||||
trpcServer({
|
||||
router: appRouter,
|
||||
createContext,
|
||||
}),
|
||||
)
|
||||
app.get("/health", (c) => c.json({ status: "ok" }))
|
||||
|
||||
registerAuthHandlers(app)
|
||||
|
||||
app.use(
|
||||
"/trpc/*",
|
||||
trpcServer({
|
||||
router: trpcRouter,
|
||||
createContext,
|
||||
}),
|
||||
)
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
const app = main()
|
||||
|
||||
export default {
|
||||
port: 3000,
|
||||
|
||||
Reference in New Issue
Block a user