From fb9fbfe1013021fb58f5c1c9b9df3476e9b739a5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Dec 2025 04:20:10 +0000 Subject: [PATCH 1/4] Initial plan From 11b511479f1d3b002126aae36bd1a91c70619fd2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Dec 2025 04:23:08 +0000 Subject: [PATCH 2/4] Initial exploration Co-authored-by: npv2k1 <73846954+npv2k1@users.noreply.github.com> --- src/index.ts | 4 +--- src/shared/index.ts | 2 +- src/utils/index.ts | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index 52c9265..09311ef 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,4 @@ -var http = require('http'); - - +const http = require('http'); async function bootstrap() { console.log('Starting server...'); diff --git a/src/shared/index.ts b/src/shared/index.ts index c08c4bf..e2d8df7 100644 --- a/src/shared/index.ts +++ b/src/shared/index.ts @@ -1 +1 @@ -// share \ No newline at end of file +// share diff --git a/src/utils/index.ts b/src/utils/index.ts index fc51dd1..bddcdfb 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,5 +1,5 @@ // utils export const getCurrentTimestamp = () => { - return Math.floor(Date.now() / 1000) -} \ No newline at end of file + return Math.floor(Date.now() / 1000); +}; From 76286c36ee68cc28e86816032686df96b8b2adae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Dec 2025 04:26:35 +0000 Subject: [PATCH 3/4] Upgrade Node.js to LTS 22 and improve folder structure Co-authored-by: npv2k1 <73846954+npv2k1@users.noreply.github.com> --- .nvmrc | 2 +- Dockerfile | 14 +++--- README.md | 104 +++++++++++++++++++++++++++++++--------- package.json | 2 +- pnpm-lock.yaml | 95 +++++++++++++++++++----------------- src/config/index.ts | 10 ++++ src/constants/index.ts | 13 +++++ src/index.ts | 2 +- src/middleware/index.ts | 2 + src/services/index.ts | 2 + src/types/index.ts | 11 +++++ tsconfig.json | 11 ++++- 12 files changed, 189 insertions(+), 79 deletions(-) create mode 100644 src/config/index.ts create mode 100644 src/constants/index.ts create mode 100644 src/middleware/index.ts create mode 100644 src/services/index.ts create mode 100644 src/types/index.ts diff --git a/.nvmrc b/.nvmrc index a1fe187..8fdd954 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -16.14.2 \ No newline at end of file +22 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3483384..0f62e20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,23 @@ -FROM node:16.20.2-alpine AS builder +FROM node:22-alpine AS builder RUN apk add --no-cache libc6-compat -RUN npm i -g pnpm@8.2.0 +RUN npm i -g pnpm@9 # Create app directory WORKDIR /app # A wildcard is used to ensure both package.json AND package-lock.json are copied -COPY package*.json ./ -RUN pnpm install +COPY package*.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile COPY . . -RUN npm run build +RUN pnpm run build -FROM node:16.20.2-alpine +FROM node:22-alpine RUN apk add --no-cache libc6-compat -RUN npm i -g pnpm@8.2.0 WORKDIR /app COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package*.json ./ COPY --from=builder /app/dist ./dist - EXPOSE 4000 CMD [ "npm", "run", "start" ] \ No newline at end of file diff --git a/README.md b/README.md index 432217b..3bf110f 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,98 @@ -# Template node typescript +# Template Node.js TypeScript + +A modern Node.js TypeScript template with a well-organized folder structure and best practices. + +## Requirements + +- Node.js 22.x (LTS) +- pnpm (recommended) or npm ## Getting Started + Instructions for installing dependencies and running the app locally. ```bash -npm install -npm run dev +# Install dependencies +pnpm install + +# Run in development mode +pnpm run dev + +# Build for production +pnpm run build + +# Start production server +pnpm run start ``` ## Project Structure -Overview of the project files and directories. ``` -src/ - TypeScript source code -dist/ - Compiled JavaScript output -test/ - Unit tests +src/ +├── config/ # Configuration files and environment variables +├── constants/ # Application constants and enums +├── middleware/ # Express/HTTP middleware functions +├── services/ # Business logic and service layer +├── shared/ # Shared utilities and helpers +├── types/ # TypeScript type definitions and interfaces +├── utils/ # Utility functions and helpers +└── index.ts # Application entry point + +tests/ # Unit and integration tests +dist/ # Compiled JavaScript output (generated) ``` + +### Folder Descriptions + +| Folder | Description | +|--------|-------------| +| `config/` | Environment configuration, app settings, and external service configs | +| `constants/` | Static values, HTTP status codes, error messages, and app-wide constants | +| `middleware/` | Request processing middleware (auth, logging, validation, etc.) | +| `services/` | Business logic layer with reusable service modules | +| `shared/` | Cross-cutting utilities shared across the application | +| `types/` | TypeScript interfaces, types, and type guards | +| `utils/` | Helper functions and utility modules | + ## Scripts -Explanation of the main NPM scripts for development. -dev - Starts the app in development mode with live reloading -build - Compiles TypeScript to JavaScript -start - Runs the compiled app -test - Runs unit tests -Deployment -Notes on how to deploy the app to production. +| Script | Description | +|--------|-------------| +| `dev` | Starts the app in development mode with live reloading | +| `build` | Compiles TypeScript to JavaScript (CJS and ESM) | +| `start` | Runs the compiled app | +| `test` | Runs unit tests | +| `test:cov` | Runs tests with coverage report | +| `lint` | Runs ESLint to check and fix code style | +| `format` | Formats code using Prettier | + +## Path Aliases + +The project uses path aliases for cleaner imports: + +```typescript +import { config } from '@/config'; +import { HTTP_STATUS } from '@/constants'; +import { getCurrentTimestamp } from '@/utils'; +``` + +## Docker + +Build and run the application using Docker: + +```bash +docker build -t template-node-typescript . +docker run -p 8080:8080 template-node-typescript +``` + +## Built With -# Built With -Node.js - JavaScript runtime -TypeScript - Typed superset of JavaScript -# License -Overview of license used for the project. +- [Node.js](https://nodejs.org/) - JavaScript runtime (v22 LTS) +- [TypeScript](https://www.typescriptlang.org/) - Typed superset of JavaScript +- [Jest](https://jestjs.io/) - Testing framework +- [ESLint](https://eslint.org/) - Linting utility +- [Prettier](https://prettier.io/) - Code formatter -# Acknowledgments -Shoutouts to tutorials, libraries, and resources that were helpful. +## License -Let me know if you would like me to expand or modify this suggested README. I aimed to provide a high-level overview based on the context provided. \ No newline at end of file +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. \ No newline at end of file diff --git a/package.json b/package.json index f1df777..b93b439 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@swc/helpers": "^0.5.1", "@types/jest": "28.1.6", "@types/lodash": "^4.14.197", - "@types/node": "^18.16.19", + "@types/node": "^22.0.0", "@typescript-eslint/eslint-plugin": "5.30.7", "@typescript-eslint/parser": "5.30.7", "concurrently": "^7.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4848749..8dcd435 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,8 +31,8 @@ importers: specifier: ^4.14.197 version: 4.14.197 '@types/node': - specifier: ^18.16.19 - version: 18.16.19 + specifier: ^22.0.0 + version: 22.19.1 '@typescript-eslint/eslint-plugin': specifier: 5.30.7 version: 5.30.7(@typescript-eslint/parser@5.30.7(eslint@8.20.0)(typescript@4.7.4))(eslint@8.20.0)(typescript@4.7.4) @@ -62,7 +62,7 @@ importers: version: 10.0.0(eslint@8.20.0) jest: specifier: 28.1.3 - version: 28.1.3(@types/node@18.16.19)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4)) + version: 28.1.3(@types/node@22.19.1)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4)) nodemon: specifier: ^2.0.22 version: 2.0.22 @@ -77,13 +77,13 @@ importers: version: 3.0.2 ts-jest: specifier: 28.0.7 - version: 28.0.7(@babel/core@7.22.9)(@jest/types@28.1.3)(babel-jest@28.1.3(@babel/core@7.22.9))(jest@28.1.3(@types/node@18.16.19)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4)))(typescript@4.7.4) + version: 28.0.7(@babel/core@7.22.9)(@jest/types@28.1.3)(babel-jest@28.1.3(@babel/core@7.22.9))(jest@28.1.3(@types/node@22.19.1)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4)))(typescript@4.7.4) ts-node: specifier: ^10.9.1 - version: 10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4) + version: 10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4) ts-node-dev: specifier: ^2.0.0 - version: 2.0.0(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4) + version: 2.0.0(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4) tsconfig-paths: specifier: ^4.2.0 version: 4.2.0 @@ -912,8 +912,8 @@ packages: '@types/lodash@4.14.197': resolution: {integrity: sha512-BMVOiWs0uNxHVlHBgzTIqJYmj+PgCo4euloGF+5m4okL3rEYzM2EEv78mw8zWSMM57dM7kVIgJ2QDvwHSoCI5g==} - '@types/node@18.16.19': - resolution: {integrity: sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==} + '@types/node@22.19.1': + resolution: {integrity: sha512-LCCV0HdSZZZb34qifBsyWlUmok6W7ouER+oQIGBScS8EsZsQbrtFTUrDX4hOl+CS6p7cnNC4td+qrSVGSCTUfQ==} '@types/prettier@2.7.3': resolution: {integrity: sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==} @@ -2655,6 +2655,9 @@ packages: undefsafe@2.0.5: resolution: {integrity: sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==} + undici-types@6.21.0: + resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} + universalify@2.0.0: resolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==} engines: {node: '>= 10.0.0'} @@ -3161,27 +3164,27 @@ snapshots: '@jest/console@28.1.3': dependencies: '@jest/types': 28.1.3 - '@types/node': 18.16.19 + '@types/node': 22.19.1 chalk: 4.1.2 jest-message-util: 28.1.3 jest-util: 28.1.3 slash: 3.0.0 - '@jest/core@28.1.3(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4))': + '@jest/core@28.1.3(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4))': dependencies: '@jest/console': 28.1.3 '@jest/reporters': 28.1.3 '@jest/test-result': 28.1.3 '@jest/transform': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 18.16.19 + '@types/node': 22.19.1 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.8.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 28.1.3 - jest-config: 28.1.3(@types/node@18.16.19)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4)) + jest-config: 28.1.3(@types/node@22.19.1)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4)) jest-haste-map: 28.1.3 jest-message-util: 28.1.3 jest-regex-util: 28.0.2 @@ -3206,7 +3209,7 @@ snapshots: dependencies: '@jest/fake-timers': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 18.16.19 + '@types/node': 22.19.1 jest-mock: 28.1.3 '@jest/expect-utils@28.1.3': @@ -3224,7 +3227,7 @@ snapshots: dependencies: '@jest/types': 28.1.3 '@sinonjs/fake-timers': 9.1.2 - '@types/node': 18.16.19 + '@types/node': 22.19.1 jest-message-util: 28.1.3 jest-mock: 28.1.3 jest-util: 28.1.3 @@ -3245,7 +3248,7 @@ snapshots: '@jest/transform': 28.1.3 '@jest/types': 28.1.3 '@jridgewell/trace-mapping': 0.3.18 - '@types/node': 18.16.19 + '@types/node': 22.19.1 chalk: 4.1.2 collect-v8-coverage: 1.0.2 exit: 0.1.2 @@ -3316,7 +3319,7 @@ snapshots: '@jest/schemas': 28.1.3 '@types/istanbul-lib-coverage': 2.0.4 '@types/istanbul-reports': 3.0.1 - '@types/node': 18.16.19 + '@types/node': 22.19.1 '@types/yargs': 17.0.24 chalk: 4.1.2 @@ -3529,14 +3532,14 @@ snapshots: dependencies: '@types/http-cache-semantics': 4.0.1 '@types/keyv': 3.1.4 - '@types/node': 18.16.19 + '@types/node': 22.19.1 '@types/responselike': 1.0.0 '@types/estree@1.0.1': {} '@types/graceful-fs@4.1.6': dependencies: - '@types/node': 18.16.19 + '@types/node': 22.19.1 '@types/http-cache-semantics@4.0.1': {} @@ -3559,11 +3562,13 @@ snapshots: '@types/keyv@3.1.4': dependencies: - '@types/node': 18.16.19 + '@types/node': 22.19.1 '@types/lodash@4.14.197': {} - '@types/node@18.16.19': {} + '@types/node@22.19.1': + dependencies: + undici-types: 6.21.0 '@types/prettier@2.7.3': {} @@ -3571,7 +3576,7 @@ snapshots: '@types/responselike@1.0.0': dependencies: - '@types/node': 18.16.19 + '@types/node': 22.19.1 '@types/stack-utils@2.0.1': {} @@ -4515,7 +4520,7 @@ snapshots: '@jest/expect': 28.1.3 '@jest/test-result': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 18.16.19 + '@types/node': 22.19.1 chalk: 4.1.2 co: 4.6.0 dedent: 0.7.0 @@ -4533,16 +4538,16 @@ snapshots: transitivePeerDependencies: - supports-color - jest-cli@28.1.3(@types/node@18.16.19)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4)): + jest-cli@28.1.3(@types/node@22.19.1)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4)): dependencies: - '@jest/core': 28.1.3(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4)) + '@jest/core': 28.1.3(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4)) '@jest/test-result': 28.1.3 '@jest/types': 28.1.3 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 import-local: 3.1.0 - jest-config: 28.1.3(@types/node@18.16.19)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4)) + jest-config: 28.1.3(@types/node@22.19.1)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4)) jest-util: 28.1.3 jest-validate: 28.1.3 prompts: 2.4.2 @@ -4552,7 +4557,7 @@ snapshots: - supports-color - ts-node - jest-config@28.1.3(@types/node@18.16.19)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4)): + jest-config@28.1.3(@types/node@22.19.1)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4)): dependencies: '@babel/core': 7.22.9 '@jest/test-sequencer': 28.1.3 @@ -4577,8 +4582,8 @@ snapshots: slash: 3.0.0 strip-json-comments: 3.1.1 optionalDependencies: - '@types/node': 18.16.19 - ts-node: 10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4) + '@types/node': 22.19.1 + ts-node: 10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4) transitivePeerDependencies: - supports-color @@ -4606,7 +4611,7 @@ snapshots: '@jest/environment': 28.1.3 '@jest/fake-timers': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 18.16.19 + '@types/node': 22.19.1 jest-mock: 28.1.3 jest-util: 28.1.3 @@ -4616,7 +4621,7 @@ snapshots: dependencies: '@jest/types': 28.1.3 '@types/graceful-fs': 4.1.6 - '@types/node': 18.16.19 + '@types/node': 22.19.1 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -4655,7 +4660,7 @@ snapshots: jest-mock@28.1.3: dependencies: '@jest/types': 28.1.3 - '@types/node': 18.16.19 + '@types/node': 22.19.1 jest-pnp-resolver@1.2.3(jest-resolve@28.1.3): optionalDependencies: @@ -4689,7 +4694,7 @@ snapshots: '@jest/test-result': 28.1.3 '@jest/transform': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 18.16.19 + '@types/node': 22.19.1 chalk: 4.1.2 emittery: 0.10.2 graceful-fs: 4.2.11 @@ -4766,7 +4771,7 @@ snapshots: jest-util@28.1.3: dependencies: '@jest/types': 28.1.3 - '@types/node': 18.16.19 + '@types/node': 22.19.1 chalk: 4.1.2 ci-info: 3.8.0 graceful-fs: 4.2.11 @@ -4785,7 +4790,7 @@ snapshots: dependencies: '@jest/test-result': 28.1.3 '@jest/types': 28.1.3 - '@types/node': 18.16.19 + '@types/node': 22.19.1 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.10.2 @@ -4794,16 +4799,16 @@ snapshots: jest-worker@28.1.3: dependencies: - '@types/node': 18.16.19 + '@types/node': 22.19.1 merge-stream: 2.0.0 supports-color: 8.1.1 - jest@28.1.3(@types/node@18.16.19)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4)): + jest@28.1.3(@types/node@22.19.1)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4)): dependencies: - '@jest/core': 28.1.3(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4)) + '@jest/core': 28.1.3(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4)) '@jest/types': 28.1.3 import-local: 3.1.0 - jest-cli: 28.1.3(@types/node@18.16.19)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4)) + jest-cli: 28.1.3(@types/node@22.19.1)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4)) transitivePeerDependencies: - '@types/node' - supports-color @@ -5388,11 +5393,11 @@ snapshots: dependencies: escape-string-regexp: 5.0.0 - ts-jest@28.0.7(@babel/core@7.22.9)(@jest/types@28.1.3)(babel-jest@28.1.3(@babel/core@7.22.9))(jest@28.1.3(@types/node@18.16.19)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4)))(typescript@4.7.4): + ts-jest@28.0.7(@babel/core@7.22.9)(@jest/types@28.1.3)(babel-jest@28.1.3(@babel/core@7.22.9))(jest@28.1.3(@types/node@22.19.1)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4)))(typescript@4.7.4): dependencies: bs-logger: 0.2.6 fast-json-stable-stringify: 2.1.0 - jest: 28.1.3(@types/node@18.16.19)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4)) + jest: 28.1.3(@types/node@22.19.1)(ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4)) jest-util: 28.1.3 json5: 2.2.3 lodash.memoize: 4.1.2 @@ -5405,7 +5410,7 @@ snapshots: '@jest/types': 28.1.3 babel-jest: 28.1.3(@babel/core@7.22.9) - ts-node-dev@2.0.0(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4): + ts-node-dev@2.0.0(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4): dependencies: chokidar: 3.5.3 dynamic-dedupe: 0.3.0 @@ -5415,7 +5420,7 @@ snapshots: rimraf: 2.7.1 source-map-support: 0.5.21 tree-kill: 1.2.2 - ts-node: 10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4) + ts-node: 10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4) tsconfig: 7.0.0 typescript: 4.7.4 transitivePeerDependencies: @@ -5423,14 +5428,14 @@ snapshots: - '@swc/wasm' - '@types/node' - ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@18.16.19)(typescript@4.7.4): + ts-node@10.9.1(@swc/core@1.3.74(@swc/helpers@0.5.1))(@types/node@22.19.1)(typescript@4.7.4): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.9 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 18.16.19 + '@types/node': 22.19.1 acorn: 8.10.0 acorn-walk: 8.2.0 arg: 4.1.3 @@ -5514,6 +5519,8 @@ snapshots: undefsafe@2.0.5: {} + undici-types@6.21.0: {} + universalify@2.0.0: {} untildify@4.0.0: {} diff --git a/src/config/index.ts b/src/config/index.ts new file mode 100644 index 0000000..fe6e3ca --- /dev/null +++ b/src/config/index.ts @@ -0,0 +1,10 @@ +import dotenv from 'dotenv'; + +dotenv.config(); + +export const config = { + port: process.env.PORT || 8080, + nodeEnv: process.env.NODE_ENV || 'development', +}; + +export default config; diff --git a/src/constants/index.ts b/src/constants/index.ts new file mode 100644 index 0000000..7129ca7 --- /dev/null +++ b/src/constants/index.ts @@ -0,0 +1,13 @@ +// Application constants + +export const HTTP_STATUS = { + OK: 200, + CREATED: 201, + BAD_REQUEST: 400, + UNAUTHORIZED: 401, + FORBIDDEN: 403, + NOT_FOUND: 404, + INTERNAL_SERVER_ERROR: 500, +} as const; + +export const DEFAULT_PORT = 8080; diff --git a/src/index.ts b/src/index.ts index 09311ef..0c178e7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -const http = require('http'); +import http from 'http'; async function bootstrap() { console.log('Starting server...'); diff --git a/src/middleware/index.ts b/src/middleware/index.ts new file mode 100644 index 0000000..7ce203c --- /dev/null +++ b/src/middleware/index.ts @@ -0,0 +1,2 @@ +// Export all middleware from this file +// Example: export * from './auth.middleware'; diff --git a/src/services/index.ts b/src/services/index.ts new file mode 100644 index 0000000..f708e78 --- /dev/null +++ b/src/services/index.ts @@ -0,0 +1,2 @@ +// Export all services from this file +// Example: export * from './user.service'; diff --git a/src/types/index.ts b/src/types/index.ts new file mode 100644 index 0000000..d0bef58 --- /dev/null +++ b/src/types/index.ts @@ -0,0 +1,11 @@ +// Application type definitions + +export interface AppConfig { + port: number | string; + nodeEnv: string; +} + +export interface ServerResponse { + status: number; + message: string; +} diff --git a/tsconfig.json b/tsconfig.json index 1a3a1ca..af1f9a7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "jsx": "react", "module": "CommonJS", - "target": "es2022", + "target": "ES2022", "declaration": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, @@ -21,7 +21,14 @@ "forceConsistentCasingInFileNames": false, "noFallthroughCasesInSwitch": false, "paths": { - "@/*": ["src/*"] + "@/*": ["src/*"], + "@/config": ["src/config"], + "@/types": ["src/types"], + "@/services": ["src/services"], + "@/constants": ["src/constants"], + "@/middleware": ["src/middleware"], + "@/utils": ["src/utils"], + "@/shared": ["src/shared"] } }, "ts-node": { From 2b9d824ad7a54156f0e6d99a3c1cb9f1c7bf318e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Dec 2025 04:28:46 +0000 Subject: [PATCH 4/4] Address code review feedback: fix typo and simplify tsconfig Co-authored-by: npv2k1 <73846954+npv2k1@users.noreply.github.com> --- src/shared/index.ts | 2 +- tsconfig.json | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/shared/index.ts b/src/shared/index.ts index e2d8df7..6cabc41 100644 --- a/src/shared/index.ts +++ b/src/shared/index.ts @@ -1 +1 @@ -// share +// shared diff --git a/tsconfig.json b/tsconfig.json index af1f9a7..7e04869 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,14 +21,7 @@ "forceConsistentCasingInFileNames": false, "noFallthroughCasesInSwitch": false, "paths": { - "@/*": ["src/*"], - "@/config": ["src/config"], - "@/types": ["src/types"], - "@/services": ["src/services"], - "@/constants": ["src/constants"], - "@/middleware": ["src/middleware"], - "@/utils": ["src/utils"], - "@/shared": ["src/shared"] + "@/*": ["src/*"] } }, "ts-node": {