xypriss 9.5.51 → 9.5.53
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 +1 -1
- package/dist/cjs/src/index.js +3 -0
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/utils/getMime.js +96 -0
- package/dist/cjs/src/utils/getMime.js.map +1 -0
- package/dist/esm/src/index.js +1 -0
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/utils/getMime.js +93 -0
- package/dist/esm/src/utils/getMime.js.map +1 -0
- package/dist/index.d.ts +53 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ This separation allows each layer to operate in its optimal domain: compiled nat
|
|
|
56
56
|
- **Advanced Radix Routing** — Ultra-fast routing system capable of complex path matching with microsecond latency.
|
|
57
57
|
- **Real-Time System Intelligence** — Native access to CPU, memory, disk, network, battery, and process metrics directly from the application layer.
|
|
58
58
|
- **Filesystem Engine & Binary Streaming** — High-performance filesystem operations, duplicate detection, and robust **Zero-Copy Ranged Streaming** via `res.sendFile()`, optimized for media delivery and large assets.
|
|
59
|
-
- **File Upload Management** — Production-ready multipart/form-data handling with automatic validation and
|
|
59
|
+
- **File Upload Management** — Production-ready multipart/form-data handling with automatic validation, error handling, and the `getMimes()` helper for extension-to-mime mapping.
|
|
60
60
|
- **Environment Security Shield** — Military-grade protection for sensitive variables. Direct `process.env` access is masked via a native Proxy to prevent accidental leakage, forcing the use of secure, typed APIs.
|
|
61
61
|
- **Built-in DotEnv Loader** — Zero-dependency, ultra-fast `.env` parser with automatic support for `.env`, `.env.local`, and `.private/.env`.
|
|
62
62
|
- **Extensible Plugin System** — Permission-based plugin architecture with lifecycle hooks and security controls.
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -18,6 +18,7 @@ var PluginHookIds = require('./plugins/const/PluginHookIds.js');
|
|
|
18
18
|
var mergeWithDefaults = require('./utils/mergeWithDefaults.js');
|
|
19
19
|
var getIp = require('./utils/getIp.js');
|
|
20
20
|
var XemsPlugin = require('./plugins/modules/xems/XemsPlugin.js');
|
|
21
|
+
var getMime = require('./utils/getMime.js');
|
|
21
22
|
var xyprissSecurity = require('xypriss-security');
|
|
22
23
|
var safeJsonMiddleware = require('./middleware/safe-json-middleware.js');
|
|
23
24
|
var FiUp = require('./FiUp.js');
|
|
@@ -83,6 +84,8 @@ exports.mergeWithDefaults = mergeWithDefaults.mergeWithDefaults;
|
|
|
83
84
|
exports.mwdef = mergeWithDefaults.mergeWithDefaults;
|
|
84
85
|
exports.getIp = getIp.getIp;
|
|
85
86
|
exports.xems = XemsPlugin.xems;
|
|
87
|
+
exports.getMime = getMime.getMime;
|
|
88
|
+
exports.getMimes = getMime.getMimes;
|
|
86
89
|
Object.defineProperty(exports, "XyPriStringify", {
|
|
87
90
|
enumerable: true,
|
|
88
91
|
get: function () { return xyprissSecurity.XyPriStringify; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":[null],"names":["configLoader","XyPrissRouter"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":[null],"names":["configLoader","XyPrissRouter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBiF;AAqBjF;AACA,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE;IACnCA,yBAAY,CAAC,qBAAqB,EAAE;AACxC;AAqGA;;AAEG;SACa,MAAM,GAAA;IAClB,OAAO,IAAIC,sBAAa,CAAC;AACrB,QAAA,aAAa,EAAE,KAAK;AACpB,QAAA,WAAW,EAAE,KAAK;AAClB,QAAA,MAAM,EAAE,KAAK;AAChB,KAAA,CAAC;AACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var MIME_MAP = require('../server/const/MIME_MAP.js');
|
|
4
|
+
var config = require('../config.js');
|
|
5
|
+
|
|
6
|
+
/***************************************************************************
|
|
7
|
+
* XyPriss - Fast And Secure
|
|
8
|
+
*
|
|
9
|
+
* @author Nehonix
|
|
10
|
+
* @license Nehonix OSL (NOSL)
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) 2025 Nehonix. All rights reserved.
|
|
13
|
+
****************************************************************************/
|
|
14
|
+
/**
|
|
15
|
+
* Resolves a single MIME type from a file extension.
|
|
16
|
+
*
|
|
17
|
+
* @param ext - The file extension (e.g., '.png' or 'jpg').
|
|
18
|
+
* @returns The corresponding MIME type or 'application/octet-stream' if unknown.
|
|
19
|
+
*/
|
|
20
|
+
const getMime = (ext) => {
|
|
21
|
+
if (!ext)
|
|
22
|
+
return "application/octet-stream";
|
|
23
|
+
const normalized = ext.startsWith(".")
|
|
24
|
+
? ext.toLowerCase()
|
|
25
|
+
: `.${ext.toLowerCase()}`;
|
|
26
|
+
return MIME_MAP.MIME_MAP[normalized] || "application/octet-stream";
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Advanced utility to resolve multiple MIME types from file extensions.
|
|
30
|
+
*
|
|
31
|
+
* This helper is designed to simplify server configurations, particularly for
|
|
32
|
+
* 'fileUpload' and security policies, by allowing developers to specify
|
|
33
|
+
* human-readable extensions instead of complex MIME strings.
|
|
34
|
+
*
|
|
35
|
+
* FEATURES:
|
|
36
|
+
* - Supports single extensions or arrays.
|
|
37
|
+
* - Automatically normalizes extensions (handles missing dots).
|
|
38
|
+
* - Deduplicates results to ensure a clean MIME array.
|
|
39
|
+
* - Can fall back to global 'fileUpload.allowedExtensions' if no argument is provided.
|
|
40
|
+
*
|
|
41
|
+
* @param extensions - A single extension (e.g., '.png') or an array (e.g., ['.jpg', '.pdf']).
|
|
42
|
+
* If omitted, the function attempts to read from global configuration.
|
|
43
|
+
* @returns A unique array of resolved MIME types.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // 1. Map an array of extensions for file upload configuration
|
|
47
|
+
* const uploadConfig = {
|
|
48
|
+
* allowedMimeTypes: getMimes(['.png', '.jpg', '.jpeg', '.webp'])
|
|
49
|
+
* };
|
|
50
|
+
* // Result: ['image/png', 'image/jpeg', 'image/webp']
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // 2. Map a single extension
|
|
54
|
+
* const mimes = getMimes('.pdf');
|
|
55
|
+
* // Result: ['application/pdf']
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // 3. Automatic detection from xypriss.config.json
|
|
59
|
+
* // If config has: { "fileUpload": { "allowedExtensions": [".zip", ".rar"] } }
|
|
60
|
+
* const mimes = getMimes();
|
|
61
|
+
* // Result: ['application/zip', 'application/vnd.rar']
|
|
62
|
+
*/
|
|
63
|
+
const getMimes = (extensions) => {
|
|
64
|
+
let targetExts = [];
|
|
65
|
+
if (extensions) {
|
|
66
|
+
targetExts = Array.isArray(extensions) ? extensions : [extensions];
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// Fallback to global framework configuration if available
|
|
70
|
+
try {
|
|
71
|
+
const uMimeConfig = config.__cfg__.get("fileUpload")?.allowedExtensions;
|
|
72
|
+
if (Array.isArray(uMimeConfig)) {
|
|
73
|
+
targetExts = uMimeConfig;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
// Config might not be initialized yet in early-loading contexts
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (targetExts.length === 0)
|
|
82
|
+
return [];
|
|
83
|
+
const mimeSet = new Set();
|
|
84
|
+
for (const ext of targetExts) {
|
|
85
|
+
if (!ext)
|
|
86
|
+
continue;
|
|
87
|
+
const mime = getMime(ext);
|
|
88
|
+
if (mime)
|
|
89
|
+
mimeSet.add(mime);
|
|
90
|
+
}
|
|
91
|
+
return Array.from(mimeSet);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
exports.getMime = getMime;
|
|
95
|
+
exports.getMimes = getMimes;
|
|
96
|
+
//# sourceMappingURL=getMime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMime.js","sources":["../../../../src/utils/getMime.ts"],"sourcesContent":[null],"names":["MIME_MAP","__cfg__"],"mappings":";;;;;AAAA;;;;;;;AAO8E;AAK9E;;;;;AAKG;AACI,MAAM,OAAO,GAAG,CAAC,GAAW,KAAY;AAC3C,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,OAAO,0BAA0B;AAC3C,IAAA,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG;AACjC,UAAE,GAAG,CAAC,WAAW;AACjB,UAAE,CAAA,CAAA,EAAI,GAAG,CAAC,WAAW,EAAE,EAAE;AAC7B,IAAA,OAAOA,iBAAQ,CAAC,UAAU,CAAC,IAAI,0BAA0B;AAC7D;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCG;AACI,MAAM,QAAQ,GAAG,CAAC,UAA8B,KAAc;IACjE,IAAI,UAAU,GAAa,EAAE;IAE7B,IAAI,UAAU,EAAE;AACZ,QAAA,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,UAAU,CAAC;IACtE;SAAO;;AAEH,QAAA,IAAI;YACA,MAAM,WAAW,GAAGC,cAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,iBAAiB;AAChE,YAAA,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;gBAC5B,UAAU,GAAG,WAAW;YAC5B;QACJ;QAAE,OAAO,CAAC,EAAE;;AAER,YAAA,OAAO,EAAE;QACb;IACJ;AAEA,IAAA,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,EAAE;AAEtC,IAAA,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU;AACjC,IAAA,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;AAC1B,QAAA,IAAI,CAAC,GAAG;YAAE;AACV,QAAA,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;AACzB,QAAA,IAAI,IAAI;AAAE,YAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;IAC/B;AAEA,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;AAC9B;;;;;"}
|
package/dist/esm/src/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export { PluginHookIds } from './plugins/const/PluginHookIds.js';
|
|
|
16
16
|
export { mergeWithDefaults, mergeWithDefaults as mwdef } from './utils/mergeWithDefaults.js';
|
|
17
17
|
export { getIp } from './utils/getIp.js';
|
|
18
18
|
export { xems } from './plugins/modules/xems/XemsPlugin.js';
|
|
19
|
+
export { getMime, getMimes } from './utils/getMime.js';
|
|
19
20
|
export { XyPriStringify, fastStringify, safeStringify } from 'xypriss-security';
|
|
20
21
|
export { createCircularRefDebugger, createSafeJsonMiddleware, safeJsonStringify, sendSafeJson, setupSafeJson } from './middleware/safe-json-middleware.js';
|
|
21
22
|
export { initializeFileUpload, uploadAny, uploadArray, uploadFields, uploadSingle } from './FiUp.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBiF;AAqBjF;AACA,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE;IACnC,YAAY,CAAC,qBAAqB,EAAE;AACxC;AAqGA;;AAEG;SACa,MAAM,GAAA;IAClB,OAAO,IAAI,aAAa,CAAC;AACrB,QAAA,aAAa,EAAE,KAAK;AACpB,QAAA,WAAW,EAAE,KAAK;AAClB,QAAA,MAAM,EAAE,KAAK;AAChB,KAAA,CAAC;AACN;;;;"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { MIME_MAP } from '../server/const/MIME_MAP.js';
|
|
2
|
+
import { __cfg__ } from '../config.js';
|
|
3
|
+
|
|
4
|
+
/***************************************************************************
|
|
5
|
+
* XyPriss - Fast And Secure
|
|
6
|
+
*
|
|
7
|
+
* @author Nehonix
|
|
8
|
+
* @license Nehonix OSL (NOSL)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2025 Nehonix. All rights reserved.
|
|
11
|
+
****************************************************************************/
|
|
12
|
+
/**
|
|
13
|
+
* Resolves a single MIME type from a file extension.
|
|
14
|
+
*
|
|
15
|
+
* @param ext - The file extension (e.g., '.png' or 'jpg').
|
|
16
|
+
* @returns The corresponding MIME type or 'application/octet-stream' if unknown.
|
|
17
|
+
*/
|
|
18
|
+
const getMime = (ext) => {
|
|
19
|
+
if (!ext)
|
|
20
|
+
return "application/octet-stream";
|
|
21
|
+
const normalized = ext.startsWith(".")
|
|
22
|
+
? ext.toLowerCase()
|
|
23
|
+
: `.${ext.toLowerCase()}`;
|
|
24
|
+
return MIME_MAP[normalized] || "application/octet-stream";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Advanced utility to resolve multiple MIME types from file extensions.
|
|
28
|
+
*
|
|
29
|
+
* This helper is designed to simplify server configurations, particularly for
|
|
30
|
+
* 'fileUpload' and security policies, by allowing developers to specify
|
|
31
|
+
* human-readable extensions instead of complex MIME strings.
|
|
32
|
+
*
|
|
33
|
+
* FEATURES:
|
|
34
|
+
* - Supports single extensions or arrays.
|
|
35
|
+
* - Automatically normalizes extensions (handles missing dots).
|
|
36
|
+
* - Deduplicates results to ensure a clean MIME array.
|
|
37
|
+
* - Can fall back to global 'fileUpload.allowedExtensions' if no argument is provided.
|
|
38
|
+
*
|
|
39
|
+
* @param extensions - A single extension (e.g., '.png') or an array (e.g., ['.jpg', '.pdf']).
|
|
40
|
+
* If omitted, the function attempts to read from global configuration.
|
|
41
|
+
* @returns A unique array of resolved MIME types.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // 1. Map an array of extensions for file upload configuration
|
|
45
|
+
* const uploadConfig = {
|
|
46
|
+
* allowedMimeTypes: getMimes(['.png', '.jpg', '.jpeg', '.webp'])
|
|
47
|
+
* };
|
|
48
|
+
* // Result: ['image/png', 'image/jpeg', 'image/webp']
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // 2. Map a single extension
|
|
52
|
+
* const mimes = getMimes('.pdf');
|
|
53
|
+
* // Result: ['application/pdf']
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // 3. Automatic detection from xypriss.config.json
|
|
57
|
+
* // If config has: { "fileUpload": { "allowedExtensions": [".zip", ".rar"] } }
|
|
58
|
+
* const mimes = getMimes();
|
|
59
|
+
* // Result: ['application/zip', 'application/vnd.rar']
|
|
60
|
+
*/
|
|
61
|
+
const getMimes = (extensions) => {
|
|
62
|
+
let targetExts = [];
|
|
63
|
+
if (extensions) {
|
|
64
|
+
targetExts = Array.isArray(extensions) ? extensions : [extensions];
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Fallback to global framework configuration if available
|
|
68
|
+
try {
|
|
69
|
+
const uMimeConfig = __cfg__.get("fileUpload")?.allowedExtensions;
|
|
70
|
+
if (Array.isArray(uMimeConfig)) {
|
|
71
|
+
targetExts = uMimeConfig;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
// Config might not be initialized yet in early-loading contexts
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (targetExts.length === 0)
|
|
80
|
+
return [];
|
|
81
|
+
const mimeSet = new Set();
|
|
82
|
+
for (const ext of targetExts) {
|
|
83
|
+
if (!ext)
|
|
84
|
+
continue;
|
|
85
|
+
const mime = getMime(ext);
|
|
86
|
+
if (mime)
|
|
87
|
+
mimeSet.add(mime);
|
|
88
|
+
}
|
|
89
|
+
return Array.from(mimeSet);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export { getMime, getMimes };
|
|
93
|
+
//# sourceMappingURL=getMime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMime.js","sources":["../../../../src/utils/getMime.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;;;AAO8E;AAK9E;;;;;AAKG;AACI,MAAM,OAAO,GAAG,CAAC,GAAW,KAAY;AAC3C,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,OAAO,0BAA0B;AAC3C,IAAA,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG;AACjC,UAAE,GAAG,CAAC,WAAW;AACjB,UAAE,CAAA,CAAA,EAAI,GAAG,CAAC,WAAW,EAAE,EAAE;AAC7B,IAAA,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,0BAA0B;AAC7D;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCG;AACI,MAAM,QAAQ,GAAG,CAAC,UAA8B,KAAc;IACjE,IAAI,UAAU,GAAa,EAAE;IAE7B,IAAI,UAAU,EAAE;AACZ,QAAA,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,UAAU,CAAC;IACtE;SAAO;;AAEH,QAAA,IAAI;YACA,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,iBAAiB;AAChE,YAAA,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;gBAC5B,UAAU,GAAG,WAAW;YAC5B;QACJ;QAAE,OAAO,CAAC,EAAE;;AAER,YAAA,OAAO,EAAE;QACb;IACJ;AAEA,IAAA,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,EAAE;AAEtC,IAAA,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU;AACjC,IAAA,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;AAC1B,QAAA,IAAI,CAAC,GAAG;YAAE;AACV,QAAA,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;AACzB,QAAA,IAAI,IAAI;AAAE,YAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;IAC/B;AAEA,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;AAC9B;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9088,6 +9088,58 @@ type IpSource = "cf-connecting-ip" | "true-client-ip" | "x-real-ip" | "x-forward
|
|
|
9088
9088
|
declare function getIp(req: XyPrisRequest): string;
|
|
9089
9089
|
declare function getIp(req: XyPrisRequest, enriched: true): GetIpResult;
|
|
9090
9090
|
|
|
9091
|
+
/***************************************************************************
|
|
9092
|
+
* XyPriss - Fast And Secure
|
|
9093
|
+
*
|
|
9094
|
+
* @author Nehonix
|
|
9095
|
+
* @license Nehonix OSL (NOSL)
|
|
9096
|
+
*
|
|
9097
|
+
* Copyright (c) 2025 Nehonix. All rights reserved.
|
|
9098
|
+
****************************************************************************/
|
|
9099
|
+
/**
|
|
9100
|
+
* Resolves a single MIME type from a file extension.
|
|
9101
|
+
*
|
|
9102
|
+
* @param ext - The file extension (e.g., '.png' or 'jpg').
|
|
9103
|
+
* @returns The corresponding MIME type or 'application/octet-stream' if unknown.
|
|
9104
|
+
*/
|
|
9105
|
+
declare const getMime: (ext: string) => string;
|
|
9106
|
+
/**
|
|
9107
|
+
* Advanced utility to resolve multiple MIME types from file extensions.
|
|
9108
|
+
*
|
|
9109
|
+
* This helper is designed to simplify server configurations, particularly for
|
|
9110
|
+
* 'fileUpload' and security policies, by allowing developers to specify
|
|
9111
|
+
* human-readable extensions instead of complex MIME strings.
|
|
9112
|
+
*
|
|
9113
|
+
* FEATURES:
|
|
9114
|
+
* - Supports single extensions or arrays.
|
|
9115
|
+
* - Automatically normalizes extensions (handles missing dots).
|
|
9116
|
+
* - Deduplicates results to ensure a clean MIME array.
|
|
9117
|
+
* - Can fall back to global 'fileUpload.allowedExtensions' if no argument is provided.
|
|
9118
|
+
*
|
|
9119
|
+
* @param extensions - A single extension (e.g., '.png') or an array (e.g., ['.jpg', '.pdf']).
|
|
9120
|
+
* If omitted, the function attempts to read from global configuration.
|
|
9121
|
+
* @returns A unique array of resolved MIME types.
|
|
9122
|
+
*
|
|
9123
|
+
* @example
|
|
9124
|
+
* // 1. Map an array of extensions for file upload configuration
|
|
9125
|
+
* const uploadConfig = {
|
|
9126
|
+
* allowedMimeTypes: getMimes(['.png', '.jpg', '.jpeg', '.webp'])
|
|
9127
|
+
* };
|
|
9128
|
+
* // Result: ['image/png', 'image/jpeg', 'image/webp']
|
|
9129
|
+
*
|
|
9130
|
+
* @example
|
|
9131
|
+
* // 2. Map a single extension
|
|
9132
|
+
* const mimes = getMimes('.pdf');
|
|
9133
|
+
* // Result: ['application/pdf']
|
|
9134
|
+
*
|
|
9135
|
+
* @example
|
|
9136
|
+
* // 3. Automatic detection from xypriss.config.json
|
|
9137
|
+
* // If config has: { "fileUpload": { "allowedExtensions": [".zip", ".rar"] } }
|
|
9138
|
+
* const mimes = getMimes();
|
|
9139
|
+
* // Result: ['application/zip', 'application/vnd.rar']
|
|
9140
|
+
*/
|
|
9141
|
+
declare const getMimes: (extensions?: string | string[]) => string[];
|
|
9142
|
+
|
|
9091
9143
|
/***************************************************************************
|
|
9092
9144
|
* XyPrissJS - Fast And Secure
|
|
9093
9145
|
*
|
|
@@ -9169,5 +9221,5 @@ declare global {
|
|
|
9169
9221
|
*/
|
|
9170
9222
|
declare function Router(): XyPrissRouter;
|
|
9171
9223
|
|
|
9172
|
-
export { ConfigurationManager as CM, ConfigurationManager as Configs, FileUploadAPI as FLA, FileUploadAPI, PerformanceMonitor, Plugin, PluginHookIds, Router, SecurityMiddleware, TrustProxy, Upload, XJsonResponseHandler, MultiServerApp as XyPMS, XyPrissRouter, XyPrissSys, __cfg__, __const__, __sys__, createCircularRefDebugger, createOptimalCache, createSafeJsonMiddleware, createServer, getIp, initializeFileUpload, mergeWithDefaults, mergeWithDefaults as mwdef, quickServer, safeJsonStringify, sendSafeJson, setupSafeJson, uploadAny, uploadArray, uploadFields, uploadSingle, xems };
|
|
9224
|
+
export { ConfigurationManager as CM, ConfigurationManager as Configs, FileUploadAPI as FLA, FileUploadAPI, PerformanceMonitor, Plugin, PluginHookIds, Router, SecurityMiddleware, TrustProxy, Upload, XJsonResponseHandler, MultiServerApp as XyPMS, XyPrissRouter, XyPrissSys, __cfg__, __const__, __sys__, createCircularRefDebugger, createOptimalCache, createSafeJsonMiddleware, createServer, getIp, getMime, getMimes, initializeFileUpload, mergeWithDefaults, mergeWithDefaults as mwdef, quickServer, safeJsonStringify, sendSafeJson, setupSafeJson, uploadAny, uploadArray, uploadFields, uploadSingle, xems };
|
|
9173
9225
|
export type { ArchiveOptions, BatchRenameChange, CacheConfig, FileUploadConfig as FiUpConfig, FileUploadConfig, GetIpResult, IpSource, MonitorSnapshot, MultiServerConfig, NetworkStats, NextFunction, PerformanceConfig, PluginCreator, ProcessInfo, ProcessMonitorSnapshot, XyPrisRequest as Request, RequestHandler, XyPrisResponse as Response, RouteConfig, RouteOptions, SecurityConfig, ServerOptions$1 as ServerOptions, TrustProxyValue$1 as TrustProxyValue, UltraFastApp, XemsTypes, XyPrisRequest, XyPrisResponse, XyPrissPlugin, XyPrisRequest as XyPrissRequest, XyPrisResponse as XyPrissResponse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xypriss",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.53",
|
|
4
4
|
"description": "XyPriss is a lightweight, TypeScript-first, open-source Node.js web framework crafted for developers seeking a familiar Express-like API without Express dependencies.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Nehonix",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"require": "./dist/cjs/src/index.js",
|
|
17
17
|
"types": "./dist/index.d.ts"
|
|
18
18
|
}
|
|
19
|
-
},
|
|
19
|
+
},
|
|
20
20
|
"files": [
|
|
21
21
|
"dist/",
|
|
22
22
|
"shared/",
|