diff --git a/src/app.module.ts b/src/app.module.ts index aa98702..05ac71f 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -11,9 +11,10 @@ import { UsersModule } from './modules/users/users.module'; import { ClassificationModule } from './modules/classification/classification.module'; import { AuthModule } from './modules/auth/auth.module'; import { FoldersModule } from './modules/folders/folders.module'; -import { LinksModule } from './modules/links/links.module'; import { PostsModule } from './modules/posts/posts.module'; +import { LinksModule } from './modules/links/links.module'; import { AwsLambdaModule } from './infrastructure/aws-lambda/aws-lambda.module'; +import { OnboardModule } from './modules/onboard/onboard.module'; @Module({ imports: [ @@ -27,10 +28,11 @@ import { AwsLambdaModule } from './infrastructure/aws-lambda/aws-lambda.module'; UsersModule, ClassificationModule, AuthModule, + PostsModule, FoldersModule, LinksModule, - PostsModule, AwsLambdaModule, + OnboardModule, ], controllers: [AppController], providers: [AppService], diff --git a/src/modules/folders/folders.module.ts b/src/modules/folders/folders.module.ts index 77b4e99..5eee094 100644 --- a/src/modules/folders/folders.module.ts +++ b/src/modules/folders/folders.module.ts @@ -1,10 +1,9 @@ -import { Module } from '@nestjs/common'; +import { forwardRef, Module } from '@nestjs/common'; import { FoldersService } from './folders.service'; import { FoldersController } from './folders.controller'; import { MongooseModule } from '@nestjs/mongoose'; import { Folder, FolderSchema, Post, PostSchema } from '@src/infrastructure'; import { FolderRepository } from './folders.repository'; -import { PostsRepository } from '../posts/posts.repository'; import { PostsModule } from '../posts/posts.module'; @Module({ @@ -13,9 +12,10 @@ import { PostsModule } from '../posts/posts.module'; { name: Post.name, schema: PostSchema }, { name: Folder.name, schema: FolderSchema }, ]), - PostsModule, + forwardRef(() => PostsModule), ], controllers: [FoldersController], - providers: [FoldersService, FolderRepository, PostsRepository], + providers: [FoldersService, FolderRepository], + exports: [FolderRepository, FoldersService], }) export class FoldersModule {} diff --git a/src/modules/folders/folders.service.ts b/src/modules/folders/folders.service.ts index 636aeb1..e20d027 100644 --- a/src/modules/folders/folders.service.ts +++ b/src/modules/folders/folders.service.ts @@ -1,16 +1,16 @@ -import { Injectable } from '@nestjs/common'; +import { forwardRef, Inject, Injectable } from '@nestjs/common'; import { CreateFolderDto, UpdateFolderDto } from './dto/mutate-folder.dto'; -import { HydratedDocument, Schema as MongooseSchema } from 'mongoose'; +import { Schema as MongooseSchema } from 'mongoose'; import { FolderWithCount } from './dto/folder-with-count.dto'; import { FolderRepository } from './folders.repository'; import { PostsRepository } from '../posts/posts.repository'; import { FolderType } from '@src/infrastructure/database/types/folder-type.enum'; -import { Type } from 'class-transformer'; @Injectable() export class FoldersService { constructor( private readonly folderRepository: FolderRepository, + @Inject(forwardRef(() => PostsRepository)) private readonly postRepository: PostsRepository, ) {} diff --git a/src/modules/folders/responses/post.response.ts b/src/modules/folders/responses/post.response.ts index fc19f9e..9960bda 100644 --- a/src/modules/folders/responses/post.response.ts +++ b/src/modules/folders/responses/post.response.ts @@ -37,7 +37,7 @@ export class PostResponse { isFavorite: boolean; @ApiProperty() - createdAt: string; + createdAt: Date; @ApiProperty({ type: Keyword, isArray: true }) keywords: Keyword[]; diff --git a/src/modules/onboard/onboard.const.ts b/src/modules/onboard/onboard.const.ts new file mode 100644 index 0000000..e8523bd --- /dev/null +++ b/src/modules/onboard/onboard.const.ts @@ -0,0 +1,34 @@ +export const onBoardCategoryList = [ + '경제', + '디자인', + '개발', + '쇼핑', + '요리법', + '여행', + '음악', + 'UX', + '자기개발', + '금융', + '소셜', + '미디어', + '뉴스', + '오락', + '비즈니스', + '건강', + '부동산', + '세계', + '예술', + '스포츠', + '경영', + '운동', + '기술', + '영화', + '책', + '사진', + '교육', + '과학', + '패션', + '정치', + '생산성', + '환경', +]; diff --git a/src/modules/onboard/onboard.controller.spec.ts b/src/modules/onboard/onboard.controller.spec.ts new file mode 100644 index 0000000..99959df --- /dev/null +++ b/src/modules/onboard/onboard.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { OnboardController } from './onboard.controller'; + +describe('OnboardController', () => { + let controller: OnboardController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [OnboardController], + }).compile(); + + controller = module.get(OnboardController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/src/modules/onboard/onboard.controller.ts b/src/modules/onboard/onboard.controller.ts new file mode 100644 index 0000000..088bbca --- /dev/null +++ b/src/modules/onboard/onboard.controller.ts @@ -0,0 +1,12 @@ +import { Controller, Get } from '@nestjs/common'; +import { OnboardService } from './onboard.service'; + +@Controller('onboard') +export class OnboardController { + constructor(private readonly onboardService: OnboardService) {} + + @Get() + getOnboardCategories() { + return this.onboardService.getOnboardCategories(); + } +} diff --git a/src/modules/onboard/onboard.module.ts b/src/modules/onboard/onboard.module.ts new file mode 100644 index 0000000..2432668 --- /dev/null +++ b/src/modules/onboard/onboard.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { OnboardController } from './onboard.controller'; +import { OnboardService } from './onboard.service'; + +@Module({ + controllers: [OnboardController], + providers: [OnboardService], +}) +export class OnboardModule {} diff --git a/src/modules/onboard/onboard.service.spec.ts b/src/modules/onboard/onboard.service.spec.ts new file mode 100644 index 0000000..1123afc --- /dev/null +++ b/src/modules/onboard/onboard.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { OnboardService } from './onboard.service'; + +describe('OnboardService', () => { + let service: OnboardService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [OnboardService], + }).compile(); + + service = module.get(OnboardService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/src/modules/onboard/onboard.service.ts b/src/modules/onboard/onboard.service.ts new file mode 100644 index 0000000..b318467 --- /dev/null +++ b/src/modules/onboard/onboard.service.ts @@ -0,0 +1,9 @@ +import { Injectable } from '@nestjs/common'; +import { onBoardCategoryList } from './onboard.const'; + +@Injectable() +export class OnboardService { + getOnboardCategories() { + return onBoardCategoryList; + } +} diff --git a/src/modules/posts/posts.module.ts b/src/modules/posts/posts.module.ts index a475a07..f604a20 100644 --- a/src/modules/posts/posts.module.ts +++ b/src/modules/posts/posts.module.ts @@ -1,13 +1,13 @@ -import { Module } from '@nestjs/common'; +import { forwardRef, Module } from '@nestjs/common'; import { PostsService } from './posts.service'; import { PostsController } from './posts.controller'; import { PostsRepository } from '@src/modules/posts/posts.repository'; import { MongooseModule } from '@nestjs/mongoose'; import { Folder, FolderSchema, Post, PostSchema } from '@src/infrastructure'; import { UsersModule } from '@src/modules/users/users.module'; -import { FolderRepository } from '../folders/folders.repository'; import { AwsLambdaModule } from '@src/infrastructure/aws-lambda/aws-lambda.module'; import { AwsLambdaService } from '@src/infrastructure/aws-lambda/aws-lambda.service'; +import { FoldersModule } from '../folders/folders.module'; @Module({ imports: [ @@ -15,16 +15,12 @@ import { AwsLambdaService } from '@src/infrastructure/aws-lambda/aws-lambda.serv { name: Post.name, schema: PostSchema }, { name: Folder.name, schema: FolderSchema }, ]), + forwardRef(() => FoldersModule), UsersModule, AwsLambdaModule, ], controllers: [PostsController], - providers: [ - PostsService, - PostsRepository, - FolderRepository, - AwsLambdaService, - ], - exports: [PostsService], + providers: [PostsService, PostsRepository, AwsLambdaService], + exports: [PostsService, PostsRepository], }) export class PostsModule {} diff --git a/src/modules/posts/posts.service.ts b/src/modules/posts/posts.service.ts index 27964ae..d74d766 100644 --- a/src/modules/posts/posts.service.ts +++ b/src/modules/posts/posts.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@nestjs/common'; +import { forwardRef, Inject, Injectable } from '@nestjs/common'; import { CreatePostDto } from '@src/modules/posts/dto/create-post.dto'; import { PostsRepository } from '@src/modules/posts/posts.repository'; import { GetPostQueryDto } from './dto/find-in-folder.dto'; @@ -11,6 +11,7 @@ import { ConfigService } from '@nestjs/config'; export class PostsService { constructor( private readonly postRepository: PostsRepository, + @Inject(forwardRef(() => FolderRepository)) private readonly folderRepository: FolderRepository, private readonly awsLambdaService: AwsLambdaService, private readonly config: ConfigService,