장재혁

Fix semi colon

......@@ -22,5 +22,12 @@ module.exports = {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
semi: [2, 'never'],
'prettier/prettier': [
'error',
{
semi: false,
},
};
],
},
}
......
{
"singleQuote": true,
"trailingComma": "all"
"trailingComma": "all",
"semi": false
}
\ No newline at end of file
......
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { Test, TestingModule } from '@nestjs/testing'
import { AppController } from './app.controller'
import { AppService } from './app.service'
describe('AppController', () => {
let appController: AppController;
let appController: AppController
beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
}).compile()
appController = app.get<AppController>(AppController);
});
appController = app.get<AppController>(AppController)
})
describe('root', () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!');
});
});
});
expect(appController.getHello()).toBe('Hello World!')
})
})
})
......
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import { Controller, Get } from '@nestjs/common'
import { AppService } from './app.service'
@Controller()
export class AppController {
......@@ -7,6 +7,6 @@ export class AppController {
@Get()
getHello(): string {
return this.appService.getHello();
return this.appService.getHello()
}
}
......
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { TypeOrmModule } from '@nestjs/typeorm';
import { join } from 'path';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { MypageModule } from './mypage/mypage.module';
import { PostModule } from './post/post.module';
import { CommentModule } from './comment/comment.module';
import { UserModule } from './user/user.module';
import { LikeableService } from './likeable/likeable.service';
import { LikeableModule } from './likeable/likeable.module';
import { Module } from '@nestjs/common'
import { GraphQLModule } from '@nestjs/graphql'
import { TypeOrmModule } from '@nestjs/typeorm'
import { join } from 'path'
import { AppController } from './app.controller'
import { AppService } from './app.service'
import { MypageModule } from './mypage/mypage.module'
import { PostModule } from './post/post.module'
import { CommentModule } from './comment/comment.module'
import { UserModule } from './user/user.module'
import { LikeableService } from './likeable/likeable.service'
import { LikeableModule } from './likeable/likeable.module'
@Module({
imports: [
......
import { Injectable } from '@nestjs/common';
import { Injectable } from '@nestjs/common'
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
return 'Hello World!'
}
}
......
import { Module } from '@nestjs/common';
import { CommentService } from './comment.service';
import { CommentResolver } from './comment.resolver';
import { Module } from '@nestjs/common'
import { CommentService } from './comment.service'
import { CommentResolver } from './comment.resolver'
@Module({
providers: [CommentService, CommentResolver],
......
import { Test, TestingModule } from '@nestjs/testing';
import { CommentResolver } from './comment.resolver';
import { Test, TestingModule } from '@nestjs/testing'
import { CommentResolver } from './comment.resolver'
describe('CommentResolver', () => {
let resolver: CommentResolver;
let resolver: CommentResolver
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [CommentResolver],
}).compile();
}).compile()
resolver = module.get<CommentResolver>(CommentResolver);
});
resolver = module.get<CommentResolver>(CommentResolver)
})
it('should be defined', () => {
expect(resolver).toBeDefined();
});
});
expect(resolver).toBeDefined()
})
})
......
import { Resolver } from '@nestjs/graphql';
import { Resolver } from '@nestjs/graphql'
@Resolver()
export class CommentResolver {}
......
import { Test, TestingModule } from '@nestjs/testing';
import { CommentService } from './comment.service';
import { Test, TestingModule } from '@nestjs/testing'
import { CommentService } from './comment.service'
describe('CommentService', () => {
let service: CommentService;
let service: CommentService
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [CommentService],
}).compile();
}).compile()
service = module.get<CommentService>(CommentService);
});
service = module.get<CommentService>(CommentService)
})
it('should be defined', () => {
expect(service).toBeDefined();
});
});
expect(service).toBeDefined()
})
})
......
import { Injectable } from '@nestjs/common';
import { Injectable } from '@nestjs/common'
@Injectable()
export class CommentService {}
......
import { Module } from '@nestjs/common';
import { LikeableResolver } from './likeable.resolver';
import { Module } from '@nestjs/common'
import { LikeableResolver } from './likeable.resolver'
@Module({
providers: [LikeableResolver],
......
import { Test, TestingModule } from '@nestjs/testing';
import { LikeableResolver } from './likeable.resolver';
import { Test, TestingModule } from '@nestjs/testing'
import { LikeableResolver } from './likeable.resolver'
describe('LikeableResolver', () => {
let resolver: LikeableResolver;
let resolver: LikeableResolver
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [LikeableResolver],
}).compile();
}).compile()
resolver = module.get<LikeableResolver>(LikeableResolver);
});
resolver = module.get<LikeableResolver>(LikeableResolver)
})
it('should be defined', () => {
expect(resolver).toBeDefined();
});
});
expect(resolver).toBeDefined()
})
})
......
import { Resolver } from '@nestjs/graphql';
import { Resolver } from '@nestjs/graphql'
@Resolver()
export class LikeableResolver {}
......
import { Injectable } from '@nestjs/common';
import { Injectable } from '@nestjs/common'
@Injectable()
export class LikeableService {}
......
import { Field, InputType } from '@nestjs/graphql';
import { Entity } from 'typeorm';
import { Field, InputType, PartialType, PickType } from '@nestjs/graphql';
import { IsNumber } from 'class-validator';
import { Post } from '../model/post.entity';
@Entity()
@InputType()
export class GetPostInput {
@Field()
......@@ -13,3 +13,17 @@ export class GetPostInput {
@Field({ nullable: true })
category?: string;
}
@InputType()
export class CreatePostInput extends PickType(
Post,
['category', 'content', 'title'],
InputType,
) {}
@InputType()
export class UpdatePostInput extends PartialType(CreatePostInput) {
@Field()
@IsNumber()
id: number;
}
......
import { Module } from '@nestjs/common';
import { PostService } from './post.service';
import { PostResolver } from './post.resolver';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Post } from './post.entity';
import { Module } from '@nestjs/common'
import { PostService } from './post.service'
import { PostResolver } from './post.resolver'
import { TypeOrmModule } from '@nestjs/typeorm'
import { Post } from './model/post.entity'
@Module({
imports: [TypeOrmModule.forFeature([Post])],
......
import { Test, TestingModule } from '@nestjs/testing';
import { PostResolver } from './post.resolver';
import { Test, TestingModule } from '@nestjs/testing'
import { PostResolver } from './post.resolver'
describe('PostResolver', () => {
let resolver: PostResolver;
let resolver: PostResolver
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [PostResolver],
}).compile();
}).compile()
resolver = module.get<PostResolver>(PostResolver);
});
resolver = module.get<PostResolver>(PostResolver)
})
it('should be defined', () => {
expect(resolver).toBeDefined();
});
});
expect(resolver).toBeDefined()
})
})
......
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
import { PostService } from './post.service';
import { Post } from './post.entity';
import { GetPostInput } from './dto/post.input';
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql'
import { PostService } from './post.service'
import { Post } from './model/post.entity'
import { GetPostInput } from './dto/post.input'
@Resolver((of) => Post)
export class PostResolver {
......@@ -9,11 +9,11 @@ export class PostResolver {
@Query((returns) => [Post])
getPosts(): Promise<Post[]> {
return this.postService.findAll();
return this.postService.findAll()
}
@Query((returns) => Post)
getPost(@Args('id') id: number): Promise<Post> {
return this.postService.findOne(id);
return this.postService.findOne(id)
}
}
......
import { Test, TestingModule } from '@nestjs/testing';
import { PostService } from './post.service';
import { Test, TestingModule } from '@nestjs/testing'
import { PostService } from './post.service'
describe('PostService', () => {
let service: PostService;
let service: PostService
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [PostService],
}).compile();
}).compile()
service = module.get<PostService>(PostService);
});
service = module.get<PostService>(PostService)
})
it('should be defined', () => {
expect(service).toBeDefined();
});
});
expect(service).toBeDefined()
})
})
......
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { GetPostInput } from './dto/post.input';
import { Post } from './post.entity';
import { Injectable } from '@nestjs/common'
import { InjectRepository } from '@nestjs/typeorm'
import { QueryRunner, Repository, getConnection } from 'typeorm'
import {
CreatePostInput,
GetPostInput,
UpdatePostInput,
} from './dto/post.input'
import { Post } from './model/post.entity'
@Injectable()
export class PostService {
constructor(
@InjectRepository(Post) private postRepository: Repository<Post>,
) {}
private connection = getConnection()
async findAll(): Promise<Post[]> {
return this.postRepository.find();
return this.postRepository.find()
}
async findOne(id: number): Promise<Post> {
return this.postRepository.findOne(id);
return this.postRepository.findOne(id)
}
async findSome(input: Partial<GetPostInput>): Promise<Post[]> {
return this.postRepository
.createQueryBuilder('post')
.where('post.author like :author', { author: input.author })
.getMany()
}
async createOne(input: CreatePostInput): Promise<Post> {
let result
const queryRunner: QueryRunner = this.connection.createQueryRunner()
await queryRunner.connect()
await queryRunner.startTransaction()
try {
result = await queryRunner.manager.save(this.postRepository.create(input))
await queryRunner.commitTransaction()
} catch (err) {
await queryRunner.rollbackTransaction()
throw err
} finally {
await queryRunner.release()
}
return result
}
async updateOne(input: UpdatePostInput): Promise<Post> {
let result
const queryRunner: QueryRunner = this.connection.createQueryRunner()
await queryRunner.connect()
await queryRunner.startTransaction()
try {
const before = await this.postRepository.findOne(input.id)
result = await queryRunner.manager.save(this.postRepository.create(input))
await queryRunner.commitTransaction()
} catch (err) {
await queryRunner.rollbackTransaction()
throw err
} finally {
await queryRunner.release()
}
return result
}
}
......
import { Module } from '@nestjs/common';
import { UserResolver } from './user.resolver';
import { UserService } from './user.service';
import { Module } from '@nestjs/common'
import { UserResolver } from './user.resolver'
import { UserService } from './user.service'
@Module({
providers: [UserResolver, UserService]
providers: [UserResolver, UserService],
})
export class UserModule {}
......
import { Test, TestingModule } from '@nestjs/testing';
import { UserResolver } from './user.resolver';
import { Test, TestingModule } from '@nestjs/testing'
import { UserResolver } from './user.resolver'
describe('UserResolver', () => {
let resolver: UserResolver;
let resolver: UserResolver
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [UserResolver],
}).compile();
}).compile()
resolver = module.get<UserResolver>(UserResolver);
});
resolver = module.get<UserResolver>(UserResolver)
})
it('should be defined', () => {
expect(resolver).toBeDefined();
});
});
expect(resolver).toBeDefined()
})
})
......
import { Resolver } from '@nestjs/graphql';
import { Resolver } from '@nestjs/graphql'
@Resolver()
export class UserResolver {}
......
import { Test, TestingModule } from '@nestjs/testing';
import { UserService } from './user.service';
import { Test, TestingModule } from '@nestjs/testing'
import { UserService } from './user.service'
describe('UserService', () => {
let service: UserService;
let service: UserService
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [UserService],
}).compile();
}).compile()
service = module.get<UserService>(UserService);
});
service = module.get<UserService>(UserService)
})
it('should be defined', () => {
expect(service).toBeDefined();
});
});
expect(service).toBeDefined()
})
})
......
import { Injectable } from '@nestjs/common';
import { Injectable } from '@nestjs/common'
@Injectable()
export class UserService {}
......