Skip to content

Commit 8f03f4a

Browse files
author
vinod
committed
fix user response type
1 parent 6571301 commit 8f03f4a

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

src/interface/common.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Types } from 'mongoose';
12
export interface responseData {
23
statusCode: Number;
34
timestamp: String;
@@ -9,4 +10,16 @@ export interface responseData {
910

1011
}
1112

13+
export interface userData {
14+
username?: String;
15+
first_name?: String;
16+
last_name?: String;
17+
activation_code?: String;
18+
email?: String;
19+
email_code?: String;
20+
password?: String;
21+
password_reset_code? :String
22+
_id? : Types.ObjectId | String| null
23+
}
24+
1225

src/users/dto/create-user.dto.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { IsNotEmpty, IsNumberString, IsStrongPassword } from 'class-validator';
33
export class CreateUserDto {
44
@IsNumberString()
55
@IsNotEmpty()
6-
username : { type : String }
7-
first_name : { type : String }
8-
last_name : { type : String }
6+
username : String
7+
first_name : String
8+
last_name : String
99
@IsStrongPassword({ minLength: 8, minLowercase: 1, minNumbers: 1, minSymbols: 1, minUppercase: 1})
10-
password : { type : String }
11-
password_reset_code : { type : String }
12-
email : { type : String }
13-
email_code : { type : String }
10+
password : String
11+
password_reset_code : String
12+
email : String
13+
email_code : String
1414
}

src/users/schemas/user.schema.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ export class User {
2121
password: string;
2222
@Prop({ type : String })
2323
password_reset_code
24-
@Prop()
25-
_id: string | null;
2624
}
2725

2826
export const UserSchema = SchemaFactory.createForClass(User);

src/users/users.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Model } from 'mongoose';
44
import { CreateUserDto } from './dto/create-user.dto';
55
import { User } from './schemas/user.schema';
66
import * as bcrypt from 'bcrypt';
7+
import { userData } from 'src/interface/common';
78

89
@Injectable()
910
export class UserService {
@@ -17,15 +18,15 @@ export class UserService {
1718
return createdCat;
1819
}
1920

20-
async findAll(): Promise<User[]> {
21+
async findAll(): Promise<userData[]> {
2122
return this.userModel.find().exec();
2223
}
2324

24-
async findOne(id: string): Promise<User> {
25+
async findOne(id: string): Promise<userData> {
2526
return this.userModel.findOne({ _id: id }).exec();
2627
}
2728

28-
async findOneUser(email: string): Promise<User> {
29+
async findOneUser(email: string): Promise<userData> {
2930
return this.userModel.findOne({ email: email }).exec();
3031
}
3132
async delete(id: string) {

0 commit comments

Comments
 (0)