Commit 567d220
feat: Upgrade to TypeScript, add data types, and mock auth (#39)
* feat: Upgrade to TypeScript, add data types, and mock auth
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.
* fix: Add Vitest coverage directory to .gitignore
Adds `coverage/` to `.gitignore` to prevent tracking of
locally generated code coverage reports by Vitest.
* chore: Update Node.js versions in CI workflow
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.
* fix: Add dist directory to .gitignore
Adds the `dist/` directory (default TypeScript output)
to `.gitignore` to prevent compiled files from being
committed to the repository.
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>1 parent 12b22bb commit 567d220
File tree
56 files changed
+8822
-2125
lines changed- .github/workflows
- routes
- src
- bin
- database
- interfaces
- middleware
- routes
- scripts
- tests
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
56 files changed
+8822
-2125
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
This file was deleted.
0 commit comments