linkup-lib 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/db.d.ts +4 -0
- package/dist/db.js +59 -0
- package/dist/image.d.ts +129 -0
- package/dist/image.js +118 -0
- package/dist/index.d.ts +100 -2
- package/dist/index.js +8 -8
- package/dist/util.d.ts +69 -0
- package/dist/util.js +204 -0
- package/package.json +11 -2
package/dist/db.d.ts
ADDED
package/dist/db.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.pool = void 0;
|
|
16
|
+
const promise_1 = __importDefault(require("mysql2/promise"));
|
|
17
|
+
/**
|
|
18
|
+
* check, globalObject, registerService
|
|
19
|
+
* Next.js는 개발 모드에서 API 경로를 지속적으로 재구축하는데, initFn()의 경로를 전역으로 지정하여 변경되지 않도록 합니다.
|
|
20
|
+
*/
|
|
21
|
+
function check(it) {
|
|
22
|
+
return it && it.Math === Math && it;
|
|
23
|
+
}
|
|
24
|
+
const globalObject = check(typeof window === 'object' && window) ||
|
|
25
|
+
check(typeof self === 'object' && self) ||
|
|
26
|
+
check(typeof global === 'object' && global) ||
|
|
27
|
+
(() => {
|
|
28
|
+
return this;
|
|
29
|
+
})() ||
|
|
30
|
+
Function('return this')();
|
|
31
|
+
const registerService = (name, initFn) => {
|
|
32
|
+
if (process.env.NODE_ENV === 'development') {
|
|
33
|
+
if (!(name in globalObject)) {
|
|
34
|
+
globalObject[name] = initFn();
|
|
35
|
+
}
|
|
36
|
+
return globalObject[name];
|
|
37
|
+
}
|
|
38
|
+
return initFn();
|
|
39
|
+
};
|
|
40
|
+
exports.pool = registerService('mysql', () => promise_1.default.createPool({
|
|
41
|
+
host: "database-secretorder.cfk0kqmkqkbd.ap-northeast-2.rds.amazonaws.com",
|
|
42
|
+
port: 3306,
|
|
43
|
+
user: 'admin',
|
|
44
|
+
password: "linkup1!",
|
|
45
|
+
database: 'secretorder',
|
|
46
|
+
connectionLimit: 1000,
|
|
47
|
+
waitForConnections: true,
|
|
48
|
+
keepAliveInitialDelay: 10000, // 0 by default.
|
|
49
|
+
enableKeepAlive: true, // false by default.
|
|
50
|
+
}));
|
|
51
|
+
// 🛑 서버 종료 시 MySQL 커넥션 풀 닫기
|
|
52
|
+
process.on('SIGINT', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
if (exports.pool) {
|
|
54
|
+
console.debug('Closing MySQL connection pool...');
|
|
55
|
+
yield exports.pool.end();
|
|
56
|
+
}
|
|
57
|
+
process.exit();
|
|
58
|
+
}));
|
|
59
|
+
exports.default = exports.pool;
|
package/dist/image.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export declare const convertWebpAndUploadFile: ({ file, path, fileName, size }: {
|
|
2
|
+
file: File;
|
|
3
|
+
path: string;
|
|
4
|
+
fileName?: string;
|
|
5
|
+
size?: number;
|
|
6
|
+
}) => Promise<{
|
|
7
|
+
result: boolean;
|
|
8
|
+
location: string;
|
|
9
|
+
key: string;
|
|
10
|
+
Expiration?: string | undefined;
|
|
11
|
+
ETag?: string | undefined;
|
|
12
|
+
ChecksumCRC32?: string | undefined;
|
|
13
|
+
ChecksumCRC32C?: string | undefined;
|
|
14
|
+
ChecksumCRC64NVME?: string | undefined;
|
|
15
|
+
ChecksumSHA1?: string | undefined;
|
|
16
|
+
ChecksumSHA256?: string | undefined;
|
|
17
|
+
ChecksumType?: import("@aws-sdk/client-s3").ChecksumType | undefined;
|
|
18
|
+
ServerSideEncryption?: import("@aws-sdk/client-s3").ServerSideEncryption | undefined;
|
|
19
|
+
VersionId?: string | undefined;
|
|
20
|
+
SSECustomerAlgorithm?: string | undefined;
|
|
21
|
+
SSECustomerKeyMD5?: string | undefined;
|
|
22
|
+
SSEKMSKeyId?: string | undefined;
|
|
23
|
+
SSEKMSEncryptionContext?: string | undefined;
|
|
24
|
+
BucketKeyEnabled?: boolean | undefined;
|
|
25
|
+
Size?: number | undefined;
|
|
26
|
+
RequestCharged?: import("@aws-sdk/client-s3").RequestCharged | undefined;
|
|
27
|
+
$metadata: import("@smithy/types").ResponseMetadata;
|
|
28
|
+
}>;
|
|
29
|
+
export declare const convertWebpAndUploadBuffer: ({ buffer, path, fileName, size }: {
|
|
30
|
+
buffer: Buffer;
|
|
31
|
+
path: string;
|
|
32
|
+
fileName?: string;
|
|
33
|
+
size?: number;
|
|
34
|
+
}) => Promise<{
|
|
35
|
+
result: boolean;
|
|
36
|
+
location: string;
|
|
37
|
+
key: string;
|
|
38
|
+
Expiration?: string | undefined;
|
|
39
|
+
ETag?: string | undefined;
|
|
40
|
+
ChecksumCRC32?: string | undefined;
|
|
41
|
+
ChecksumCRC32C?: string | undefined;
|
|
42
|
+
ChecksumCRC64NVME?: string | undefined;
|
|
43
|
+
ChecksumSHA1?: string | undefined;
|
|
44
|
+
ChecksumSHA256?: string | undefined;
|
|
45
|
+
ChecksumType?: import("@aws-sdk/client-s3").ChecksumType | undefined;
|
|
46
|
+
ServerSideEncryption?: import("@aws-sdk/client-s3").ServerSideEncryption | undefined;
|
|
47
|
+
VersionId?: string | undefined;
|
|
48
|
+
SSECustomerAlgorithm?: string | undefined;
|
|
49
|
+
SSECustomerKeyMD5?: string | undefined;
|
|
50
|
+
SSEKMSKeyId?: string | undefined;
|
|
51
|
+
SSEKMSEncryptionContext?: string | undefined;
|
|
52
|
+
BucketKeyEnabled?: boolean | undefined;
|
|
53
|
+
Size?: number | undefined;
|
|
54
|
+
RequestCharged?: import("@aws-sdk/client-s3").RequestCharged | undefined;
|
|
55
|
+
$metadata: import("@smithy/types").ResponseMetadata;
|
|
56
|
+
}>;
|
|
57
|
+
export declare const deleteS3Object: (key: string) => Promise<{
|
|
58
|
+
result: boolean;
|
|
59
|
+
DeleteMarker?: boolean | undefined;
|
|
60
|
+
VersionId?: string | undefined;
|
|
61
|
+
RequestCharged?: import("@aws-sdk/client-s3").RequestCharged | undefined;
|
|
62
|
+
$metadata: import("@smithy/types").ResponseMetadata;
|
|
63
|
+
}>;
|
|
64
|
+
declare const _default: {
|
|
65
|
+
convertWebpAndUploadFile: ({ file, path, fileName, size }: {
|
|
66
|
+
file: File;
|
|
67
|
+
path: string;
|
|
68
|
+
fileName?: string;
|
|
69
|
+
size?: number;
|
|
70
|
+
}) => Promise<{
|
|
71
|
+
result: boolean;
|
|
72
|
+
location: string;
|
|
73
|
+
key: string;
|
|
74
|
+
Expiration?: string | undefined;
|
|
75
|
+
ETag?: string | undefined;
|
|
76
|
+
ChecksumCRC32?: string | undefined;
|
|
77
|
+
ChecksumCRC32C?: string | undefined;
|
|
78
|
+
ChecksumCRC64NVME?: string | undefined;
|
|
79
|
+
ChecksumSHA1?: string | undefined;
|
|
80
|
+
ChecksumSHA256?: string | undefined;
|
|
81
|
+
ChecksumType?: import("@aws-sdk/client-s3").ChecksumType | undefined;
|
|
82
|
+
ServerSideEncryption?: import("@aws-sdk/client-s3").ServerSideEncryption | undefined;
|
|
83
|
+
VersionId?: string | undefined;
|
|
84
|
+
SSECustomerAlgorithm?: string | undefined;
|
|
85
|
+
SSECustomerKeyMD5?: string | undefined;
|
|
86
|
+
SSEKMSKeyId?: string | undefined;
|
|
87
|
+
SSEKMSEncryptionContext?: string | undefined;
|
|
88
|
+
BucketKeyEnabled?: boolean | undefined;
|
|
89
|
+
Size?: number | undefined;
|
|
90
|
+
RequestCharged?: import("@aws-sdk/client-s3").RequestCharged | undefined;
|
|
91
|
+
$metadata: import("@smithy/types").ResponseMetadata;
|
|
92
|
+
}>;
|
|
93
|
+
convertWebpAndUploadBuffer: ({ buffer, path, fileName, size }: {
|
|
94
|
+
buffer: Buffer;
|
|
95
|
+
path: string;
|
|
96
|
+
fileName?: string;
|
|
97
|
+
size?: number;
|
|
98
|
+
}) => Promise<{
|
|
99
|
+
result: boolean;
|
|
100
|
+
location: string;
|
|
101
|
+
key: string;
|
|
102
|
+
Expiration?: string | undefined;
|
|
103
|
+
ETag?: string | undefined;
|
|
104
|
+
ChecksumCRC32?: string | undefined;
|
|
105
|
+
ChecksumCRC32C?: string | undefined;
|
|
106
|
+
ChecksumCRC64NVME?: string | undefined;
|
|
107
|
+
ChecksumSHA1?: string | undefined;
|
|
108
|
+
ChecksumSHA256?: string | undefined;
|
|
109
|
+
ChecksumType?: import("@aws-sdk/client-s3").ChecksumType | undefined;
|
|
110
|
+
ServerSideEncryption?: import("@aws-sdk/client-s3").ServerSideEncryption | undefined;
|
|
111
|
+
VersionId?: string | undefined;
|
|
112
|
+
SSECustomerAlgorithm?: string | undefined;
|
|
113
|
+
SSECustomerKeyMD5?: string | undefined;
|
|
114
|
+
SSEKMSKeyId?: string | undefined;
|
|
115
|
+
SSEKMSEncryptionContext?: string | undefined;
|
|
116
|
+
BucketKeyEnabled?: boolean | undefined;
|
|
117
|
+
Size?: number | undefined;
|
|
118
|
+
RequestCharged?: import("@aws-sdk/client-s3").RequestCharged | undefined;
|
|
119
|
+
$metadata: import("@smithy/types").ResponseMetadata;
|
|
120
|
+
}>;
|
|
121
|
+
deleteS3Object: (key: string) => Promise<{
|
|
122
|
+
result: boolean;
|
|
123
|
+
DeleteMarker?: boolean | undefined;
|
|
124
|
+
VersionId?: string | undefined;
|
|
125
|
+
RequestCharged?: import("@aws-sdk/client-s3").RequestCharged | undefined;
|
|
126
|
+
$metadata: import("@smithy/types").ResponseMetadata;
|
|
127
|
+
}>;
|
|
128
|
+
};
|
|
129
|
+
export default _default;
|
package/dist/image.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.deleteS3Object = exports.convertWebpAndUploadBuffer = exports.convertWebpAndUploadFile = void 0;
|
|
16
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
17
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
18
|
+
const sharp_1 = __importDefault(require("sharp"));
|
|
19
|
+
const Bucket = process.env.AWS_S3_BUCKET || ""; // 'secret-order';
|
|
20
|
+
const s3 = new client_s3_1.S3Client({
|
|
21
|
+
region: process.env.AWS_REGION || "",
|
|
22
|
+
credentials: {
|
|
23
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID || "",
|
|
24
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || "",
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
// 이미지를 webp로 변환 후 업로드
|
|
28
|
+
const convertWebpAndUploadFile = (_a) => __awaiter(void 0, [_a], void 0, function* ({ file, path, fileName, size }) {
|
|
29
|
+
try {
|
|
30
|
+
const buffer = yield file.arrayBuffer();
|
|
31
|
+
// 이미지를 webp로 변환
|
|
32
|
+
const convert = yield (0, sharp_1.default)(buffer).webp({
|
|
33
|
+
quality: 90,
|
|
34
|
+
// lossless: true,
|
|
35
|
+
// nearLossless: true,
|
|
36
|
+
effort: 5,
|
|
37
|
+
}).toBuffer();
|
|
38
|
+
// 변환 실패!
|
|
39
|
+
if (!convert) {
|
|
40
|
+
throw new Error('이미지 변환에 실패했습니다.');
|
|
41
|
+
}
|
|
42
|
+
const resized = size ? yield (0, sharp_1.default)(convert)
|
|
43
|
+
.resize({ width: size, withoutEnlargement: true })
|
|
44
|
+
.toBuffer() : convert;
|
|
45
|
+
if (!fileName)
|
|
46
|
+
fileName = (0, dayjs_1.default)().format('YYYYMMDDHHmmssSSS');
|
|
47
|
+
// 스트림을 사용하여 S3에 업로드
|
|
48
|
+
const Key = `${path}/${fileName}.webp`;
|
|
49
|
+
// S3에 업로드하고 결과 출력
|
|
50
|
+
const res = yield s3.send(new client_s3_1.PutObjectCommand({
|
|
51
|
+
Bucket,
|
|
52
|
+
Key,
|
|
53
|
+
Body: resized,
|
|
54
|
+
ACL: 'public-read'
|
|
55
|
+
}));
|
|
56
|
+
return Object.assign(Object.assign({}, res), { result: true, location: `https://${Bucket}.s3.ap-northeast-2.amazonaws.com/${Key}`, key: Key });
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
console.error('이미지 변환 및 업로드 실패:', err);
|
|
60
|
+
throw new Error('이미지 변환 및 업로드에 실패했습니다.');
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
exports.convertWebpAndUploadFile = convertWebpAndUploadFile;
|
|
64
|
+
// 이미지를 webp로 변환 후 업로드
|
|
65
|
+
const convertWebpAndUploadBuffer = (_a) => __awaiter(void 0, [_a], void 0, function* ({ buffer, path, fileName, size }) {
|
|
66
|
+
try {
|
|
67
|
+
// 이미지를 webp로 변환
|
|
68
|
+
const convert = yield (0, sharp_1.default)(buffer).webp({
|
|
69
|
+
quality: 90,
|
|
70
|
+
// lossless: true,
|
|
71
|
+
// nearLossless: true,
|
|
72
|
+
effort: 5,
|
|
73
|
+
}).toBuffer();
|
|
74
|
+
// 변환 실패!
|
|
75
|
+
if (!convert) {
|
|
76
|
+
throw new Error('이미지 변환에 실패했습니다.');
|
|
77
|
+
}
|
|
78
|
+
const resized = size ? yield (0, sharp_1.default)(convert)
|
|
79
|
+
.resize({ width: size, withoutEnlargement: true })
|
|
80
|
+
.toBuffer() : convert;
|
|
81
|
+
if (!fileName)
|
|
82
|
+
fileName = (0, dayjs_1.default)().format('YYYYMMDDHHmmssSSS');
|
|
83
|
+
// 스트림을 사용하여 S3에 업로드
|
|
84
|
+
const Key = `${path}/${fileName}.webp`;
|
|
85
|
+
// S3에 업로드하고 결과 출력
|
|
86
|
+
const res = yield s3.send(new client_s3_1.PutObjectCommand({
|
|
87
|
+
Bucket,
|
|
88
|
+
Key,
|
|
89
|
+
Body: resized,
|
|
90
|
+
ACL: 'public-read'
|
|
91
|
+
}));
|
|
92
|
+
return Object.assign(Object.assign({}, res), { result: true, location: `https://${Bucket}.s3.ap-northeast-2.amazonaws.com/${Key}`, key: Key });
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
console.error('이미지 변환 및 업로드 실패:', err);
|
|
96
|
+
throw new Error('이미지 변환 및 업로드에 실패했습니다.');
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
exports.convertWebpAndUploadBuffer = convertWebpAndUploadBuffer;
|
|
100
|
+
const deleteS3Object = (key) => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
+
try {
|
|
102
|
+
const res = yield s3.send(new client_s3_1.DeleteObjectCommand({
|
|
103
|
+
Bucket,
|
|
104
|
+
Key: key,
|
|
105
|
+
}));
|
|
106
|
+
return Object.assign(Object.assign({}, res), { result: true });
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
console.error('S3 객체 삭제 실패:', err);
|
|
110
|
+
throw new Error('S3 객체 삭제에 실패했습니다.');
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
exports.deleteS3Object = deleteS3Object;
|
|
114
|
+
exports.default = {
|
|
115
|
+
convertWebpAndUploadFile: exports.convertWebpAndUploadFile,
|
|
116
|
+
convertWebpAndUploadBuffer: exports.convertWebpAndUploadBuffer,
|
|
117
|
+
deleteS3Object: exports.deleteS3Object,
|
|
118
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const _default: {
|
|
2
|
+
util: {
|
|
3
|
+
format: {
|
|
4
|
+
comma: (target: string | number) => string | 0 | undefined;
|
|
5
|
+
card: (cardNumber: string) => string;
|
|
6
|
+
tel: (tel: string) => string;
|
|
7
|
+
bizNum: (bizNum: string) => string;
|
|
8
|
+
};
|
|
9
|
+
is: {
|
|
10
|
+
isEng: (s: string) => boolean;
|
|
11
|
+
isKorean: (s: string) => boolean;
|
|
12
|
+
isNumber: (s: string) => boolean;
|
|
13
|
+
isSpecialChar: (s: string) => boolean;
|
|
14
|
+
};
|
|
15
|
+
feature: {
|
|
16
|
+
onChangeBrowserUrl: (searchParams: any) => void;
|
|
17
|
+
};
|
|
18
|
+
get: {
|
|
19
|
+
number: (value: string | number) => number;
|
|
20
|
+
josa: (word: string) => {
|
|
21
|
+
이가: string;
|
|
22
|
+
은는: string;
|
|
23
|
+
을를: string;
|
|
24
|
+
과와: string;
|
|
25
|
+
아야: string;
|
|
26
|
+
으로로: string;
|
|
27
|
+
};
|
|
28
|
+
byte: (str: string) => number;
|
|
29
|
+
age: (birth: string | number, isMonth?: boolean) => string;
|
|
30
|
+
time: (sec: number) => string;
|
|
31
|
+
diffProperties: (prev: any, next: any) => any;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
image: {
|
|
35
|
+
convertWebpAndUploadFile: ({ file, path, fileName, size }: {
|
|
36
|
+
file: File;
|
|
37
|
+
path: string;
|
|
38
|
+
fileName?: string;
|
|
39
|
+
size?: number;
|
|
40
|
+
}) => Promise<{
|
|
41
|
+
result: boolean;
|
|
42
|
+
location: string;
|
|
43
|
+
key: string;
|
|
44
|
+
Expiration?: string | undefined;
|
|
45
|
+
ETag?: string | undefined;
|
|
46
|
+
ChecksumCRC32?: string | undefined;
|
|
47
|
+
ChecksumCRC32C?: string | undefined;
|
|
48
|
+
ChecksumCRC64NVME?: string | undefined;
|
|
49
|
+
ChecksumSHA1?: string | undefined;
|
|
50
|
+
ChecksumSHA256?: string | undefined;
|
|
51
|
+
ChecksumType?: import("@aws-sdk/client-s3").ChecksumType | undefined;
|
|
52
|
+
ServerSideEncryption?: import("@aws-sdk/client-s3").ServerSideEncryption | undefined;
|
|
53
|
+
VersionId?: string | undefined;
|
|
54
|
+
SSECustomerAlgorithm?: string | undefined;
|
|
55
|
+
SSECustomerKeyMD5?: string | undefined;
|
|
56
|
+
SSEKMSKeyId?: string | undefined;
|
|
57
|
+
SSEKMSEncryptionContext?: string | undefined;
|
|
58
|
+
BucketKeyEnabled?: boolean | undefined;
|
|
59
|
+
Size?: number | undefined;
|
|
60
|
+
RequestCharged?: import("@aws-sdk/client-s3").RequestCharged | undefined;
|
|
61
|
+
$metadata: import("@smithy/types").ResponseMetadata;
|
|
62
|
+
}>;
|
|
63
|
+
convertWebpAndUploadBuffer: ({ buffer, path, fileName, size }: {
|
|
64
|
+
buffer: Buffer;
|
|
65
|
+
path: string;
|
|
66
|
+
fileName?: string;
|
|
67
|
+
size?: number;
|
|
68
|
+
}) => Promise<{
|
|
69
|
+
result: boolean;
|
|
70
|
+
location: string;
|
|
71
|
+
key: string;
|
|
72
|
+
Expiration?: string | undefined;
|
|
73
|
+
ETag?: string | undefined;
|
|
74
|
+
ChecksumCRC32?: string | undefined;
|
|
75
|
+
ChecksumCRC32C?: string | undefined;
|
|
76
|
+
ChecksumCRC64NVME?: string | undefined;
|
|
77
|
+
ChecksumSHA1?: string | undefined;
|
|
78
|
+
ChecksumSHA256?: string | undefined;
|
|
79
|
+
ChecksumType?: import("@aws-sdk/client-s3").ChecksumType | undefined;
|
|
80
|
+
ServerSideEncryption?: import("@aws-sdk/client-s3").ServerSideEncryption | undefined;
|
|
81
|
+
VersionId?: string | undefined;
|
|
82
|
+
SSECustomerAlgorithm?: string | undefined;
|
|
83
|
+
SSECustomerKeyMD5?: string | undefined;
|
|
84
|
+
SSEKMSKeyId?: string | undefined;
|
|
85
|
+
SSEKMSEncryptionContext?: string | undefined;
|
|
86
|
+
BucketKeyEnabled?: boolean | undefined;
|
|
87
|
+
Size?: number | undefined;
|
|
88
|
+
RequestCharged?: import("@aws-sdk/client-s3").RequestCharged | undefined;
|
|
89
|
+
$metadata: import("@smithy/types").ResponseMetadata;
|
|
90
|
+
}>;
|
|
91
|
+
deleteS3Object: (key: string) => Promise<{
|
|
92
|
+
result: boolean;
|
|
93
|
+
DeleteMarker?: boolean | undefined;
|
|
94
|
+
VersionId?: string | undefined;
|
|
95
|
+
RequestCharged?: import("@aws-sdk/client-s3").RequestCharged | undefined;
|
|
96
|
+
$metadata: import("@smithy/types").ResponseMetadata;
|
|
97
|
+
}>;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const hello = (name) => {
|
|
5
|
-
return `Hello, ${name}!`;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
4
|
};
|
|
7
|
-
exports
|
|
8
|
-
const
|
|
9
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const util_1 = __importDefault(require("./util"));
|
|
7
|
+
const image_1 = __importDefault(require("./image"));
|
|
8
|
+
exports.default = {
|
|
9
|
+
util: util_1.default,
|
|
10
|
+
image: image_1.default,
|
|
10
11
|
};
|
|
11
|
-
exports.add = add;
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export declare const format: {
|
|
2
|
+
/**
|
|
3
|
+
* 숫자에 3자리마다 콤마(,) 추가
|
|
4
|
+
*/
|
|
5
|
+
comma: (target: string | number) => string | 0 | undefined;
|
|
6
|
+
card: (cardNumber: string) => string;
|
|
7
|
+
tel: (tel: string) => string;
|
|
8
|
+
bizNum: (bizNum: string) => string;
|
|
9
|
+
};
|
|
10
|
+
export declare const is: {
|
|
11
|
+
isEng: (s: string) => boolean;
|
|
12
|
+
isKorean: (s: string) => boolean;
|
|
13
|
+
isNumber: (s: string) => boolean;
|
|
14
|
+
isSpecialChar: (s: string) => boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const feature: {
|
|
17
|
+
onChangeBrowserUrl: (searchParams: any) => void;
|
|
18
|
+
};
|
|
19
|
+
export declare const get: {
|
|
20
|
+
number: (value: string | number) => number;
|
|
21
|
+
josa: (word: string) => {
|
|
22
|
+
이가: string;
|
|
23
|
+
은는: string;
|
|
24
|
+
을를: string;
|
|
25
|
+
과와: string;
|
|
26
|
+
아야: string;
|
|
27
|
+
으로로: string;
|
|
28
|
+
};
|
|
29
|
+
byte: (str: string) => number;
|
|
30
|
+
age: (birth: string | number, isMonth?: boolean) => string;
|
|
31
|
+
time: (sec: number) => string;
|
|
32
|
+
diffProperties: (prev: any, next: any) => any;
|
|
33
|
+
};
|
|
34
|
+
declare const _default: {
|
|
35
|
+
format: {
|
|
36
|
+
/**
|
|
37
|
+
* 숫자에 3자리마다 콤마(,) 추가
|
|
38
|
+
*/
|
|
39
|
+
comma: (target: string | number) => string | 0 | undefined;
|
|
40
|
+
card: (cardNumber: string) => string;
|
|
41
|
+
tel: (tel: string) => string;
|
|
42
|
+
bizNum: (bizNum: string) => string;
|
|
43
|
+
};
|
|
44
|
+
is: {
|
|
45
|
+
isEng: (s: string) => boolean;
|
|
46
|
+
isKorean: (s: string) => boolean;
|
|
47
|
+
isNumber: (s: string) => boolean;
|
|
48
|
+
isSpecialChar: (s: string) => boolean;
|
|
49
|
+
};
|
|
50
|
+
feature: {
|
|
51
|
+
onChangeBrowserUrl: (searchParams: any) => void;
|
|
52
|
+
};
|
|
53
|
+
get: {
|
|
54
|
+
number: (value: string | number) => number;
|
|
55
|
+
josa: (word: string) => {
|
|
56
|
+
이가: string;
|
|
57
|
+
은는: string;
|
|
58
|
+
을를: string;
|
|
59
|
+
과와: string;
|
|
60
|
+
아야: string;
|
|
61
|
+
으로로: string;
|
|
62
|
+
};
|
|
63
|
+
byte: (str: string) => number;
|
|
64
|
+
age: (birth: string | number, isMonth?: boolean) => string;
|
|
65
|
+
time: (sec: number) => string;
|
|
66
|
+
diffProperties: (prev: any, next: any) => any;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export default _default;
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get = exports.feature = exports.is = exports.format = void 0;
|
|
4
|
+
exports.format = {
|
|
5
|
+
/**
|
|
6
|
+
* 숫자에 3자리마다 콤마(,) 추가
|
|
7
|
+
*/
|
|
8
|
+
comma: (target) => {
|
|
9
|
+
if (Number(target) === 0)
|
|
10
|
+
return 0;
|
|
11
|
+
else if (target)
|
|
12
|
+
return target.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
13
|
+
else
|
|
14
|
+
target;
|
|
15
|
+
},
|
|
16
|
+
// 신용카드 번호에 하이픈(-) 추가
|
|
17
|
+
card: (cardNumber) => {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
if (!cardNumber)
|
|
20
|
+
return cardNumber;
|
|
21
|
+
return (_b = (_a = cardNumber.match(/.{1,4}/g)) === null || _a === void 0 ? void 0 : _a.join('-')) !== null && _b !== void 0 ? _b : cardNumber;
|
|
22
|
+
},
|
|
23
|
+
// 전화번호에 하이픈(-) 추가
|
|
24
|
+
tel: (tel) => {
|
|
25
|
+
if (!tel)
|
|
26
|
+
return tel;
|
|
27
|
+
if (tel.length === 11) {
|
|
28
|
+
return tel.replace(/(\d{3})(\d{4})(\d{4})/, '$1-$2-$3');
|
|
29
|
+
}
|
|
30
|
+
else if (tel.length === 10) {
|
|
31
|
+
return tel.replace(/(\d{3})(\d{3})(\d{4})/, '$1-$2-$3');
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return tel;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
// 사업자등록번호에 하이픈(-) 추가
|
|
38
|
+
bizNum: (bizNum) => {
|
|
39
|
+
if (!bizNum)
|
|
40
|
+
return bizNum;
|
|
41
|
+
if (bizNum.length === 10) {
|
|
42
|
+
return bizNum.replace(/(\d{3})(\d{2})(\d{5})/, '$1-$2-$3');
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return bizNum;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.is = {
|
|
50
|
+
isEng: (s) => {
|
|
51
|
+
return /[A-Za-z]/.test(s);
|
|
52
|
+
},
|
|
53
|
+
isKorean: (s) => {
|
|
54
|
+
return /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/.test(s);
|
|
55
|
+
},
|
|
56
|
+
isNumber: (s) => {
|
|
57
|
+
return /[0-9]/.test(s);
|
|
58
|
+
},
|
|
59
|
+
isSpecialChar: (s) => {
|
|
60
|
+
return /[~!@#$%^&*()_+|<>?:{}]/.test(s);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
exports.feature = {
|
|
64
|
+
// 브라우저 URL의 쿼리 파라미터를 갱신
|
|
65
|
+
onChangeBrowserUrl: (searchParams) => {
|
|
66
|
+
const queryString = Object.entries(searchParams)
|
|
67
|
+
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
|
68
|
+
.flatMap(([key, value]) => {
|
|
69
|
+
if (Array.isArray(value)) {
|
|
70
|
+
return value.map(v => `${encodeURIComponent(key)}[]=${encodeURIComponent(v)}`);
|
|
71
|
+
}
|
|
72
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
73
|
+
})
|
|
74
|
+
.join('&');
|
|
75
|
+
const newUrl = `${window.location.pathname}?${queryString}`;
|
|
76
|
+
window.history.replaceState(null, '', newUrl);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
exports.get = {
|
|
80
|
+
// 문자열이나 숫자에서 숫자만 추출하여 반환
|
|
81
|
+
number: (value) => {
|
|
82
|
+
if (typeof value === "number") {
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
const match = value.match(/[\d.]+/g);
|
|
86
|
+
return match ? parseFloat(match[0]) : 0;
|
|
87
|
+
},
|
|
88
|
+
// 한글 조사 처리
|
|
89
|
+
josa: (word) => {
|
|
90
|
+
const lastChar = word.charAt(word.length - 1);
|
|
91
|
+
const code = lastChar.charCodeAt(0);
|
|
92
|
+
if (code >= 44032 && code <= 55203) {
|
|
93
|
+
const jong = (code - 44032) % 28;
|
|
94
|
+
const hasFinalConsonant = jong !== 0;
|
|
95
|
+
return {
|
|
96
|
+
이가: hasFinalConsonant ? '이' : '가',
|
|
97
|
+
은는: hasFinalConsonant ? '은' : '는',
|
|
98
|
+
을를: hasFinalConsonant ? '을' : '를',
|
|
99
|
+
과와: hasFinalConsonant ? '과' : '와',
|
|
100
|
+
아야: hasFinalConsonant ? '아' : '야',
|
|
101
|
+
으로로: hasFinalConsonant ? '으로' : '로'
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
이가: '이',
|
|
106
|
+
은는: '은',
|
|
107
|
+
을를: '을',
|
|
108
|
+
과와: '과',
|
|
109
|
+
아야: '아',
|
|
110
|
+
으로로: '으로'
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
// UTF-8 인코딩에서 각 문자의 바이트 수 계산
|
|
114
|
+
byte: (str) => {
|
|
115
|
+
let byteSize = 0;
|
|
116
|
+
for (let i = 0; i < str.length; i++) {
|
|
117
|
+
const charCode = str.charCodeAt(i);
|
|
118
|
+
if (charCode <= 0x7F) {
|
|
119
|
+
byteSize += 1; // ASCII 문자 (1바이트)
|
|
120
|
+
}
|
|
121
|
+
else if (charCode <= 0x7FF) {
|
|
122
|
+
byteSize += 2; // 2바이트 문자
|
|
123
|
+
}
|
|
124
|
+
else if (charCode <= 0xFFFF) {
|
|
125
|
+
byteSize += 3; // 3바이트 문자 (대부분의 한글, 한자 등)
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
byteSize += 4; // 4바이트 문자 (이모지 등)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return byteSize;
|
|
132
|
+
},
|
|
133
|
+
// 생년월일(YYYYMMDD)로부터 만 나이 계산
|
|
134
|
+
age: (birth, isMonth) => {
|
|
135
|
+
const birthStr = String(birth);
|
|
136
|
+
if (!/^\d{8}$/.test(birthStr))
|
|
137
|
+
return '';
|
|
138
|
+
const year = parseInt(birthStr.substring(0, 4), 10);
|
|
139
|
+
const month = parseInt(birthStr.substring(4, 6), 10);
|
|
140
|
+
const day = parseInt(birthStr.substring(6, 8), 10);
|
|
141
|
+
const today = new Date();
|
|
142
|
+
let age = today.getFullYear() - year;
|
|
143
|
+
let monthDiff = today.getMonth() + 1 - month;
|
|
144
|
+
let dayDiff = today.getDate() - day;
|
|
145
|
+
if (monthDiff < 0 || (monthDiff === 0 && dayDiff < 0)) {
|
|
146
|
+
age--;
|
|
147
|
+
monthDiff += 12;
|
|
148
|
+
}
|
|
149
|
+
if (dayDiff < 0) {
|
|
150
|
+
monthDiff--;
|
|
151
|
+
if (monthDiff < 0) {
|
|
152
|
+
monthDiff += 12;
|
|
153
|
+
age--;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (age < 0)
|
|
157
|
+
return '';
|
|
158
|
+
if (isMonth) {
|
|
159
|
+
return `만 ${age}세 ${monthDiff}개월`;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
return `만 ${age}세`;
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
// 초 단위를 받아서 "X일 Y시간 Z분" 형식으로 변환
|
|
166
|
+
time: (sec) => {
|
|
167
|
+
const days = Math.floor(sec / 86400);
|
|
168
|
+
const hours = Math.floor((sec % 86400) / 3600);
|
|
169
|
+
const minutes = Math.floor((sec % 3600) / 60);
|
|
170
|
+
const parts = [];
|
|
171
|
+
if (days > 0) {
|
|
172
|
+
parts.push(`${days}일`);
|
|
173
|
+
}
|
|
174
|
+
if (hours > 0) {
|
|
175
|
+
parts.push(`${hours}시간`);
|
|
176
|
+
}
|
|
177
|
+
if (minutes > 0) {
|
|
178
|
+
parts.push(`${minutes}분`);
|
|
179
|
+
}
|
|
180
|
+
return parts.length > 0 ? parts.join(' ') : '0분';
|
|
181
|
+
},
|
|
182
|
+
diffProperties: (prev, next) => {
|
|
183
|
+
if (prev && next) {
|
|
184
|
+
const keys = Object.keys(prev);
|
|
185
|
+
const diffObj = {};
|
|
186
|
+
let count = 0;
|
|
187
|
+
for (const key of keys) {
|
|
188
|
+
if (String(prev[key]) !== String(next[key])) {
|
|
189
|
+
count++;
|
|
190
|
+
diffObj[key] = next[key];
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return count ? diffObj : false;
|
|
194
|
+
}
|
|
195
|
+
else
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
exports.default = {
|
|
200
|
+
format: exports.format,
|
|
201
|
+
is: exports.is,
|
|
202
|
+
feature: exports.feature,
|
|
203
|
+
get: exports.get
|
|
204
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linkup-lib",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "링크업 패키지",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,11 +18,20 @@
|
|
|
18
18
|
"prepublishOnly": "npm run build",
|
|
19
19
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
20
20
|
},
|
|
21
|
-
"keywords": [
|
|
21
|
+
"keywords": [
|
|
22
|
+
"linkup"
|
|
23
|
+
],
|
|
22
24
|
"author": "leeyoonmin",
|
|
23
25
|
"license": "MIT",
|
|
24
26
|
"devDependencies": {
|
|
25
27
|
"@types/node": "^25.0.3",
|
|
26
28
|
"typescript": "^5.9.3"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@aws-sdk/client-s3": "^3.962.0",
|
|
32
|
+
"axios": "^1.13.2",
|
|
33
|
+
"dayjs": "^1.11.19",
|
|
34
|
+
"mysql2": "^3.16.0",
|
|
35
|
+
"sharp": "^0.34.5"
|
|
27
36
|
}
|
|
28
37
|
}
|