Skip to content

Commit 0d902b9

Browse files
committed
chore: update workflows and package config
1 parent d0a461c commit 0d902b9

4 files changed

Lines changed: 91 additions & 100 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
run: npx prettier --write "src/generated/**/*.ts"
3434

3535
- name: Run unit tests with coverage
36-
run: npm run test:cov
36+
run: npm run test
3737
env:
3838
NODE_ENV: test
3939

README.md

Lines changed: 61 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@ A microservice for handling user authentication and authorization in the NestJS
44

55
## 🚀 Features
66

7-
- **User Authentication**: JWT-based authentication with access and refresh tokens
8-
- **User Management**: CRUD operations for user accounts
9-
- **Role-based Authorization**: Support for ADMIN and USER roles
10-
- **gRPC Microservice**: Inter-service communication via gRPC
11-
- **REST API**: HTTP endpoints for authentication operations
12-
- **Database Integration**: PostgreSQL with Prisma ORM
13-
- **Caching**: Redis-based caching for performance
14-
- **Internationalization**: Multi-language support with nestjs-i18n
15-
- **API Documentation**: Swagger/OpenAPI documentation
16-
- **Health Checks**: Built-in health monitoring
17-
- **Security**: Helmet security headers, CORS configuration
7+
- **User Authentication**: JWT-based authentication with access and refresh tokens
8+
- **User Management**: CRUD operations for user accounts
9+
- **Role-based Authorization**: Support for ADMIN and USER roles
10+
- **gRPC Microservice**: Inter-service communication via gRPC
11+
- **REST API**: HTTP endpoints for authentication operations
12+
- **Database Integration**: PostgreSQL with Prisma ORM
13+
- **Caching**: Redis-based caching for performance
14+
- **Internationalization**: Multi-language support with nestjs-i18n
15+
- **API Documentation**: Swagger/OpenAPI documentation
16+
- **Health Checks**: Built-in health monitoring
17+
- **Security**: Helmet security headers, CORS configuration
1818

1919
## 🏗️ Architecture
2020

2121
### Technology Stack
2222

23-
- **Framework**: NestJS 10.x
24-
- **Language**: TypeScript 5.x
25-
- **Database**: PostgreSQL with Prisma ORM
26-
- **Cache**: Redis with cache-manager
27-
- **Authentication**: JWT with Passport.js
28-
- **API Documentation**: Swagger/OpenAPI
29-
- **Microservice**: gRPC communication
30-
- **Validation**: class-validator and class-transformer
31-
- **Testing**: Jest
23+
- **Framework**: NestJS 10.x
24+
- **Language**: TypeScript 5.x
25+
- **Database**: PostgreSQL with Prisma ORM
26+
- **Cache**: Redis with cache-manager
27+
- **Authentication**: JWT with Passport.js
28+
- **API Documentation**: Swagger/OpenAPI
29+
- **Microservice**: gRPC communication
30+
- **Validation**: class-validator and class-transformer
31+
- **Testing**: Jest
3232

3333
### Service Structure
3434

@@ -57,10 +57,10 @@ src/
5757

5858
## 📋 Prerequisites
5959

60-
- Node.js >= 18.0.0
61-
- npm >= 9.0.0
62-
- PostgreSQL
63-
- Redis
60+
- Node.js >= 18.0.0
61+
- npm >= 9.0.0
62+
- PostgreSQL
63+
- Redis
6464

6565
## 🛠️ Installation
6666

@@ -159,82 +159,76 @@ docker run -p 9001:9001 auth-service
159159

160160
#### Public Endpoints
161161

162-
- `POST /auth/login` - User login
163-
- `POST /auth/signup` - User registration
164-
- `GET /auth/refresh` - Refresh access token
162+
- `POST /auth/login` - User login
163+
- `POST /auth/signup` - User registration
164+
- `GET /auth/refresh` - Refresh access token
165165

166166
#### Protected Endpoints
167167

168-
- `GET /user/profile` - Get user profile
169-
- `PUT /user/profile` - Update user profile
168+
- `GET /user/profile` - Get user profile
169+
- `PUT /user/profile` - Update user profile
170170

171171
### User Management Endpoints
172172

173173
#### Admin Only
174174

175-
- `GET /admin/user` - List all users (paginated)
176-
- `DELETE /admin/user/:id` - Delete user
175+
- `GET /admin/user` - List all users (paginated)
176+
- `DELETE /admin/user/:id` - Delete user
177177

178178
### Health Check
179179

180-
- `GET /health` - Service health status
181-
- `GET /` - Service information
180+
- `GET /health` - Service health status
181+
- `GET /` - Service information
182182

183183
## 🔌 gRPC Services
184184

185185
### AuthService
186186

187-
- `ValidateToken` - Validate JWT tokens and return user information
187+
- `ValidateToken` - Validate JWT tokens and return user information
188188

189189
## 🔧 Configuration
190190

191191
The service uses a modular configuration system with environment-specific settings:
192192

193193
### App Configuration
194194

195-
- **Name**: Service name and display information
196-
- **Environment**: Development, staging, production
197-
- **Debug**: Debug mode settings
198-
- **CORS**: Cross-origin resource sharing settings
195+
- **Name**: Service name and display information
196+
- **Environment**: Development, staging, production
197+
- **Debug**: Debug mode settings
198+
- **CORS**: Cross-origin resource sharing settings
199199

200200
### HTTP Configuration
201201

202-
- **Port**: HTTP server port (default: 9001)
203-
- **Host**: HTTP server host
204-
- **Versioning**: API versioning settings
202+
- **Port**: HTTP server port (default: 9001)
203+
- **Host**: HTTP server host
204+
- **Versioning**: API versioning settings
205205

206206
### JWT Configuration
207207

