Skip to content

Commit

Permalink
[#3] 회원가입 API 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
sejin5 committed Dec 12, 2024
1 parent 912164f commit dda69fe
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 33 deletions.
84 changes: 73 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@nestjs/platform-express": "^10.0.0",
"@nestjs/typeorm": "^10.0.2",
"@types/passport-jwt": "^4.0.1",
"axios": "^1.7.9",
"bcrypt": "^5.1.1",
"bcrypto": "^5.5.2",
"class-validator": "^0.14.1",
Expand All @@ -38,6 +39,7 @@
"passport": "^0.7.0",
"passport-jwt": "^4.0.1",
"passport-local": "^1.0.0",
"qs": "^6.13.1",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1",
"typeorm": "^0.3.20"
Expand Down
18 changes: 10 additions & 8 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ import { AuthModule } from './auth/auth.module';
],
isGlobal: true,
}),
UsersModule,
TypeOrmModule.forRoot({
type: 'mysql',
host: 'localhost',
port: 3306,
username: 'root',
password: '1234',
database: 'conn_test',
host: process.env.DATABASE_HOST,
port: parseInt(process.env.DATABASE_PORT),
username: process.env.DATABASE_USERNAME,
password: process.env.DATABASE_PASSWORD,
database: process.env.DATABASE_DBNAME,
entities: [__dirname + `/**/*.entity{.ts,.js}`],
synchronize: false
}),
UsersModule,
AuthModule
],
controllers: [AppController],
providers: [AppService, ],
providers: [AppService],
})
export class AppModule {}
export class AppModule {

}
4 changes: 2 additions & 2 deletions src/users/dto/update-user.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PartialType } from '@nestjs/mapped-types';
import { userDto } from './user.dto';
import { UserDto } from './user.dto';

export class UpdateUserDto extends PartialType(userDto) {}
export class UpdateUserDto extends PartialType(UserDto) {}
2 changes: 1 addition & 1 deletion src/users/dto/user.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class userDto {
export class UserDto {
userNo: number;
userId: string;
userName: string;
Expand Down
18 changes: 9 additions & 9 deletions src/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@ export class UsersController {
return '회원가입성공';
}

@UseGuards(JwtAuthGuard)
@Get('/')
async getProfile(@Req() req: any){
const user = req.user;
return user;
}
// @UseGuards(JwtAuthGuard)
// @Get('/')
// async getProfile(@Req() req: any){
// const user = req.user;
// return user;
// }


@Get()
findAll() {
return this.usersService.findAll();
}

@Get('/userNo')
@Get('/:userNo')
findOne(@Param('userNo', ParseIntPipe) userNo: number) {
return this.usersService.findOne(userNo);
}

@Patch('/userNo')
@Patch('/:userNo')
update(@Param('userNo', ParseIntPipe) userNo: number, @Body() updateUserDto: UpdateUserDto) {
return this.usersService.update(userNo, updateUserDto);
}

@Delete('/id')
@Delete('/:id')
remove(@Param('id') id: string) {
return this.usersService.remove(+id);
}
Expand Down
16 changes: 14 additions & 2 deletions src/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,24 @@ export class UsersService {
})
}

async findbyUserNo(userNo: number){
return await this.userRepository.findOne({
where:{
userNo,
}
})
}

findAll() {
return `This action returns all users`;
}

findOne(id: number) {
return `This action returns a #${id} user`;
findOne(userNo: number) {
return this.userRepository.findOne({
where:{
userNo,
}
})
}

update(id: number, updateUserDto: UpdateUserDto) {
Expand Down

0 comments on commit dda69fe

Please sign in to comment.