Skip to content

Commit 32212c9

Browse files
committed
[#3] 회원가입 API 개선
1 parent 912164f commit 32212c9

File tree

5 files changed

+36
-22
lines changed

5 files changed

+36
-22
lines changed

src/app.module.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@ import { AuthModule } from './auth/auth.module';
1515
],
1616
isGlobal: true,
1717
}),
18-
UsersModule,
1918
TypeOrmModule.forRoot({
2019
type: 'mysql',
21-
host: 'localhost',
22-
port: 3306,
23-
username: 'root',
24-
password: '1234',
25-
database: 'conn_test',
20+
host: process.env.DATABASE_HOST,
21+
port: parseInt(process.env.DATABASE_PORT),
22+
username: process.env.DATABASE_USERNAME,
23+
password: process.env.DATABASE_PASSWORD,
24+
database: process.env.DATABASE_DBNAME,
2625
entities: [__dirname + `/**/*.entity{.ts,.js}`],
2726
synchronize: false
2827
}),
28+
UsersModule,
2929
AuthModule
3030
],
3131
controllers: [AppController],
32-
providers: [AppService, ],
32+
providers: [AppService],
3333
})
34-
export class AppModule {}
34+
export class AppModule {
35+
36+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { PartialType } from '@nestjs/mapped-types';
2-
import { userDto } from './user.dto';
2+
import { UserDto } from './user.dto';
33

4-
export class UpdateUserDto extends PartialType(userDto) {}
4+
export class UpdateUserDto extends PartialType(UserDto) {}

src/users/dto/user.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export class userDto {
1+
export class UserDto {
22
userNo: number;
33
userId: string;
44
userName: string;

src/users/users.controller.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,30 @@ export class UsersController {
2525
return '회원가입성공';
2626
}
2727

28-
@UseGuards(JwtAuthGuard)
29-
@Get('/')
30-
async getProfile(@Req() req: any){
31-
const user = req.user;
32-
return user;
33-
}
28+
// @UseGuards(JwtAuthGuard)
29+
// @Get('/')
30+
// async getProfile(@Req() req: any){
31+
// const user = req.user;
32+
// return user;
33+
// }
3434

3535

3636
@Get()
3737
findAll() {
3838
return this.usersService.findAll();
3939
}
4040

41-
@Get('/userNo')
41+
@Get('/:userNo')
4242
findOne(@Param('userNo', ParseIntPipe) userNo: number) {
4343
return this.usersService.findOne(userNo);
4444
}
4545

46-
@Patch('/userNo')
46+
@Patch('/:userNo')
4747
update(@Param('userNo', ParseIntPipe) userNo: number, @Body() updateUserDto: UpdateUserDto) {
4848
return this.usersService.update(userNo, updateUserDto);
4949
}
5050

51-
@Delete('/id')
51+
@Delete('/:id')
5252
remove(@Param('id') id: string) {
5353
return this.usersService.remove(+id);
5454
}

src/users/users.service.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,24 @@ export class UsersService {
2828
})
2929
}
3030

31+
async findbyUserNo(userNo: number){
32+
return await this.userRepository.findOne({
33+
where:{
34+
userNo,
35+
}
36+
})
37+
}
38+
3139
findAll() {
3240
return `This action returns all users`;
3341
}
3442

35-
findOne(id: number) {
36-
return `This action returns a #${id} user`;
43+
findOne(userNo: number) {
44+
return this.userRepository.findOne({
45+
where:{
46+
userNo,
47+
}
48+
})
3749
}
3850

3951
update(id: number, updateUserDto: UpdateUserDto) {

0 commit comments

Comments
 (0)