feat: enhance backend conventions for tRPC and Hono with new error handling, pagination, authorization, and logging guidelines. Introduce shared utilities for error management, ownership assertions, and visibility conditions. Update routers to utilize new pagination schema and improve error responses. Add comprehensive documentation in AGENTS.md for better developer onboarding.
598f0d5 Download packages/api/src/lib/errors.ts from Atmint/cpns: direct link, hf CLI and curl.
- Browser
- Download file 708 Bytes
-
https://huggingface.co/spaces/Atmint/cpns/resolve/main/packages/api/src/lib/errors.ts
- Command line
-
hf download hf://spaces/Atmint/cpns/packages/api/src/lib/errors.ts
-
curl -L -o errors.ts https://huggingface.co/spaces/Atmint/cpns/resolve/main/packages/api/src/lib/errors.ts
708 Bytes
| import { TRPCError } from "@trpc/server"; | |
| export function throwUnauthorized(message = "Unauthorized"): never { | |
| throw new TRPCError({ code: "UNAUTHORIZED", message }); | |
| } | |
| export function throwForbidden(message = "Forbidden"): never { | |
| throw new TRPCError({ code: "FORBIDDEN", message }); | |
| } | |
| export function throwNotFound(resource = "Resource"): never { | |
| throw new TRPCError({ code: "NOT_FOUND", message: `${resource} not found` }); | |
| } | |
| export function throwBadRequest(message = "Bad request"): never { | |
| throw new TRPCError({ code: "BAD_REQUEST", message }); | |
| } | |
| export function throwInternal(message = "Internal server error"): never { | |
| throw new TRPCError({ code: "INTERNAL_SERVER_ERROR", message }); | |
| } | |