generated from Medici-Mansion/basic-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.2.0
- Loading branch information
Showing
17 changed files
with
294 additions
and
15 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "shinnyang", | ||
"version": "0.1.9", | ||
"version": "0.2.0", | ||
"description": "", | ||
"author": { | ||
"name": "Medici", | ||
|
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 { AuthService } from '../auth.service'; | ||
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; | ||
import { Request } from 'express'; | ||
import { Observable } from 'rxjs'; | ||
|
||
@Injectable() | ||
export class OptinalAccessGuard implements CanActivate { | ||
constructor(private readonly authService: AuthService) {} | ||
|
||
canActivate( | ||
context: ExecutionContext, | ||
): boolean | Promise<boolean> | Observable<boolean> { | ||
const request = context.switchToHttp().getRequest() as Request; | ||
const token = request.headers.authorization?.replace('Bearer ', ''); | ||
if (token) { | ||
const payload = this.authService.verify(token, { | ||
secret: process.env.SALT, | ||
}); | ||
request['user'] = payload; | ||
} | ||
|
||
return true; | ||
} | ||
} |
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
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,18 @@ | ||
import { IsUUID } from 'class-validator'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class UserCatPatchDto { | ||
@ApiProperty({ | ||
description: '고양이아이디', | ||
example: 'be17e0ab-6463-4db8-bdfa-bc9011193038', | ||
}) | ||
@IsUUID('all') | ||
catId: string; | ||
|
||
@ApiProperty({ | ||
description: '악세사리아이디', | ||
example: 'be17e0ab-6463-4db8-bdfa-bc9011193038', | ||
}) | ||
@IsUUID('all') | ||
accessoryId: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { CatDTO } from './cat.dto'; | ||
import { AccessoryDTO } from './accessory.dto'; | ||
import { IsString, IsUUID } from 'class-validator'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class UserCatDto { | ||
@ApiProperty({ | ||
description: '냥이 아이디', | ||
example: 'be17e0ab-6463-4db8-bdfa-bc9011193038', | ||
}) | ||
@IsUUID('all') | ||
catId: string; | ||
|
||
@ApiProperty({ description: '냥이 이름', example: '우무' }) | ||
@IsString() | ||
catName: string; | ||
|
||
@ApiProperty({ description: '냥이 객체코드 (영어이름)', example: 'umu' }) | ||
@IsString() | ||
catCode: string; | ||
|
||
@ApiProperty({ | ||
description: '악세사리 아이디', | ||
example: '53227c7f-9dde-4adb-b448-69664fcae813', | ||
nullable: true, | ||
required: false, | ||
}) | ||
@IsUUID('all') | ||
accessoryId?: string; | ||
|
||
@ApiProperty({ | ||
description: '악세사리 이름', | ||
example: '빵 모자', | ||
nullable: true, | ||
required: false, | ||
}) | ||
@IsString() | ||
accessoryName?: string; | ||
|
||
@ApiProperty({ | ||
description: '악세사리 객체코드 ', | ||
example: 'AC-H-1', | ||
nullable: true, | ||
required: false, | ||
}) | ||
@IsString() | ||
accessoryCode?: string; | ||
|
||
constructor(catDto: CatDTO, accessoryDto: AccessoryDTO) { | ||
if (accessoryDto) { | ||
this.accessoryCode = accessoryDto.code; | ||
this.accessoryId = accessoryDto.id; | ||
this.accessoryName = accessoryDto.name; | ||
} | ||
this.catCode = catDto.code; | ||
this.catId = catDto.id; | ||
this.catName = catDto.name; | ||
} | ||
} |
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,49 @@ | ||
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm'; | ||
import { BaseEntity } from './base.entity'; | ||
import { User } from 'src/users/entities/user.entity'; | ||
import { Cats } from './cats.entity'; | ||
import { Accessories } from './accessories.entity'; | ||
|
||
@Entity({ name: 'user_cat' }) | ||
export class UserCatEntity extends BaseEntity { | ||
@Column({ | ||
name: 'user_id', | ||
comment: '유저아이디', | ||
unique: false, | ||
nullable: false, | ||
}) | ||
userId: string; | ||
|
||
@ManyToOne(() => User, (user) => user.id, { | ||
createForeignKeyConstraints: false, | ||
}) | ||
@JoinColumn({ name: 'user_id' }) | ||
user: User; | ||
|
||
@Column({ | ||
name: 'cat_id', | ||
comment: '고양이아이디', | ||
unique: false, | ||
nullable: false, | ||
}) | ||
catId: string; | ||
|
||
@ManyToOne(() => Cats, (cats) => cats.id, { | ||
createForeignKeyConstraints: false, | ||
}) | ||
@JoinColumn({ name: 'cat_id' }) | ||
cat: Cats; | ||
|
||
@Column({ | ||
name: 'accessory_id', | ||
comment: '악세사리아이디', | ||
unique: false, | ||
nullable: true, | ||
}) | ||
accessoryId: string; | ||
@ManyToOne(() => Accessories, (accessories) => accessories.id, { | ||
createForeignKeyConstraints: false, | ||
}) | ||
@JoinColumn({ name: 'accessory_id' }) | ||
accessory: Accessories; | ||
} |
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,9 @@ | ||
import { DataSource, Repository } from 'typeorm'; | ||
import { UserCatEntity } from './entities/user-cat.entity'; | ||
import { InjectDataSource } from '@nestjs/typeorm'; | ||
|
||
export class UserCatRepository extends Repository<UserCatEntity> { | ||
constructor(@InjectDataSource() dataSource: DataSource) { | ||
super(UserCatEntity, dataSource.createEntityManager()); | ||
} | ||
} |
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
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
Oops, something went wrong.