-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Upgrade to TypeScript, add data types, and mock auth #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
StanleyMasinde
merged 4 commits into
master
from
feat/typescript-upgrade-new-types-mock-auth
Jun 6, 2025
Merged
feat: Upgrade to TypeScript, add data types, and mock auth #39
StanleyMasinde
merged 4 commits into
master
from
feat/typescript-upgrade-new-types-mock-auth
Jun 6, 2025
Conversation
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
This major update transitions the entire project from JavaScript to TypeScript, enhancing type safety and maintainability. Key changes include: 1. **TypeScript Conversion:** * All source files (`.js` to `.ts`) in `app.js`, `bin/www`, routes, and new modules. * Setup of `tsconfig.json` for strict type checking. * Updated `package.json` scripts for TypeScript compilation (`tsc`). 2. **Dependency Updates & Testing Framework:** * Upgraded dependencies to their latest versions. * Replaced Faker.js with `@faker-js/faker`. * Integrated Vitest as the testing framework, replacing Mocha/Chai. * Converted all existing tests to TypeScript/Vitest and added `supertest` for HTTP request testing. 3. **New Data Types:** * Added `Company`, `Address`, and `Order` data types. * Created interfaces for these types in `src/interfaces/`. * Generated mock data using Faker.js scripts (stored in `src/database/`). * Implemented new Express routes for each data type (GET all, GET by ID). 4. **Mock Authentication:** * Implemented JWT-based mock authentication. * Added `/auth/login` endpoint to issue tokens (mock credential check). * Created a protected `/auth/me` endpoint. * Developed an `authenticateToken` middleware for securing routes. * Defined `JwtPayload` and extended Express Request types. 5. **Testing Enhancements:** * Added comprehensive tests for all new data type routes. * Added detailed tests for the authentication flow (login, token validation, protected route access). * Achieved high test coverage for all new and modified functionalities. 6. **Code Quality and Refinement:** * Ensured strong typing throughout the codebase, minimizing `any`. * Verified successful build and all tests passing post-refinement. This upgrade provides a more robust, well-typed, and feature-rich mock API server suitable for further development and testing purposes.
Adds `coverage/` to `.gitignore` to prevent tracking of locally generated code coverage reports by Vitest.
I've updated the GitHub Actions CI workflow to use more recent Node.js versions. - I modified the `node-version` matrix to `[20.x, 22.x]`. - I updated `actions/checkout` from `v2` to `v4`. - I updated `actions/setup-node` from `v1` to `v4`. - I enabled npm caching in the `setup-node` step. - I ensured `npm test` is always executed.
Adds the `dist/` directory (default TypeScript output) to `.gitignore` to prevent compiled files from being committed to the repository.
StanleyMasinde
commented
Jun 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.
This major update transitions the entire project from JavaScript to TypeScript, enhancing type safety and maintainability.
Key changes include:
TypeScript Conversion:
.js
to.ts
) inapp.js
,bin/www
, routes,and new modules.
tsconfig.json
for strict type checking.package.json
scripts for TypeScript compilation (tsc
).Dependency Updates & Testing Framework:
@faker-js/faker
.supertest
for HTTP request testing.New Data Types:
Company
,Address
, andOrder
data types.src/interfaces/
.src/database/
).Mock Authentication:
/auth/login
endpoint to issue tokens (mock credential check)./auth/me
endpoint.authenticateToken
middleware for securing routes.JwtPayload
and extended Express Request types.Testing Enhancements:
validation, protected route access).
Code Quality and Refinement:
any
.This upgrade provides a more robust, well-typed, and feature-rich mock API server suitable for further development and testing purposes.