Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: 온보딩 API 추가 #43

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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],
Expand Down
8 changes: 4 additions & 4 deletions src/modules/folders/folders.module.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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 {}
6 changes: 3 additions & 3 deletions src/modules/folders/folders.service.ts
Original file line number Diff line number Diff line change
@@ -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,
) {}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/folders/responses/post.response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class PostResponse {
isFavorite: boolean;

@ApiProperty()
createdAt: string;
createdAt: Date;

@ApiProperty({ type: Keyword, isArray: true })
keywords: Keyword[];
Expand Down
34 changes: 34 additions & 0 deletions src/modules/onboard/onboard.const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export const onBoardCategoryList = [
'경제',
'디자인',
'개발',
'쇼핑',
'요리법',
'여행',
'음악',
'UX',
'자기개발',
'금융',
'소셜',
'미디어',
'뉴스',
'오락',
'비즈니스',
'건강',
'부동산',
'세계',
'예술',
'스포츠',
'경영',
'운동',
'기술',
'영화',
'책',
'사진',
'교육',
'과학',
'패션',
'정치',
'생산성',
'환경',
];
18 changes: 18 additions & 0 deletions src/modules/onboard/onboard.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -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>(OnboardController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
12 changes: 12 additions & 0 deletions src/modules/onboard/onboard.controller.ts
Original file line number Diff line number Diff line change
@@ -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();
}
}
9 changes: 9 additions & 0 deletions src/modules/onboard/onboard.module.ts
Original file line number Diff line number Diff line change
@@ -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 {}
18 changes: 18 additions & 0 deletions src/modules/onboard/onboard.service.spec.ts
Original file line number Diff line number Diff line change
@@ -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>(OnboardService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
9 changes: 9 additions & 0 deletions src/modules/onboard/onboard.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Injectable } from '@nestjs/common';
import { onBoardCategoryList } from './onboard.const';

@Injectable()
export class OnboardService {
getOnboardCategories() {
return onBoardCategoryList;
}
}
14 changes: 5 additions & 9 deletions src/modules/posts/posts.module.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
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: [
MongooseModule.forFeature([
{ 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 {}
3 changes: 2 additions & 1 deletion src/modules/posts/posts.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down