Skip to content

Migrate to ts#16

Merged
pakeku merged 10 commits intomasterfrom
erick/profile
May 17, 2025
Merged

Migrate to ts#16
pakeku merged 10 commits intomasterfrom
erick/profile

Conversation

@pakeku
Copy link
Copy Markdown
Owner

@pakeku pakeku commented May 17, 2025

No description provided.

@pakeku pakeku requested a review from Copilot May 17, 2025 06:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.ts and enhance error handling
  • Update project tooling: add ESLint & Prettier configs, refine package.json scripts, 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 storeId is undefined. Instead, add an explicit expect(storeId).toBeDefined() before using it and remove the if guard so the test fails rather than silently passing.
if (storeId) {

src/database/stores.ts:48

  • Returning an ObjectId directly in API responses can break JSON clients. Convert _id to 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 ObjectId with new ObjectId(...) is unnecessary and can introduce confusion. Return the original updated._id or convert it to a string if needed.
_id: new ObjectId(updated._id),

Comment thread eslint.config.js
environment. When running within a GitHub Actions workflow, it now
returns the .
@pakeku pakeku merged commit 0a84169 into master May 17, 2025
4 checks passed
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