Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] 회원가입 API 구현 #29

Merged
merged 10 commits into from
Nov 7, 2024
2 changes: 1 addition & 1 deletion BE/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Controller, Get, Body } from '@nestjs/common';
import { AuthService } from './auth.service';
import { AuthCredentialsDto } from './dto/auth-credential-dto';
import { AuthCredentialsDto } from './dto/authCredentials.dto';
Copy link
Collaborator

@uuuo3o uuuo3o Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 이런 네이밍 규칙도 나중에 이야기해보면 좋겠네요!
저는 케밥 케이스 방식을 써서
auth-credential.dto 이런 식으로 작성하고 있었거든요!

Copy link
Collaborator Author

@jinddings jinddings Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런 네이밍 규칙도 나중에 이야기해보면 좋겠네요! 저는 케밥 케이스 방식을 써서 auth-credential.dto 이런 식으로 작성하고 있었거든요!

어라? 저도 진님이 하신게 기억나서 고쳐논건데 왜 다시 되돌아 왔는지 모르겠네요 ㅎㅎ
한번 이야기 해보면 좋을거 같아요!


@Controller('auth')
export class AuthController {
Expand Down
2 changes: 2 additions & 0 deletions BE/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Injectable } from '@nestjs/common';
import { UserRepository } from './user.repository';
import { AuthCredentialsDto } from './dto/authCredentials.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { bcrypt } from 'bcrypt';

@Injectable()
export class AuthService {
Expand Down
7 changes: 4 additions & 3 deletions BE/src/auth/user.repository.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { Injectable } from '@nestjs/common';
import { InjectDataSource } from '@nestjs/typeorm';
import { InjectDataSource, InjectRepository } from '@nestjs/typeorm';
import { User } from './user.entity';
import { DataSource, Repository } from 'typeorm';
import { AuthCredentialsDto } from './dto/auth-credential-dto';
import { AuthCredentialsDto } from './dto/authCredentials.dto';

@Injectable()
export class UserRepository extends Repository<User> {
constructor(@InjectDataSource() dataSource: DataSource) {
super(User, dataSource.createEntityManager());
}

async createUser(authCredentialsDto: AuthCredentialsDto): Promise<void> {
async registerUser(authCredentialsDto: AuthCredentialsDto) {
const { email, password } = authCredentialsDto;
const user = this.create({ email, password });

await this.save(user);
}
}