JavaScript
-
[Vue] Vuelidate object property에 validation 적용 방법JavaScript/Vue 2020. 12. 21. 18:29
public class Exaplme extends Vue { private signupInfo: ISignupInfo = { email: "", password: "", name: "" }; @Validations() validations = { signupInfo: { email: { required, email }, password: { required, minLength: minLength(4) }, name: { required } }, passwordCheck: { required, minLength: minLength(4) } }; }
-
[Vue] Vue Apollo GraphQL Authorization(Nest.js)JavaScript/Vue 2020. 12. 4. 11:06
1. Nest.js Auth module GraphQL로 Guard를 사용하려면 AuthGuard 클래스의 getRequest() 메소드를 오버라이드 해야함 @Injectable() export class JwtAuthGuard extends AuthGuard('jwt') { getRequest(context: ExecutionContext) { const ctx = GqlExecutionContext.create(context); return ctx.getContext().req; } } @Module({ imports: [ GraphQLModule.forRoot({ autoSchemaFile: 'schema.gql', context: ({ req }) => ({ req }), }), AuthModul..
-
[NestJS] 순환 의존성(Circular Dependency) 해결 방법JavaScript/NestJS 2020. 11. 30. 11:09
Circular Dependency 원인 NestJS Module이 서로 import 하면 순환 의존성 문제 발생 @Module({ imports: [PostModule)], providers: [ CommentResolver, CommentSubResolver, CommentService, CommonCommentService, ], exports: [CommentService], }) export class CommentModule {} @Module({ imports: [CommentModule)], providers: [ PostResolver, PostSubResolver, PostService, CommonPostService, ], exports: [PostService], }) export..
-
[JS] 객체 배열 정렬JavaScript 2020. 11. 30. 10:11
const commentCountList = [ { postId: 1, commentCount: '5' }, { postId: 2, commentCount: '1' }, { postId: 3, commentCount: '1' }, { postId: 4, commentCount: '3' }, { postId: 5, commentCount: '1' }, { postId: 6, commentCount: '4' } ] const result = commentCountList .sort((target1, target2) => { return target1.commentCount > target2.commentCount ? -1 : target1.commentCount < target2.commentCount ? ..
-
[NestJS] GraphQL Input Type Enum Field 사용 방법JavaScript/NestJS 2020. 11. 25. 11:17
enum에 registerEnumType 추가해줘야 사용 가능 @InputType() export class PracticeInputType { @IsNumber() @Field(() => Int) public id: number; @IsEnum(PracticeType) @Field(() => PracticeType) public practiceType: PracticeType; } export enum PracticeType { Test1 = 'test1', Test2 = 'test2', Test3 = 'test3', } registerEnumType(PracticeType, { name: 'PracticeType' });
-
[NestJS] NestJS DataLoaderJavaScript/NestJS 2020. 11. 21. 20:12
NestJS Data Loader N+1 문제를 해결하기 위해 사용 Installation npm i nestjs-dataloader --save 사용 방법 1. DataLoader 생성 첫 번째 제네릭은 DB의 ID 타입 두 번째 제네릭은 return될 타입 import { Injectable } from '@nestjs/common'; import * as DataLoader from 'dataloader'; import { NestDataLoader } from 'nestjs-dataloader'; import { RateplanService } from '../service/rateplan.service'; import { RateplanObjectType } from '@/graphql/rate..
-
[Vue] Property DecoratorJavaScript/Vue 2020. 11. 7. 13:08
Property Decorator @Prop @Prop(options: (PropOptions | Constructor[] | Constructor) = {}) import { Vue, Component, Prop } from 'vue-property-decorator' @Component export default class YourComponent extends Vue { @Prop(Number) readonly propA: number | undefined @Prop({ default: 'default value' }) readonly propB!: string @Prop([String, Boolean]) readonly propC: string | boolean | undefined } 각 Pro..