Skip to content

Improve Type Safety in event.ts and Remove Remaining any Usage #549

@Harxhit

Description

@Harxhit

Summary

Improve type safety in event.ts by removing remaining usages of any and replacing them with proper Fastify, TypeScript, Prisma, and application-specific types.

Contexts

The event routes currently contain several usages of any that bypass TypeScript's type checking and reduce maintainability.

Examples include:

const server = request.server as any;
(app as any).authenticate
(request.user as any).id
catch (error: any)

Some of these usages are related to authentication, Fastify route handlers, and Prisma error handling. Existing shared Fastify/JWT type definitions should be reused where available instead of introducing duplicate definitions.

Removing these usages will improve maintainability, reduce unsafe casts, and make future refactoring easier.

Tasks

  • Identify all remaining any usages in event.ts
  • Use existing Fastify/JWT type definitions where available
  • Replace server as any with appropriate Fastify types
  • Replace app as any with appropriate Fastify types
  • Replace request.user as any with properly typed user access
  • Replace error: any with safer error handling patterns
  • Improve authentication-related typing where applicable
  • Verify TypeScript passes without introducing new type errors
  • Update tests if required

Acceptance Criteria

  • No any usages remain in event.ts
  • Existing shared Fastify/JWT types are reused where applicable
  • Authenticated user access is properly typed
  • Authentication-related code uses proper Fastify types
  • Error handling avoids unsafe any usage
  • TypeScript checks pass successfully
  • Existing event functionality continues to work
  • Tests pass successfully

Area

backend

Difficulty

Good First Issue

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Status
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions