@fuzionx/framework 0.1.39 → 0.1.41
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/README.md +501 -501
- package/bin/fx.js +12 -12
- package/cli/db-sync.js +99 -99
- package/cli/index.js +493 -493
- package/cli/templates/make/app/controllers/HomeController.js +14 -14
- package/cli/templates/make/app/routes/api.js +7 -7
- package/cli/templates/make/app/routes/web.js +5 -5
- package/cli/templates/make/app/views/default/errors/404.html +11 -11
- package/cli/templates/make/app/views/default/errors/500.html +14 -14
- package/cli/templates/make/app/views/default/layouts/main.html +22 -22
- package/cli/templates/make/app/views/default/pages/home.html +11 -11
- package/cli/templates/make/controller.js.tpl +40 -40
- package/cli/templates/make/event.js.tpl +8 -8
- package/cli/templates/make/job.js.tpl +10 -10
- package/cli/templates/make/middleware.js.tpl +10 -10
- package/cli/templates/make/model.js.tpl +15 -15
- package/cli/templates/make/service.js.tpl +15 -15
- package/cli/templates/make/task.js.tpl +15 -15
- package/cli/templates/make/test.js.tpl +7 -7
- package/cli/templates/make/worker.js.tpl +14 -14
- package/cli/templates/make/ws.js.tpl +18 -18
- package/index.js +67 -67
- package/lib/core/AppError.js +46 -46
- package/lib/core/Application.js +1006 -1006
- package/lib/core/AutoLoader.js +226 -226
- package/lib/core/Base.js +64 -64
- package/lib/core/Config.js +228 -228
- package/lib/core/Context.js +484 -484
- package/lib/database/ConnectionManager.js +208 -208
- package/lib/database/MariaModel.js +29 -29
- package/lib/database/Model.js +247 -247
- package/lib/database/ModelRegistry.js +72 -72
- package/lib/database/MongoModel.js +232 -232
- package/lib/database/Pagination.js +37 -37
- package/lib/database/PostgreModel.js +29 -29
- package/lib/database/QueryBuilder.js +172 -172
- package/lib/database/SQLiteModel.js +27 -27
- package/lib/database/SqlModel.js +257 -257
- package/lib/database/SqlQueryBuilder.js +332 -332
- package/lib/helpers/CryptoHelper.js +48 -48
- package/lib/helpers/FileHelper.js +61 -61
- package/lib/helpers/HashHelper.js +39 -39
- package/lib/helpers/I18nHelper.js +174 -174
- package/lib/helpers/Logger.js +108 -108
- package/lib/helpers/MediaHelper.js +84 -84
- package/lib/http/Controller.js +34 -34
- package/lib/http/ErrorHandler.js +136 -136
- package/lib/http/Middleware.js +43 -43
- package/lib/http/Router.js +109 -109
- package/lib/http/Validation.js +125 -125
- package/lib/middleware/apiAuth.js +79 -79
- package/lib/middleware/auth.js +42 -42
- package/lib/middleware/bodyParser.js +19 -19
- package/lib/middleware/cors.js +47 -47
- package/lib/middleware/csrf.js +32 -32
- package/lib/middleware/index.js +13 -13
- package/lib/middleware/session.js +27 -27
- package/lib/middleware/theme.js +20 -20
- package/lib/realtime/RoomManager.js +85 -85
- package/lib/realtime/WsHandler.js +107 -107
- package/lib/schedule/Job.js +38 -38
- package/lib/schedule/Queue.js +103 -103
- package/lib/schedule/Scheduler.js +171 -171
- package/lib/schedule/Task.js +39 -39
- package/lib/schedule/WorkerPool.js +225 -225
- package/lib/services/EventBus.js +94 -94
- package/lib/services/Service.js +261 -261
- package/lib/services/Storage.js +112 -112
- package/lib/utilities/ArrUtil.js +112 -112
- package/lib/utilities/DateUtil.js +98 -98
- package/lib/utilities/FunctionUtil.js +119 -119
- package/lib/utilities/NumUtil.js +75 -75
- package/lib/utilities/ObjectUtil.js +170 -170
- package/lib/utilities/PaginationUtil.js +81 -81
- package/lib/utilities/StrUtil.js +105 -105
- package/lib/utilities/index.js +18 -18
- package/lib/view/OpenAPI.js +231 -231
- package/lib/view/View.js +83 -83
- package/package.json +2 -2
- package/testing/index.js +232 -232
package/lib/utilities/StrUtil.js
CHANGED
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* StrUtil — 문자열 순수 유틸리티
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* URL-safe slug 생성
|
|
7
|
-
* @param {string} str
|
|
8
|
-
* @returns {string}
|
|
9
|
-
*/
|
|
10
|
-
export function slug(str) {
|
|
11
|
-
return str
|
|
12
|
-
.toLowerCase()
|
|
13
|
-
.trim()
|
|
14
|
-
.replace(/[^\w\s가-힣-]/g, '')
|
|
15
|
-
.replace(/[\s_]+/g, '-')
|
|
16
|
-
.replace(/^-+|-+$/g, '');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 말줄임 (한글/이모지 안전)
|
|
21
|
-
* @param {string} str
|
|
22
|
-
* @param {number} len
|
|
23
|
-
* @param {string} [suffix='…']
|
|
24
|
-
* @returns {string}
|
|
25
|
-
*/
|
|
26
|
-
export function truncate(str, len, suffix = '…') {
|
|
27
|
-
if (!str || str.length <= len) return str || '';
|
|
28
|
-
return str.slice(0, len) + suffix;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* camelCase 변환
|
|
33
|
-
* @param {string} str
|
|
34
|
-
* @returns {string}
|
|
35
|
-
*/
|
|
36
|
-
export function camelCase(str) {
|
|
37
|
-
return str
|
|
38
|
-
.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : '')
|
|
39
|
-
.replace(/^[A-Z]/, c => c.toLowerCase());
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* snake_case 변환
|
|
44
|
-
* @param {string} str
|
|
45
|
-
* @returns {string}
|
|
46
|
-
*/
|
|
47
|
-
export function snakeCase(str) {
|
|
48
|
-
return str
|
|
49
|
-
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
50
|
-
.replace(/[-\s]+/g, '_')
|
|
51
|
-
.toLowerCase();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* PascalCase 변환
|
|
56
|
-
* @param {string} str
|
|
57
|
-
* @returns {string}
|
|
58
|
-
*/
|
|
59
|
-
export function pascalCase(str) {
|
|
60
|
-
return str
|
|
61
|
-
.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : '')
|
|
62
|
-
.replace(/^[a-z]/, c => c.toUpperCase());
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 첫 글자 대문자
|
|
67
|
-
* @param {string} str
|
|
68
|
-
* @returns {string}
|
|
69
|
-
*/
|
|
70
|
-
export function capitalize(str) {
|
|
71
|
-
if (!str) return '';
|
|
72
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* 랜덤 문자열 생성
|
|
77
|
-
* @param {number} len
|
|
78
|
-
* @param {string} [chars]
|
|
79
|
-
* @returns {string}
|
|
80
|
-
*/
|
|
81
|
-
export function random(len = 16, chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') {
|
|
82
|
-
let result = '';
|
|
83
|
-
for (let i = 0; i < len; i++) {
|
|
84
|
-
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
85
|
-
}
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* 마스킹 (이메일, 전화번호 등)
|
|
91
|
-
* @param {string} str
|
|
92
|
-
* @param {number} [visibleStart=2]
|
|
93
|
-
* @param {number} [visibleEnd=2]
|
|
94
|
-
* @param {string} [mask='*']
|
|
95
|
-
* @returns {string}
|
|
96
|
-
*
|
|
97
|
-
* @example mask('hello@test.com', 2, 4) → 'he*****t.com'
|
|
98
|
-
*/
|
|
99
|
-
export function mask(str, visibleStart = 2, visibleEnd = 2, maskChar = '*') {
|
|
100
|
-
if (!str || str.length <= visibleStart + visibleEnd) return str || '';
|
|
101
|
-
const start = str.slice(0, visibleStart);
|
|
102
|
-
const end = str.slice(-visibleEnd);
|
|
103
|
-
const middle = maskChar.repeat(str.length - visibleStart - visibleEnd);
|
|
104
|
-
return start + middle + end;
|
|
105
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* StrUtil — 문자열 순수 유틸리티
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* URL-safe slug 생성
|
|
7
|
+
* @param {string} str
|
|
8
|
+
* @returns {string}
|
|
9
|
+
*/
|
|
10
|
+
export function slug(str) {
|
|
11
|
+
return str
|
|
12
|
+
.toLowerCase()
|
|
13
|
+
.trim()
|
|
14
|
+
.replace(/[^\w\s가-힣-]/g, '')
|
|
15
|
+
.replace(/[\s_]+/g, '-')
|
|
16
|
+
.replace(/^-+|-+$/g, '');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 말줄임 (한글/이모지 안전)
|
|
21
|
+
* @param {string} str
|
|
22
|
+
* @param {number} len
|
|
23
|
+
* @param {string} [suffix='…']
|
|
24
|
+
* @returns {string}
|
|
25
|
+
*/
|
|
26
|
+
export function truncate(str, len, suffix = '…') {
|
|
27
|
+
if (!str || str.length <= len) return str || '';
|
|
28
|
+
return str.slice(0, len) + suffix;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* camelCase 변환
|
|
33
|
+
* @param {string} str
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
export function camelCase(str) {
|
|
37
|
+
return str
|
|
38
|
+
.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : '')
|
|
39
|
+
.replace(/^[A-Z]/, c => c.toLowerCase());
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* snake_case 변환
|
|
44
|
+
* @param {string} str
|
|
45
|
+
* @returns {string}
|
|
46
|
+
*/
|
|
47
|
+
export function snakeCase(str) {
|
|
48
|
+
return str
|
|
49
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
50
|
+
.replace(/[-\s]+/g, '_')
|
|
51
|
+
.toLowerCase();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* PascalCase 변환
|
|
56
|
+
* @param {string} str
|
|
57
|
+
* @returns {string}
|
|
58
|
+
*/
|
|
59
|
+
export function pascalCase(str) {
|
|
60
|
+
return str
|
|
61
|
+
.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : '')
|
|
62
|
+
.replace(/^[a-z]/, c => c.toUpperCase());
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 첫 글자 대문자
|
|
67
|
+
* @param {string} str
|
|
68
|
+
* @returns {string}
|
|
69
|
+
*/
|
|
70
|
+
export function capitalize(str) {
|
|
71
|
+
if (!str) return '';
|
|
72
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 랜덤 문자열 생성
|
|
77
|
+
* @param {number} len
|
|
78
|
+
* @param {string} [chars]
|
|
79
|
+
* @returns {string}
|
|
80
|
+
*/
|
|
81
|
+
export function random(len = 16, chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') {
|
|
82
|
+
let result = '';
|
|
83
|
+
for (let i = 0; i < len; i++) {
|
|
84
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 마스킹 (이메일, 전화번호 등)
|
|
91
|
+
* @param {string} str
|
|
92
|
+
* @param {number} [visibleStart=2]
|
|
93
|
+
* @param {number} [visibleEnd=2]
|
|
94
|
+
* @param {string} [mask='*']
|
|
95
|
+
* @returns {string}
|
|
96
|
+
*
|
|
97
|
+
* @example mask('hello@test.com', 2, 4) → 'he*****t.com'
|
|
98
|
+
*/
|
|
99
|
+
export function mask(str, visibleStart = 2, visibleEnd = 2, maskChar = '*') {
|
|
100
|
+
if (!str || str.length <= visibleStart + visibleEnd) return str || '';
|
|
101
|
+
const start = str.slice(0, visibleStart);
|
|
102
|
+
const end = str.slice(-visibleEnd);
|
|
103
|
+
const middle = maskChar.repeat(str.length - visibleStart - visibleEnd);
|
|
104
|
+
return start + middle + end;
|
|
105
|
+
}
|
package/lib/utilities/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utilities — 순수 함수 유틸리티 배럴 export
|
|
3
|
-
*
|
|
4
|
-
* Helper와 달리 Bridge/App 의존 없이 import 즉시 사용 가능.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* import { PaginationUtil, StrUtil, ObjectUtil } from '@fuzionx/framework';
|
|
8
|
-
* const meta = PaginationUtil.buildMeta(100, 1, 20);
|
|
9
|
-
* const s = StrUtil.slug('Hello World');
|
|
10
|
-
* const cleaned = ObjectUtil.omit(user, ['password']);
|
|
11
|
-
*/
|
|
12
|
-
export * as PaginationUtil from './PaginationUtil.js';
|
|
13
|
-
export * as StrUtil from './StrUtil.js';
|
|
14
|
-
export * as NumUtil from './NumUtil.js';
|
|
15
|
-
export * as DateUtil from './DateUtil.js';
|
|
16
|
-
export * as ArrUtil from './ArrUtil.js';
|
|
17
|
-
export * as FunctionUtil from './FunctionUtil.js';
|
|
18
|
-
export * as ObjectUtil from './ObjectUtil.js';
|
|
1
|
+
/**
|
|
2
|
+
* Utilities — 순수 함수 유틸리티 배럴 export
|
|
3
|
+
*
|
|
4
|
+
* Helper와 달리 Bridge/App 의존 없이 import 즉시 사용 가능.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import { PaginationUtil, StrUtil, ObjectUtil } from '@fuzionx/framework';
|
|
8
|
+
* const meta = PaginationUtil.buildMeta(100, 1, 20);
|
|
9
|
+
* const s = StrUtil.slug('Hello World');
|
|
10
|
+
* const cleaned = ObjectUtil.omit(user, ['password']);
|
|
11
|
+
*/
|
|
12
|
+
export * as PaginationUtil from './PaginationUtil.js';
|
|
13
|
+
export * as StrUtil from './StrUtil.js';
|
|
14
|
+
export * as NumUtil from './NumUtil.js';
|
|
15
|
+
export * as DateUtil from './DateUtil.js';
|
|
16
|
+
export * as ArrUtil from './ArrUtil.js';
|
|
17
|
+
export * as FunctionUtil from './FunctionUtil.js';
|
|
18
|
+
export * as ObjectUtil from './ObjectUtil.js';
|