@@ -109,7 +109,7 @@ import { InjectClient } from 'nest-postgres';
109
109
export class UsersService {
110
110
constructor (@InjectClient () private readonly pg : Client ) {}
111
111
112
- public async findAll(): Promise <any > {
112
+ public async findAll(): Promise <User [] > {
113
113
const users = await this .pg .query (' SELECT * FROM users' );
114
114
return users .rows ;
115
115
}
@@ -127,7 +127,7 @@ export class UsersController {
127
127
constructor (private readonly usersService : UsersService ) {}
128
128
129
129
@Get ()
130
- async getAllUsers() {
130
+ async getAllUsers(): Promise < User []> {
131
131
return await this .usersService .findAll ();
132
132
}
133
133
}
@@ -171,6 +171,7 @@ PostService:
171
171
import { Client } from ' pg' ;
172
172
import { InjectConnection } from ' nest-postgres' ;
173
173
import { CreatePostDto } from ' ./dto/create-post.dto' ;
174
+ import { Post } from ' ./interfaces/post.interface' ;
174
175
175
176
@Injectable ()
176
177
export class PostService {
@@ -179,12 +180,12 @@ export class PostService {
179
180
private dbConnection : Client ,
180
181
) {}
181
182
182
- public async findAll(): Promise <any > {
183
+ public async findAll(): Promise <User [] > {
183
184
const users = await this .dbConnection .query (' SELECT * FROM posts' );
184
185
return users .rows ;
185
186
}
186
187
187
- public async create(createPostDto : CreatePostDto ): Promise <any > {
188
+ public async create(createPostDto : CreatePostDto ): Promise <User > {
188
189
try {
189
190
const user = await this .dbConnection .query (
190
191
' INSERT INTO posts (title, description) VALUES ($1, $2) RETURNING *' ,
@@ -204,6 +205,7 @@ UsersService:
204
205
import { Client } from ' pg' ;
205
206
import { InjectConnection } from ' nest-postgres' ;
206
207
import { CreateUserDto } from ' ./dto/create-user.dto' ;
208
+ import { User } from ' ./interfaces/user.interface' ;
207
209
208
210
@Injectable ()
209
211
export class UsersService {
@@ -212,12 +214,12 @@ export class UsersService {
212
214
private dbConnection : Client ,
213
215
) {}
214
216
215
- public async findAll(): Promise <any > {
217
+ public async findAll(): Promise <User [] > {
216
218
const users = await this .dbConnection .query (' SELECT * FROM users' );
217
219
return users .rows ;
218
220
}
219
221
220
- public async create(createUserDto : CreateUserDto ): Promise <any > {
222
+ public async create(createUserDto : CreateUserDto ): Promise <User > {
221
223
try {
222
224
const user = await this .dbConnection .query (
223
225
' INSERT INTO users (firstName, lastName) VALUES ($1, $2) RETURNING *' ,
0 commit comments