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:
2026-01-25 22:47:53 +00:00
parent bd6cc3c963
commit 949b7c8571
6 changed files with 104 additions and 46 deletions

View File

@@ -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,