Skip to content

Commit 677a106

Browse files
feat: 워크스페이스 모듈, 엔티티 정의
1 parent a9f86ab commit 677a106

13 files changed

+106
-17
lines changed

apps/backend/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ServeStaticModule } from '@nestjs/serve-static';
1616
import { UploadModule } from './upload/upload.module';
1717
import { AuthModule } from './auth/auth.module';
1818
import { UserModule } from './user/user.module';
19+
import { WorkspaceModule } from './workspace/workspace.module';
1920

2021
@Module({
2122
imports: [
@@ -44,6 +45,7 @@ import { UserModule } from './user/user.module';
4445
UploadModule,
4546
AuthModule,
4647
UserModule,
48+
WorkspaceModule,
4749
],
4850
controllers: [AppController],
4951
providers: [AppService],

apps/backend/src/auth/strategies/kakao.strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ export class KakaoStrategy extends PassportStrategy(Strategy, 'kakao') {
2626
if (!user) {
2727
user = await this.authService.signUp(createUserDto);
2828
}
29-
return user; // req.user로 반환
29+
return { snowflakeId: user.snowflakeId };
3030
}
3131
}

apps/backend/src/auth/strategies/naver.strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ export class NaverStrategy extends PassportStrategy(Strategy, 'naver') {
2626
if (!user) {
2727
user = await this.authService.signUp(createUserDto);
2828
}
29-
return user; // req.user로 반환
29+
return { snowflakeId: user.snowflakeId };
3030
}
3131
}

apps/backend/src/page/page.controller.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ describe('PageController', () => {
5252
const newDate = new Date();
5353
jest.spyOn(pageService, 'createPage').mockResolvedValue({
5454
id: 1,
55-
snowflakeId: 'generated-snowflake-id-page',
5655
title: 'New Page',
5756
content: {} as JSON,
5857
createdAt: newDate,
@@ -137,7 +136,6 @@ describe('PageController', () => {
137136
it('id에 해당하는 페이지의 상세 정보를 반환한다.', async () => {
138137
const expectedPage: Page = {
139138
id: 1,
140-
snowflakeId: 'generated-snowflake-id-page',
141139
title: 'title',
142140
content: {} as JSON,
143141
node: null,

apps/backend/src/page/page.entity.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,14 @@ import {
77
CreateDateColumn,
88
UpdateDateColumn,
99
VersionColumn,
10-
Index,
1110
} from 'typeorm';
1211
import { Node } from '../node/node.entity';
13-
import { Snowflake } from '@theinternetfolks/snowflake';
1412

1513
@Entity()
1614
export class Page {
1715
@PrimaryGeneratedColumn('increment')
1816
id: number;
1917

20-
@Column({ unique: true })
21-
@Index()
22-
snowflakeId: string = Snowflake.generate();
23-
2418
@Column()
2519
title: string;
2620

apps/backend/src/page/page.service.spec.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ describe('PageService', () => {
6262
// 페이지 엔티티
6363
const newPage: Page = {
6464
id: 1,
65-
snowflakeId: 'generated-snowflake-id-page',
6665
title: 'new page',
6766
content: {} as JSON,
6867
createdAt: newDate,
@@ -128,7 +127,6 @@ describe('PageService', () => {
128127
const originDate = new Date();
129128
const originPage: Page = {
130129
id: 1,
131-
snowflakeId: 'generated-snowflake-id-page',
132130
title: 'origin title',
133131
content: {} as JSON,
134132
node: null,
@@ -140,7 +138,6 @@ describe('PageService', () => {
140138
const newDate = new Date();
141139
const newPage: Page = {
142140
id: 1,
143-
snowflakeId: 'generated-snowflake-id-page',
144141
title: 'Updated Title',
145142
content: {} as JSON,
146143
node: null,
@@ -178,7 +175,6 @@ describe('PageService', () => {
178175
const newDate = new Date();
179176
const expectedPage: Page = {
180177
id: 1,
181-
snowflakeId: 'generated-snowflake-id-page',
182178
title: 'title',
183179
content: {} as JSON,
184180
node: null,
@@ -208,19 +204,16 @@ describe('PageService', () => {
208204
const expectedPageList = [
209205
{
210206
id: 1,
211-
snowflakeId: 'generated-snowflake-id-page-1',
212207
title: 'title1',
213208
node: null,
214209
},
215210
{
216211
id: 2,
217-
snowflakeId: 'generated-snowflake-id-page-2',
218212
title: 'title2',
219213
node: null,
220214
},
221215
{
222216
id: 3,
223-
snowflakeId: 'generated-snowflake-id-page-3',
224217
title: 'title3',
225218
node: null,
226219
},
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Test, TestingModule } from '@nestjs/testing';
2+
import { WorkspaceController } from './workspace.controller';
3+
4+
describe('WorkspaceController', () => {
5+
let controller: WorkspaceController;
6+
7+
beforeEach(async () => {
8+
const module: TestingModule = await Test.createTestingModule({
9+
controllers: [WorkspaceController],
10+
}).compile();
11+
12+
controller = module.get<WorkspaceController>(WorkspaceController);
13+
});
14+
15+
it('should be defined', () => {
16+
expect(controller).toBeDefined();
17+
});
18+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Controller } from '@nestjs/common';
2+
3+
@Controller('workspace')
4+
export class WorkspaceController {}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {
2+
Column,
3+
Entity,
4+
ManyToOne,
5+
PrimaryGeneratedColumn,
6+
CreateDateColumn,
7+
UpdateDateColumn,
8+
} from 'typeorm';
9+
import { User } from '../user/user.entity';
10+
import { Snowflake } from '@theinternetfolks/snowflake';
11+
12+
@Entity()
13+
export class Workspace {
14+
@PrimaryGeneratedColumn()
15+
id: number;
16+
17+
@Column({ unique: true })
18+
snowflakeId: string = Snowflake.generate();
19+
20+
@ManyToOne(() => User, { nullable: false })
21+
owner: User;
22+
23+
@Column()
24+
title: string;
25+
26+
@Column({ nullable: true })
27+
description: string;
28+
29+
@Column({ default: 'private' })
30+
visibility: 'public' | 'private';
31+
32+
@CreateDateColumn()
33+
createdAt: Date;
34+
35+
@UpdateDateColumn()
36+
updatedAt: Date;
37+
38+
@Column({ nullable: true })
39+
thumbnailUrl: string;
40+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Module, forwardRef } from '@nestjs/common';
2+
import { WorkspaceService } from './workspace.service';
3+
import { WorkspaceController } from './workspace.controller';
4+
import { TypeOrmModule } from '@nestjs/typeorm';
5+
import { Workspace } from './workspace.entity';
6+
import { WorkspaceRepository } from './workspace.repository';
7+
import { UserModule } from '../user/user.module';
8+
9+
@Module({
10+
imports: [
11+
TypeOrmModule.forFeature([Workspace]),
12+
forwardRef(() => UserModule),
13+
],
14+
providers: [WorkspaceService, WorkspaceRepository],
15+
controllers: [WorkspaceController, WorkspaceRepository],
16+
})
17+
export class WorkspaceModule {}

0 commit comments

Comments
 (0)