Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the codebase to TypeScript, adds stronger typing across middleware, database modules, and tests, and improves project configuration (linting, formatting, scripts, and documentation).
- Convert existing middleware, database logic, and tests from JavaScript to TypeScript with explicit types
- Introduce graceful shutdown in
src/index.tsand enhance error handling - Update project tooling: add ESLint & Prettier configs, refine
package.jsonscripts, and refresh README
Reviewed Changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/midleware/morgan.ts | Simplified import of morgan |
| src/midleware/json.ts | Reordered JSON middleware options and tightened types |
| src/midleware/helmet.ts | Reordered config keys for consistency |
| src/midleware/errorHandler.ts | Added unused-param naming convention and stack fallback |
| src/midleware/cors.ts | Switched to nullish defaults and split/trim env-based lists |
| src/index.ts | Added dotenv import, graceful shutdown, and consistent string casts |
| src/http_tests/stores.test.ts | Introduced typed Response and body casting |
| src/http_tests/authentication.test.ts | Defined response interface and strengthened test assertions |
| src/http_tests/app.test.ts | Defined response interface and used typed casts |
| src/database/stores.ts | Refactored return types and ordering of DB functions |
| src/database/mongo-common.ts | Unified startDatabase/getDatabase signatures and import order |
| src/app.ts | Reordered middleware and router imports for consistency |
| package.json | Added lint/format scripts, private flag, and import mapping |
| eslint.config.js | Introduced TypeScript-aware ESLint config |
| README.md | Updated env var docs and scripts section |
| .prettierrc | Added Prettier configuration |
| .prettierignore | Defined ignore patterns |
| .env.sample | Added JWT_SECRET documentation |
Comments suppressed due to low confidence (3)
src/http_tests/stores.test.ts:55
- Guarding test assertions behind a conditional may hide failures when
storeIdis undefined. Instead, add an explicitexpect(storeId).toBeDefined()before using it and remove theifguard so the test fails rather than silently passing.
if (storeId) {
src/database/stores.ts:48
- Returning an
ObjectIddirectly in API responses can break JSON clients. Convert_idto a string (e.g.,store._id.toHexString()) so consumers receive a primitive value.
_id: store._id,
src/database/stores.ts:66
- Re-wrapping an existing
ObjectIdwithnew ObjectId(...)is unnecessary and can introduce confusion. Return the originalupdated._idor convert it to a string if needed.
_id: new ObjectId(updated._id),
environment. When running within a GitHub Actions workflow, it now returns the .
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.