208-
- **Access Token**: Secret key and expiration time
209-
- **Refresh Token**: Secret key and expiration time
208+
- **Access Token**: Secret key and expiration time
209+
- **Refresh Token**: Secret key and expiration time
210210

211211
### Database Configuration
212212

213-
- **URL**: PostgreSQL connection string
214-
- **Migrations**: Database migration settings
213+
- **URL**: PostgreSQL connection string
214+
- **Migrations**: Database migration settings
215215

216216
### Redis Configuration
217217

218-
- **URL**: Redis connection string
219-
- **Key Prefix**: Cache key prefix
220-
- **TTL**: Cache time-to-live
218+
- **URL**: Redis connection string
219+
- **Key Prefix**: Cache key prefix
220+
- **TTL**: Cache time-to-live
221221

222222
### gRPC Configuration
223223

224-
- **URL**: gRPC server address
225-
- **Package**: Protocol buffer package name
224+
- **URL**: gRPC server address
225+
- **Package**: Protocol buffer package name
226226

227227
## 🧪 Testing
228228

229229
```bash
230230
# Run all tests
231231
npm test
232-
233-
# Run tests in watch mode
234-
npm run test:watch
235-
236-
# Run tests with coverage
237-
npm run test:cov
238232
```
239233

240234
## 📚 API Documentation
@@ -247,20 +241,20 @@ http://localhost:9001/docs
247241
248242
## 🔒 Security Features
249243
250-
- **JWT Authentication**: Secure token-based authentication
251-
- **Password Hashing**: bcrypt password hashing
252-
- **Role-based Access Control**: ADMIN and USER roles
253-
- **Helmet Security**: Security headers
254-
- **CORS Protection**: Cross-origin request protection
255-
- **Input Validation**: Request validation with class-validator
256-
- **Rate Limiting**: Built-in rate limiting (configurable)
244+
- **JWT Authentication**: Secure token-based authentication
245+
- **Password Hashing**: bcrypt password hashing
246+
- **Role-based Access Control**: ADMIN and USER roles
247+
- **Helmet Security**: Security headers
248+
- **CORS Protection**: Cross-origin request protection
249+
- **Input Validation**: Request validation with class-validator
250+
- **Rate Limiting**: Built-in rate limiting (configurable)
257251
258252
## 📊 Monitoring
259253
260-
- **Health Checks**: Built-in health monitoring endpoints
261-
- **Sentry Integration**: Error tracking and monitoring
262-
- **Logging**: Structured logging with Winston
263-
- **Metrics**: Performance metrics collection
254+
- **Health Checks**: Built-in health monitoring endpoints
255+
- **Sentry Integration**: Error tracking and monitoring
256+
- **Logging**: Structured logging with Winston
257+
- **Metrics**: Performance metrics collection
264258
265259
## 🚀 Deployment
266260

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"start": "node dist/main",
1515
"dev": "npm run proto:generate && nest start --watch",
1616
"lint": "eslint \"{src,test}/**/*.ts\" --fix",
17-
"test": "jest --config test/jest.json --runInBand",
18-
"test:cov": "jest --config test/jest.json --runInBand --coverage",
17+
"test": "jest --config test/jest.json --runInBand --coverage",
1918
"proto:generate": "npx nestjs-grpc generate --proto ./src/protos --output ./src/generated",
2019
"prepare": "husky"
2120
},

test/jest.json

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11
{
2-
"testTimeout": 10000,
3-
"rootDir": "../",
4-
"modulePaths": ["."],
5-
"testEnvironment": "node",
6-
"testMatch": ["<rootDir>/test/unit/**/*.spec.ts"],
7-
"collectCoverage": true,
8-
"coverageDirectory": "coverage",
9-
"collectCoverageFrom": [
10-
"<rootDir>/src/**/*.service.ts"
11-
],
12-
"coverageThreshold": {
13-
"global": {
14-
"branches": 100,
15-
"functions": 100,
16-
"lines": 100,
17-
"statements": 100
18-
}
19-
},
20-
"moduleFileExtensions": ["js", "ts", "json"],
21-
"transform": {
22-
"^.+\\.(t|j)s$": "ts-jest"
23-
},
24-
"modulePathIgnorePatterns": ["<rootDir>/dist"],
2+
"testTimeout": 10000,
3+
"rootDir": "../",
4+
"modulePaths": ["."],
5+
"testEnvironment": "node",
6+
"testMatch": ["<rootDir>/test/unit/**/*.spec.ts"],
7+
"collectCoverage": true,
8+
"coverageDirectory": "coverage",
9+
"collectCoverageFrom": ["<rootDir>/src/**/*.service.ts"],
10+
"coverageThreshold": {
11+
"global": {
12+
"branches": 100,
13+
"functions": 100,
14+
"lines": 100,
15+
"statements": 100
16+
}
17+
},
18+
"moduleFileExtensions": ["js", "ts", "json"],
19+
"transform": {
20+
"^.+\\.(t|j)s$": "ts-jest"
21+
},
22+
"modulePathIgnorePatterns": ["<rootDir>/dist"],
2523

26-
"coverageReporters": ["text", "lcov", "html"],
27-
"coveragePathIgnorePatterns": [
28-
"<rootDir>/src/generated/",
29-
"<rootDir>/src/main.ts",
30-
"<rootDir>/src/app/app.controller.ts",
31-
"<rootDir>/src/swagger.ts"
32-
]
24+
"coverageReporters": ["text", "lcov", "html"],
25+
"coveragePathIgnorePatterns": [
26+
"<rootDir>/src/generated/",
27+
"<rootDir>/src/main.ts",
28+
"<rootDir>/src/app/app.controller.ts",
29+
"<rootDir>/src/swagger.ts"
30+
]
3331
}

0 commit comments

Comments
 (0)