-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a488f6
commit d59e12f
Showing
13 changed files
with
213 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "@lib/util", | ||
"version": "0.0.1", | ||
"description": "", | ||
"author": "", | ||
"private": true, | ||
"license": "UNLICENSED", | ||
"scripts": { | ||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", | ||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", | ||
"test": "jest", | ||
"test:watch": "jest --watch", | ||
"test:cov": "jest --coverage", | ||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", | ||
"build": "yarn clean && yarn compile", | ||
"clean": "rimraf -rf ./dist", | ||
"compile": "tsc" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^29.5.2", | ||
"@types/node": "^20.3.1", | ||
"@types/node-imap": "^0", | ||
"@types/supertest": "^6.0.0", | ||
"@typescript-eslint/eslint-plugin": "^6.0.0", | ||
"@typescript-eslint/parser": "^6.0.0", | ||
"eslint": "^8.42.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-prettier": "^5.2.1", | ||
"eslint-plugin-unused-imports": "^4.1.4", | ||
"jest": "^29.5.0", | ||
"prettier": "^3.0.0", | ||
"source-map-support": "^0.5.21", | ||
"supertest": "^6.3.3", | ||
"ts-jest": "^29.1.0", | ||
"ts-loader": "^9.5.1", | ||
"ts-node": "^10.9.1", | ||
"tsconfig-paths": "^4.2.0", | ||
"tsconfig-paths-jest": "^0.0.1", | ||
"typescript": "^5.1.3" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export const LetterAttachmentCode = { | ||
THUMBNAIL: 'LA001', | ||
LETTER: 'LA002', | ||
BACKGROUND: 'LA003', | ||
COMPONENT: 'LA004', | ||
} as const; | ||
|
||
export type LetterAttachmentCode = | ||
(typeof LetterAttachmentCode)[keyof typeof LetterAttachmentCode]; | ||
|
||
export const pathToLetterAttachmentCode = (path: string) => { | ||
return path.includes('thm/') | ||
? LetterAttachmentCode.THUMBNAIL | ||
: path.includes('ltr/') | ||
? LetterAttachmentCode.LETTER | ||
: path.includes('bgr/') | ||
? LetterAttachmentCode.BACKGROUND | ||
: path.includes('cpn') | ||
? LetterAttachmentCode.COMPONENT | ||
: undefined; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
export const LetterCategory = { | ||
WEDDING: '결혼식', // 결혼식 | ||
BIRTHDAY: '생일', // 생일 | ||
ANNIVERSARY: '기념일', // 기념일 | ||
PARTY: '파티', // 파티 | ||
GRADUATION: '졸업', // 졸업 | ||
CORPORATE: '행사', // 회사 행사 | ||
} as const; | ||
|
||
export type LetterCategory = | ||
(typeof LetterCategory)[keyof typeof LetterCategory]; | ||
|
||
export const LetterCategoryCode = { | ||
WEDDING: 'LT001', // 결혼식 | ||
BIRTHDAY: 'LT002', // 생일 | ||
ANNIVERSARY: 'LT003', // 기념일 | ||
PARTY: 'LT004', // 파티 | ||
GRADUATION: 'LT005', // 졸업 | ||
CORPORATE: 'LT006', // 회사 행사 | ||
} as const; | ||
|
||
export type LetterCategoryCode = | ||
(typeof LetterCategoryCode)[keyof typeof LetterCategoryCode]; | ||
|
||
const categoryToCodeMap: Record<LetterCategory, LetterCategoryCode> = { | ||
[LetterCategory.WEDDING]: LetterCategoryCode.WEDDING, | ||
[LetterCategory.BIRTHDAY]: LetterCategoryCode.BIRTHDAY, | ||
[LetterCategory.ANNIVERSARY]: LetterCategoryCode.ANNIVERSARY, | ||
[LetterCategory.PARTY]: LetterCategoryCode.PARTY, | ||
[LetterCategory.GRADUATION]: LetterCategoryCode.GRADUATION, | ||
[LetterCategory.CORPORATE]: LetterCategoryCode.CORPORATE, | ||
}; | ||
|
||
const codeToCategoryMap: Record<LetterCategoryCode, LetterCategory> = { | ||
[LetterCategoryCode.WEDDING]: LetterCategory.WEDDING, | ||
[LetterCategoryCode.BIRTHDAY]: LetterCategory.BIRTHDAY, | ||
[LetterCategoryCode.ANNIVERSARY]: LetterCategory.ANNIVERSARY, | ||
[LetterCategoryCode.PARTY]: LetterCategory.PARTY, | ||
[LetterCategoryCode.GRADUATION]: LetterCategory.GRADUATION, | ||
[LetterCategoryCode.CORPORATE]: LetterCategory.CORPORATE, | ||
}; | ||
|
||
export function getCategoryFromCode(code: LetterCategoryCode): LetterCategory { | ||
return codeToCategoryMap[code]; | ||
} | ||
|
||
export function getCodeFromCategory( | ||
category: LetterCategory, | ||
): LetterCategoryCode { | ||
return categoryToCodeMap[category]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './attachment'; | ||
export * from './category'; | ||
export * from './random'; | ||
export * from './yn'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* 랜덤한 문자열을 반환한다. ( 기본 길이 10 ) | ||
* @param length | ||
* @returns string | ||
*/ | ||
export const randomString = (length: number = 10): string => { | ||
const chars = | ||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | ||
let result = ''; | ||
for (let i = 0; i < length; i++) { | ||
result += chars.charAt(Math.floor(Math.random() * chars.length)); | ||
} | ||
return result; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const YN = { | ||
Y: 'Y', | ||
N: 'N', | ||
} as const; | ||
|
||
export type YN = (typeof YN)[keyof typeof YN]; | ||
|
||
export const booleanToYN = (data: boolean): YN => { | ||
return data === true ? YN.Y : YN.N; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends" : "./tsconfig.json", | ||
"exclude": ["node_modules","test","dist","**/*spec.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"include": ["./src"], | ||
"extends" : "../../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist", | ||
"baseUrl": "./", | ||
"rootDir": ".", | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"composite": true | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"declaration": true, | ||
"removeComments": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"allowSyntheticDefaultImports": true, | ||
"target": "ES2021", | ||
"sourceMap": true, | ||
"incremental": true, | ||
"skipLibCheck": true, | ||
"strictNullChecks": false, | ||
"noImplicitAny": false, | ||
"strictBindCallApply": false, | ||
"forceConsistentCasingInFileNames": false, | ||
"noFallthroughCasesInSwitch": false, | ||
"baseUrl": "./", | ||
"composite": true | ||
"module": "commonjs", | ||
"declaration": true, | ||
"removeComments": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"allowSyntheticDefaultImports": true, | ||
"target": "ES2021", | ||
"sourceMap": true, | ||
"incremental": true, | ||
"skipLibCheck": true, | ||
"strictNullChecks": false, | ||
"noImplicitAny": false, | ||
"strictBindCallApply": false, | ||
"forceConsistentCasingInFileNames": false, | ||
"noFallthroughCasesInSwitch": false, | ||
"baseUrl": "./", | ||
"composite": true, | ||
"paths": { | ||
"@lib/util/*": ["packages/lib/util/src/*"], | ||
"@lib/dto/*": ["packages/lib/dto/src/*"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters