Skip to content

Conversation

@ronakmaheshwari
Copy link

@ronakmaheshwari ronakmaheshwari commented Jun 14, 2025

This PR introduces a full TypeScript upgrade, improving maintainability and scalability by structuring the codebase and data more robustly.

🔧 What’s Changed

  • Codebase migrated from JavaScript to TypeScript (*.ts files)
  • Replaced dynamic fs.readFileSync usage
  • reasons.json is now a proper TypeScript module (reasons.ts)
  • No file system access required at runtime
  • Introduced convert.ts utility
  • Converts a string[] JSON file into a typed { reason: string }[] format
  • Added type safety
  • Defined Reason interface
  • Enforced Reason[] typing for the reasons array

🎯 Why It Matters
✅ TypeScript provides a better developer experience with static type checks

✅ Eliminates runtime file I/O in favor of static imports

✅ Structured reasons array prepares the codebase for future features (e.g., filtering, categorization, tagging)

🧪 How to Test
Run the app as usual (npm run dev)

Test endpoint (e.g., /random-reason) still returns a valid JSON object:
{ reason: "..." }

Types validated via tsc with no type errors

@ronakmaheshwari
Copy link
Author

Use a "No" HTTP response code somewhere in the 4xx range #6

Copy link

@marcusmueller marcusmueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very much love this.

app.use(limiter);

const allStatusCodes = [400, 409, 412, 413, 417, 418, 422, 425, 429];
const earlyMorningStatusCodes = [413, 409, 412, 417, 422, 425];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@marcusmueller
Copy link

Closes #6

@ronakmaheshwari
Copy link
Author

Thanks

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.

2 participants