This commit resolves all outstanding TypeScript errors by refactoring the application to align with Fastify's best practices for schema-driven development and type inference. Key changes include: Schema-Driven Routes: Implemented schemas for auth, repos, and webhook routes. This provides automatic request validation and strong type inference for request.body and request.params, removing the need for manual, redundant type assertions. Centralized Type Definitions: Created src/types/github.ts to define and export shared types like GitHubUser and GitHubWebhookPayload, resolving module import errors and creating a single source of truth. Corrected Type Mismatches: Fixed a critical bug in the authentication and webhook services where the numeric githubUser.id was incorrectly converted to a string before database operations, which expect an integer. Simplified Middleware: The webhook verification middleware was corrected, and route handlers were simplified by removing explicit typing, letting Fastify infer types from the attached schemas.
16 lines
366 B
TypeScript
16 lines
366 B
TypeScript
/**
|
|
* Represents the user data structure returned from the GitHub API.
|
|
*/
|
|
export interface GitHubUser {
|
|
id: number;
|
|
login: string;
|
|
name: string | null;
|
|
avatar_url: string;
|
|
}
|
|
|
|
/**
|
|
* A generic type for the GitHub webhook payload.
|
|
* The actual structure varies widely depending on the event type.
|
|
*/
|
|
export type GitHubWebhookPayload = Record<string, any>;
|