Skip to content

Commit 76286c3

Browse files
Copilotnpv2k1
andcommitted
Upgrade Node.js to LTS 22 and improve folder structure
Co-authored-by: npv2k1 <73846954+npv2k1@users.noreply.github.com>
1 parent 11b5114 commit 76286c3

File tree

12 files changed

+189
-79
lines changed

12 files changed

+189
-79
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.14.2
1+
22

Dockerfile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
FROM node:16.20.2-alpine AS builder
1+
FROM node:22-alpine AS builder
22
RUN apk add --no-cache libc6-compat
3-
RUN npm i -g pnpm@8.2.0
3+
RUN npm i -g pnpm@9
44

55
# Create app directory
66
WORKDIR /app
77

88
# A wildcard is used to ensure both package.json AND package-lock.json are copied
9-
COPY package*.json ./
10-
RUN pnpm install
9+
COPY package*.json pnpm-lock.yaml ./
10+
RUN pnpm install --frozen-lockfile
1111

1212
COPY . .
13-
RUN npm run build
13+
RUN pnpm run build
1414

15-
FROM node:16.20.2-alpine
15+
FROM node:22-alpine
1616
RUN apk add --no-cache libc6-compat
17-
RUN npm i -g pnpm@8.2.0
1817
WORKDIR /app
1918
COPY --from=builder /app/node_modules ./node_modules
2019
COPY --from=builder /app/package*.json ./
2120
COPY --from=builder /app/dist ./dist
2221

23-
2422
EXPOSE 4000
2523
CMD [ "npm", "run", "start" ]

README.md

Lines changed: 82 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,98 @@
1-
# Template node typescript
1+
# Template Node.js TypeScript
2+
3+
A modern Node.js TypeScript template with a well-organized folder structure and best practices.
4+
5+
## Requirements
6+
7+
- Node.js 22.x (LTS)
8+
- pnpm (recommended) or npm
29

310
## Getting Started
11+
412
Instructions for installing dependencies and running the app locally.
513

614
```bash
7-
npm install
8-
npm run dev
15+
# Install dependencies
16+
pnpm install
17+
18+
# Run in development mode
19+
pnpm run dev
20+
21+
# Build for production
22+
pnpm run build
23+
24+
# Start production server
25+
pnpm run start
926
```
1027

1128
## Project Structure
12-
Overview of the project files and directories.
1329

1430
```
15-
src/ - TypeScript source code
16-
dist/ - Compiled JavaScript output
17-
test/ - Unit tests
31+
src/
32+
├── config/ # Configuration files and environment variables
33+
├── constants/ # Application constants and enums
34+
├── middleware/ # Express/HTTP middleware functions
35+
├── services/ # Business logic and service layer
36+
├── shared/ # Shared utilities and helpers
37+
├── types/ # TypeScript type definitions and interfaces
38+
├── utils/ # Utility functions and helpers
39+
└── index.ts # Application entry point
40+
41+
tests/ # Unit and integration tests
42+
dist/ # Compiled JavaScript output (generated)
1843
```
44+
45+
### Folder Descriptions
46+
47+
| Folder | Description |
48+
|--------|-------------|
49+
| `config/` | Environment configuration, app settings, and external service configs |
50+
| `constants/` | Static values, HTTP status codes, error messages, and app-wide constants |
51+
| `middleware/` | Request processing middleware (auth, logging, validation, etc.) |
52+
| `services/` | Business logic layer with reusable service modules |
53+
| `shared/` | Cross-cutting utilities shared across the application |
54+
| `types/` | TypeScript interfaces, types, and type guards |
55+
| `utils/` | Helper functions and utility modules |
56+
1957
## Scripts
20-
Explanation of the main NPM scripts for development.
2158

22-
dev - Starts the app in development mode with live reloading
23-
build - Compiles TypeScript to JavaScript
24-
start - Runs the compiled app
25-
test - Runs unit tests
26-
Deployment
27-
Notes on how to deploy the app to production.
59+
| Script | Description |
60+
|--------|-------------|
61+
| `dev` | Starts the app in development mode with live reloading |
62+
| `build` | Compiles TypeScript to JavaScript (CJS and ESM) |
63+
| `start` | Runs the compiled app |
64+
| `test` | Runs unit tests |
65+
| `test:cov` | Runs tests with coverage report |
66+
| `lint` | Runs ESLint to check and fix code style |
67+
| `format` | Formats code using Prettier |
68+
69+
## Path Aliases
70+
71+
The project uses path aliases for cleaner imports:
72+
73+
```typescript
74+
import { config } from '@/config';
75+
import { HTTP_STATUS } from '@/constants';
76+
import { getCurrentTimestamp } from '@/utils';
77+
```
78+
79+
## Docker
80+
81+
Build and run the application using Docker:
82+
83+
```bash
84+
docker build -t template-node-typescript .
85+
docker run -p 8080:8080 template-node-typescript
86+
```
87+
88+
## Built With
2889

29-
# Built With
30-
Node.js - JavaScript runtime
31-
TypeScript - Typed superset of JavaScript
32-
# License
33-
Overview of license used for the project.
90+
- [Node.js](https://nodejs.org/) - JavaScript runtime (v22 LTS)
91+
- [TypeScript](https://www.typescriptlang.org/) - Typed superset of JavaScript
92+
- [Jest](https://jestjs.io/) - Testing framework
93+
- [ESLint](https://eslint.org/) - Linting utility
94+
- [Prettier](https://prettier.io/) - Code formatter
3495

35-
# Acknowledgments
36-
Shoutouts to tutorials, libraries, and resources that were helpful.
96+
## License
3797

38-
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.
98+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@swc/helpers": "^0.5.1",
4040
"@types/jest": "28.1.6",
4141
"@types/lodash": "^4.14.197",
42-
"@types/node": "^18.16.19",
42+
"@types/node": "^22.0.0",
4343
"@typescript-eslint/eslint-plugin": "5.30.7",
4444
"@typescript-eslint/parser": "5.30.7",
4545
"concurrently": "^7.6.0",

0 commit comments

Comments
 (0)