Skip to content

Commit e30f1f5

Browse files
feat: 외부api 대체키 추가
1 parent 3fc0405 commit e30f1f5

File tree

6 files changed

+55
-10
lines changed

6 files changed

+55
-10
lines changed

apps/backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@nestjs/swagger": "^8.0.5",
3535
"@nestjs/typeorm": "^10.0.2",
3636
"@nestjs/websockets": "^10.4.8",
37+
"@theinternetfolks/snowflake": "^1.3.0",
3738
"@types/multer": "^1.4.12",
3839
"class-transformer": "^0.5.1",
3940
"class-validator": "^0.14.1",

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

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

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

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

1315
@Entity()
1416
export class Page {
1517
@PrimaryGeneratedColumn('increment')
1618
id: number;
1719

20+
@Column({ unique: true })
21+
@Index()
22+
snowflakeId: string = Snowflake.generate();
23+
1824
@Column()
1925
title: string;
2026

@@ -33,13 +39,6 @@ export class Page {
3339
@Column({ nullable: true })
3440
emoji: string | null;
3541

36-
// TODO:추가적인 메타데이터 컬럼들(user 기능 추가할때)
37-
// @Column('created_by')
38-
// createdBy: string;
39-
40-
// @Column('updated_by')
41-
// updatedBy: string;
42-
4342
@OneToOne(() => Node, (node) => node.page, {
4443
onDelete: 'CASCADE',
4544
})

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ describe('PageService', () => {
6262
// 페이지 엔티티
6363
const newPage: Page = {
6464
id: 1,
65+
snowflakeId: 'generated-snowflake-id-page',
6566
title: 'new page',
6667
content: {} as JSON,
6768
createdAt: newDate,
@@ -127,6 +128,7 @@ describe('PageService', () => {
127128
const originDate = new Date();
128129
const originPage: Page = {
129130
id: 1,
131+
snowflakeId: 'generated-snowflake-id-page',
130132
title: 'origin title',
131133
content: {} as JSON,
132134
node: null,
@@ -138,6 +140,7 @@ describe('PageService', () => {
138140
const newDate = new Date();
139141
const newPage: Page = {
140142
id: 1,
143+
snowflakeId: 'generated-snowflake-id-page',
141144
title: 'Updated Title',
142145
content: {} as JSON,
143146
node: null,
@@ -175,6 +178,7 @@ describe('PageService', () => {
175178
const newDate = new Date();
176179
const expectedPage: Page = {
177180
id: 1,
181+
snowflakeId: 'generated-snowflake-id-page',
178182
title: 'title',
179183
content: {} as JSON,
180184
node: null,
@@ -204,16 +208,19 @@ describe('PageService', () => {
204208
const expectedPageList = [
205209
{
206210
id: 1,
211+
snowflakeId: 'generated-snowflake-id-page-1',
207212
title: 'title1',
208213
node: null,
209214
},
210215
{
211216
id: 2,
217+
snowflakeId: 'generated-snowflake-id-page-2',
212218
title: 'title2',
213219
node: null,
214220
},
215221
{
216222
id: 3,
223+
snowflakeId: 'generated-snowflake-id-page-3',
217224
title: 'title3',
218225
node: null,
219226
},

apps/backend/src/user/user.entity.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@ import {
44
PrimaryGeneratedColumn,
55
Column,
66
CreateDateColumn,
7+
Index,
78
} from 'typeorm';
9+
import { Snowflake } from '@theinternetfolks/snowflake';
810

911
@Entity()
1012
export class User {
1113
@PrimaryGeneratedColumn('increment')
1214
id: number;
1315

16+
@Column({ unique: true })
17+
@Index()
18+
snowflakeId: string = Snowflake.generate();
19+
1420
@Column({ unique: true })
1521
providerId: string; // 네이버/카카오 ID
1622

yarn.lock

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2766,6 +2766,11 @@
27662766
dependencies:
27672767
"@tanstack/query-core" "5.60.6"
27682768

2769+
"@theinternetfolks/snowflake@^1.3.0":
2770+
version "1.3.0"
2771+
resolved "https://registry.yarnpkg.com/@theinternetfolks/snowflake/-/snowflake-1.3.0.tgz#da26407eba4a0639d23e6ea08136e66270ee0e03"
2772+
integrity sha512-/5fjyE+JIa95Lm1uDJ9fx52W7/ZHBVvKo5GbpR+swpchbriLzVgFAIUOVwLsscnUTBixyQ+JsEh5pJQM/zKNzQ==
2773+
27692774
"@tiptap/core@^2.1.7", "@tiptap/core@^2.9.1":
27702775
version "2.9.1"
27712776
resolved "https://registry.yarnpkg.com/@tiptap/core/-/core-2.9.1.tgz#ceed211a9ecfe25a94e0e0863936169990e75aee"
@@ -9604,7 +9609,16 @@ string-length@^4.0.1:
96049609
char-regex "^1.0.2"
96059610
strip-ansi "^6.0.0"
96069611

9607-
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
9612+
"string-width-cjs@npm:string-width@^4.2.0":
9613+
version "4.2.3"
9614+
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
9615+
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
9616+
dependencies:
9617+
emoji-regex "^8.0.0"
9618+
is-fullwidth-code-point "^3.0.0"
9619+
strip-ansi "^6.0.1"
9620+
9621+
"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
96089622
version "4.2.3"
96099623
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
96109624
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -9636,7 +9650,14 @@ string_decoder@~1.1.1:
96369650
dependencies:
96379651
safe-buffer "~5.1.0"
96389652

9639-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
9653+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
9654+
version "6.0.1"
9655+
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
9656+
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
9657+
dependencies:
9658+
ansi-regex "^5.0.1"
9659+
9660+
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
96409661
version "6.0.1"
96419662
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
96429663
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -10535,7 +10556,7 @@ word-wrap@^1.2.5:
1053510556
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
1053610557
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==
1053710558

10538-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
10559+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
1053910560
version "7.0.0"
1054010561
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
1054110562
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -10553,6 +10574,15 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
1055310574
string-width "^4.1.0"
1055410575
strip-ansi "^6.0.0"
1055510576

10577+
wrap-ansi@^7.0.0:
10578+
version "7.0.0"
10579+
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
10580+
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
10581+
dependencies:
10582+
ansi-styles "^4.0.0"
10583+
string-width "^4.1.0"
10584+
strip-ansi "^6.0.0"
10585+
1055610586
wrap-ansi@^8.1.0:
1055710587
version "8.1.0"
1055810588
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"

0 commit comments

Comments
 (0)