hiring-app-types
v0.1.0
Published
Type definitions for the hiring app API
Downloads
4
Maintainers
Readme
@incerro/hiring-app-types
Type definitions for the Incerro Hiring App API.
Installation
npm install @incerro/hiring-app-types
# or
yarn add @incerro/hiring-app-typesUsage
TRPC Client Setup
import { createTRPCProxyClient } from '@trpc/client';
import type { AppRouter } from '@incerro/hiring-app-types';
const trpc = createTRPCProxyClient<AppRouter>({
url: 'http://localhost:3000/api/trpc',
});
// Now you get full type safety
const result = await trpc.greeting.query();Error Handling
import { errors, ErrorSource } from '@incerro/hiring-app-types';
try {
// API call
} catch (error) {
if (error.code === errors.UNAUTHORIZED) {
// Handle unauthorized error
} else if (error.source === ErrorSource.DATABASE) {
// Handle database error
}
}Available Types
AppRouter: The main TRPC router typeerrors: Enum of error codesErrorSource: Enum of error sourcesErrorContext: Interface for error context
License
MIT
