-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0ca3b4
commit 781167f
Showing
635 changed files
with
15,514 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { IsString, IsNotEmpty, IsAlphanumeric, MinLength } from 'class-validator'; | ||
|
||
export class CreateUserDto { | ||
@IsString() | ||
name: string; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
username: string; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
password: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { NestExpressApplication } from '@nestjs/platform-express'; | ||
import { AppModule } from '../../app.module'; | ||
import { Test } from '@nestjs/testing'; | ||
import { DataSource } from 'typeorm'; | ||
import { appSetting } from '../../main'; | ||
import * as supertest from 'supertest'; | ||
import { User } from '../../user/models/user.entity'; | ||
import { UserFixture } from '../fixture/user.fixture'; | ||
import { HttpStatus } from '@nestjs/common'; | ||
|
||
describe('signup test', () => { | ||
let testServer: NestExpressApplication; | ||
let dataSource: DataSource; | ||
let user: User; | ||
|
||
beforeAll(async () => { | ||
const module = await Test.createTestingModule({ | ||
imports: [AppModule], | ||
}).compile(); | ||
|
||
testServer = module.createNestApplication<NestExpressApplication>(); | ||
dataSource = testServer.get(DataSource); | ||
await dataSource.synchronize(true); | ||
appSetting(testServer); | ||
|
||
await testServer.init(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await dataSource.synchronize(true); | ||
|
||
user = await UserFixture.create({ | ||
name: 'hi', | ||
username: 'hello', | ||
password: 'world', | ||
}); | ||
}); | ||
|
||
it('Check if the username already exists', async () => { | ||
await supertest(testServer.getHttpServer()) | ||
.post('/user/signup') | ||
.send({ | ||
name: 'John Doe', | ||
username: 'hello', | ||
password: 'password123', | ||
}) | ||
.expect(HttpStatus.CONFLICT); | ||
}); | ||
|
||
afterAll(async () => { | ||
await testServer.close(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Controller, Post, Body, ConflictException } from '@nestjs/common'; | ||
import { UserService } from './user.service'; | ||
import { User } from './models/user.entity'; | ||
import {CreateUserDto} from "../auth/controller/signup-dtos/createuser.dto"; | ||
|
||
@Controller('user') | ||
export class UserController { | ||
constructor(private readonly userService: UserService) {} | ||
|
||
|
||
@Post('signup') | ||
async signUp(@Body() createUserDto: CreateUserDto): Promise<User> { | ||
const existingUser = await this.userService.findByUsername(createUserDto.username); | ||
if (existingUser) { | ||
throw new ConflictException('Username already exists'); | ||
} | ||
return this.userService.create(createUserDto); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { UserController } from './user.controller'; | ||
import { UserService } from './user.service'; | ||
import { User } from './models/user.entity'; | ||
|
||
@Module({}) | ||
@Module({ | ||
imports: [TypeOrmModule.forFeature([User])], | ||
controllers: [UserController], | ||
providers: [UserService], | ||
}) | ||
export class UserModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { User } from './models/user.entity'; | ||
import { CreateUserDto } from '../auth/controller/signup-dtos/createuser.dto'; | ||
|
||
@Injectable() | ||
export class UserService { | ||
constructor( | ||
@InjectRepository(User) | ||
private usersRepository: Repository<User>, | ||
) {} | ||
|
||
async create(createUserDto: CreateUserDto): Promise<User> { | ||
const { name, username, password } = createUserDto; | ||
const user = this.usersRepository.create({ name, username, password }); | ||
return this.usersRepository.save(user); | ||
} | ||
|
||
async findByUsername(username: string): Promise<User | undefined> { | ||
const user = await this.usersRepository.findOne({ where: { username } }); | ||
return user ? user : undefined; // Return undefined when no user is found | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+17 Bytes
frontend/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#Thu Oct 12 16:52:28 KST 2023 | ||
gradle.version=8.0 |
Binary file not shown.
Binary file not shown.
Empty file.
Oops, something went wrong.