Skip to content

fix(backend): remove @ts-nocheck from audit and student route modules - #1038

Merged
ayomideadeniran merged 2 commits into
StellarDevHub:mainfrom
Zinai10:fix/remove-ts-nocheck-audit-student-routes
Aug 3, 2026
Merged

fix(backend): remove @ts-nocheck from audit and student route modules#1038
ayomideadeniran merged 2 commits into
StellarDevHub:mainfrom
Zinai10:fix/remove-ts-nocheck-audit-student-routes

Conversation

@Zinai10

@Zinai10 Zinai10 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Closes #919

What changed

src/types/student.types.ts (new)

  • Add Zod schemas: CreateStudentSchema, UpdateStudentSchema, StudentIdParamSchema
  • Export inferred TypeScript types: CreateStudentBody, UpdateStudentBody, StudentIdParam
  • Add StudentAuditDetails interface for typed audit detail payloads

src/utils/audit.ts

  • Remove // @ts-nocheck suppression
  • Replace as any cast with AuditDetailsRecord interface + Object.assign
  • Narrow req.body via BodyWithOptionalEmail interface
  • Narrow req.user via AuthenticatedUser interface
  • Use nullish coalescing (??) consistently

src/routes/students.ts

  • Remove // @ts-nocheck suppression
  • Add typed Request<Params, ResBody, Body> generics on every handler
  • Add parseBody() helper for centralised Zod validation with structured { field, message }[] error responses (400)
  • Explicitly type the updateData object — no implicit any
  • Replace all console.error calls with logger.error; include studentId context but never email (PII redaction)
  • Handlers return Promise — no implicit any return type

tests/students.routes.test.ts (new, 19 tests)

  • Success and error paths for GET /, GET /:id, POST /, PUT /:id, DELETE /:id
  • Validation failure paths: missing fields, invalid email, invalid DID
  • 500 paths assert structured logger is called with correct context
  • PII-redaction assertion: email never appears in error log metadata
  • DID sync and cache-invalidation side-effects verified

Verification

  • tsc --noEmit: zero errors in target files
  • 19 new tests pass; 2 pre-existing auditAction tests still pass

Closes StellarDevHub#919

## What changed

### src/types/student.types.ts (new)
- Add Zod schemas: CreateStudentSchema, UpdateStudentSchema,
  StudentIdParamSchema
- Export inferred TypeScript types: CreateStudentBody, UpdateStudentBody,
  StudentIdParam
- Add StudentAuditDetails interface for typed audit detail payloads

### src/utils/audit.ts
- Remove // @ts-nocheck suppression
- Replace `as any` cast with AuditDetailsRecord interface + Object.assign
- Narrow req.body via BodyWithOptionalEmail interface
- Narrow req.user via AuthenticatedUser interface
- Use nullish coalescing (??) consistently

### src/routes/students.ts
- Remove // @ts-nocheck suppression
- Add typed Request<Params, ResBody, Body> generics on every handler
- Add parseBody() helper for centralised Zod validation with structured
  { field, message }[] error responses (400)
- Explicitly type the updateData object — no implicit any
- Replace all console.error calls with logger.error; include studentId
  context but never email (PII redaction)
- Handlers return Promise<void> — no implicit any return type

### tests/students.routes.test.ts (new, 19 tests)
- Success and error paths for GET /, GET /:id, POST /, PUT /:id, DELETE /:id
- Validation failure paths: missing fields, invalid email, invalid DID
- 500 paths assert structured logger is called with correct context
- PII-redaction assertion: email never appears in error log metadata
- DID sync and cache-invalidation side-effects verified

## Verification
- tsc --noEmit: zero errors in target files
- 19 new tests pass; 2 pre-existing auditAction tests still pass
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Zinai10 is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Zinai10 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@ayomideadeniran

Copy link
Copy Markdown
Contributor

pr under review

@ayomideadeniran
ayomideadeniran merged commit 58eb66b into StellarDevHub:main Aug 3, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] Remove TypeScript suppression from audit and student route modules

2 participants