File tree 3 files changed +10
-12
lines changed
3 files changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ export class PostResponseDto implements IPostResponse {
63
63
if ( document . user && typeof document . user === "object" ) {
64
64
dto . user = {
65
65
id : document . user . _id . toString ( ) ,
66
- username : document . user . username || "Unknown" ,
66
+ username : ( document . user as unknown as IUserDocument ) . username || "Unknown" ,
67
67
} ;
68
68
} else {
69
69
// If user is not populated, just use the ID
Original file line number Diff line number Diff line change @@ -4,11 +4,7 @@ import { EntityId } from "@/types/common.types";
4
4
5
5
// Base interface (without Document methods)
6
6
export interface IPost {
7
- user : {
8
- _id : EntityId ;
9
- username : string ;
10
- email ?: string ;
11
- } ;
7
+ user : EntityId ;
12
8
content : string ;
13
9
imageUrl ?: string ;
14
10
likes : EntityId [ ] ;
@@ -47,7 +43,7 @@ export interface IPostModel extends Model<IPostDocument> {
47
43
const postSchema = new Schema < IPostDocument > (
48
44
{
49
45
user : {
50
- type : Schema . Types . Mixed ,
46
+ type : Schema . Types . ObjectId ,
51
47
ref : "User" ,
52
48
required : true ,
53
49
} ,
@@ -154,7 +150,7 @@ postSchema.statics.getRankedPosts = async function (options: {
154
150
{ $sort : { score : - 1 } } , // Sort by descending score
155
151
{ $skip : options . skip } ,
156
152
{ $limit : options . limit } ,
157
- {
153
+ {
158
154
$lookup : {
159
155
from : "users" , // The name of the users collection
160
156
localField : "user" ,
@@ -169,7 +165,7 @@ postSchema.statics.getRankedPosts = async function (options: {
169
165
] ) ,
170
166
this . countDocuments ( ) ,
171
167
] ) ;
172
-
168
+
173
169
return { posts, total } ;
174
170
} ;
175
171
// Export the model and return type
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ version: '3.8'
2
2
3
3
services :
4
4
backend :
5
+ restart : always
5
6
build :
6
7
context : ./backend
7
8
dockerfile : ../docker/backend.dockerfile
@@ -17,29 +18,28 @@ services:
17
18
- RECAPTCHA_SITE_KEY=${RECAPTCHA_SITE_KEY}
18
19
- NODE_ENV=${NODE_ENV}
19
20
volumes :
20
- - ./backend:/app
21
21
- /app/node_modules
22
22
depends_on :
23
23
- mongodb
24
24
networks :
25
25
- app-network
26
26
27
27
frontend :
28
+ restart : always
28
29
build :
29
30
context : ./frontend
30
31
dockerfile : ../docker/frontend.dockerfile
31
32
ports :
32
33
- " ${FRONTEND_PORT:-3000}:${FRONTEND_PORT:-3000}"
33
34
env_file :
34
35
- ./frontend/.env
35
- volumes :
36
- - ./frontend:/app # Only mount for development purposes
37
36
depends_on :
38
37
- backend
39
38
networks :
40
39
- app-network
41
40
42
41
mongodb :
42
+ restart : always
43
43
image : mongo:5
44
44
environment :
45
45
MONGO_INITDB_DATABASE : surge-social
@@ -50,6 +50,7 @@ services:
50
50
51
51
# Add Nginx reverse proxy for SSL termination
52
52
nginx :
53
+ restart : always
53
54
image : nginx:alpine
54
55
ports :
55
56
- " 80:80"
@@ -65,6 +66,7 @@ services:
65
66
66
67
# Automatically renew SSL certificates
67
68
certbot :
69
+ restart : always
68
70
image : certbot/certbot
69
71
container_name : certbot
70
72
volumes :
You can’t perform that action at this time.
0 commit comments