|
80 | 80 | ```
|
81 | 81 |
|
82 | 82 | 3. **Environment Configuration**
|
83 |
| - Create `.env` and `.env.docker` files with the following variables: |
| 83 | + The service includes a pre-configured `.env.docker` file with the following variables: |
84 | 84 | ```env
|
85 | 85 | # App Configuration
|
86 |
| - NODE_ENV=development |
87 |
| - APP_NAME=NestJS Post Service |
88 |
| - APP_DEBUG=false |
89 |
| - APP_CORS_ORIGINS=http://localhost:3000 |
| 86 | + NODE_ENV="local" |
| 87 | + APP_NAME="@backendworks/post" |
| 88 | + APP_CORS_ORIGINS="*" |
| 89 | + APP_DEBUG=true |
90 | 90 |
|
91 | 91 | # HTTP Configuration
|
92 | 92 | HTTP_ENABLE=true
|
93 |
| - HTTP_HOST=0.0.0.0 |
| 93 | + HTTP_HOST="0.0.0.0" |
94 | 94 | HTTP_PORT=9002
|
95 |
| - HTTP_VERSIONING_ENABLE=false |
| 95 | + HTTP_VERSIONING_ENABLE=true |
96 | 96 | HTTP_VERSION=1
|
97 | 97 |
|
98 | 98 | # Database Configuration
|
99 |
| - DATABASE_URL=postgresql://username:password@localhost:5432/post_db |
| 99 | + DATABASE_URL="postgresql://admin:master123@localhost:5432/postgres?schema=public" |
| 100 | +
|
| 101 | + # JWT Configuration |
| 102 | + ACCESS_TOKEN_SECRET_KEY="EAJYjNJUnRGJ6uq1YfGw4NG1pd1z102J" |
| 103 | + ACCESS_TOKEN_EXPIRED="1d" |
| 104 | + REFRESH_TOKEN_SECRET_KEY="LcnlpiuHIJ6eS51u1mcOdk0P49r2Crwu" |
| 105 | + REFRESH_TOKEN_EXPIRED="7d" |
100 | 106 |
|
101 | 107 | # Redis Configuration
|
102 |
| - REDIS_URL=redis://localhost:6379 |
103 |
| - REDIS_KEY_PREFIX=post: |
| 108 | + REDIS_URL="redis://localhost:6379" |
| 109 | + REDIS_KEY_PREFIX="post:" |
104 | 110 | REDIS_TTL=3600
|
105 | 111 |
|
106 | 112 | # gRPC Configuration
|
107 |
| - GRPC_URL=0.0.0.0:50052 |
108 |
| - GRPC_PACKAGE=post |
109 |
| -
|
110 |
| - # Auth Service Configuration (for gRPC communication) |
111 |
| - AUTH_SERVICE_URL=0.0.0.0:50051 |
112 |
| -
|
113 |
| - # Monitoring (Optional) |
114 |
| - SENTRY_DSN=your-sentry-dsn |
| 113 | + GRPC_URL="0.0.0.0:50052" |
| 114 | + GRPC_PACKAGE="post" |
| 115 | + GRPC_AUTH_URL="0.0.0.0:50051" |
| 116 | + GRPC_AUTH_PACKAGE="auth" |
115 | 117 | ```
|
116 | 118 |
|
117 | 119 | 4. **Database Setup**
|
@@ -155,14 +157,12 @@ docker run -p 9002:9002 post-service
|
155 | 157 | ### Post Management Endpoints
|
156 | 158 |
|
157 | 159 | #### Public Endpoints
|
158 |
| -- `GET /posts` - List all posts (paginated) |
159 |
| -- `GET /posts/:id` - Get post by ID |
| 160 | +- `GET /post` - List all posts (paginated) |
160 | 161 |
|
161 | 162 | #### Protected Endpoints
|
162 |
| -- `POST /posts` - Create new post |
163 |
| -- `PUT /posts/:id` - Update post |
164 |
| -- `DELETE /posts/:id` - Delete post |
165 |
| -- `POST /posts/bulk-delete` - Bulk delete posts |
| 163 | +- `POST /post` - Create new post |
| 164 | +- `PUT /post/:id` - Update post |
| 165 | +- `DELETE /post/batch` - Bulk delete posts |
166 | 166 |
|
167 | 167 | ### Query Parameters
|
168 | 168 |
|
@@ -193,25 +193,6 @@ docker run -p 9002:9002 post-service
|
193 | 193 | - `UpdatePost` - Update an existing post
|
194 | 194 | - `DeletePost` - Delete a post
|
195 | 195 |
|
196 |
| -## 🗄️ Database Schema |
197 |
| - |
198 |
| -### Post Model |
199 |
| -```sql |
200 |
| -CREATE TABLE posts ( |
201 |
| - id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
202 |
| - title VARCHAR NOT NULL, |
203 |
| - content TEXT NOT NULL, |
204 |
| - images TEXT[] DEFAULT '{}', |
205 |
| - created_by UUID NOT NULL, |
206 |
| - updated_by UUID, |
207 |
| - deleted_by UUID, |
208 |
| - created_at TIMESTAMP DEFAULT NOW(), |
209 |
| - updated_at TIMESTAMP DEFAULT NOW(), |
210 |
| - deleted_at TIMESTAMP, |
211 |
| - is_deleted BOOLEAN DEFAULT false |
212 |
| -); |
213 |
| -``` |
214 |
| - |
215 | 196 | ## 🔧 Configuration
|
216 | 197 |
|
217 | 198 | The service uses a modular configuration system with environment-specific settings:
|
|
0 commit comments