@maioradv/nestjs-core 1.1.3 → 1.1.4
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/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const DEFAULT_MAX_IMAGE_SIZE = 2;
|
|
2
|
+
export declare const DEFAULT_MIMETYPES_SUPPORT = ".(webp|avif|png|gif|jpeg|jpg)";
|
|
3
|
+
export type ImagePipeValidatorOptions = {
|
|
4
|
+
maxSize?: number;
|
|
5
|
+
mimeTypes?: ('webp' | 'avif' | 'png' | 'gif' | 'jpeg' | 'jpg')[];
|
|
6
|
+
};
|
|
7
|
+
export declare const ImagePipeValidator: (options?: ImagePipeValidatorOptions) => import("@nestjs/common").ParseFilePipe;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImagePipeValidator = exports.DEFAULT_MIMETYPES_SUPPORT = exports.DEFAULT_MAX_IMAGE_SIZE = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.DEFAULT_MAX_IMAGE_SIZE = 2;
|
|
6
|
+
exports.DEFAULT_MIMETYPES_SUPPORT = '.(webp|avif|png|gif|jpeg|jpg)';
|
|
7
|
+
const ImagePipeValidator = (options) => new common_1.ParseFilePipeBuilder()
|
|
8
|
+
.addFileTypeValidator({ fileType: options?.mimeTypes ? `.(${options.mimeTypes.join('|')})` : exports.DEFAULT_MIMETYPES_SUPPORT })
|
|
9
|
+
.addMaxSizeValidator({ maxSize: (options?.maxSize ?? exports.DEFAULT_MAX_IMAGE_SIZE) * 8e6 })
|
|
10
|
+
.build({ errorHttpStatusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY });
|
|
11
|
+
exports.ImagePipeValidator = ImagePipeValidator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './image-pipe.validator';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./image-pipe.validator"), exports);
|