@maioradv/nestjs-core 1.5.8 → 1.6.0
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 +1 -0
- package/dist/index.js +1 -0
- package/dist/middlewares/client-ip.middleware.d.ts +1 -0
- package/dist/middlewares/client-ip.middleware.js +8 -0
- package/dist/middlewares/index.d.ts +1 -0
- package/dist/middlewares/index.js +17 -0
- package/dist/pipes/image-compression.pipe.d.ts +2 -0
- package/dist/pipes/image-compression.pipe.js +10 -4
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ClientIp: () => (req: import("request-ip").Request, res: any, next: any) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './client-ip.middleware';
|
|
@@ -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("./client-ip.middleware"), exports);
|
|
@@ -5,5 +5,7 @@ export type CompressionOptions = {
|
|
|
5
5
|
quality?: number;
|
|
6
6
|
};
|
|
7
7
|
export declare class ImageCompressionPipe implements PipeTransform<Express.Multer.File, Promise<Express.Multer.File>> {
|
|
8
|
+
private readonly options;
|
|
9
|
+
constructor(options?: CompressionOptions);
|
|
8
10
|
transform(file: Express.Multer.File, metadata: ArgumentMetadata): Promise<Express.Multer.File>;
|
|
9
11
|
}
|
|
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
8
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
13
|
};
|
|
@@ -14,12 +17,14 @@ const common_1 = require("@nestjs/common");
|
|
|
14
17
|
const path_1 = require("path");
|
|
15
18
|
const sharp_1 = __importDefault(require("sharp"));
|
|
16
19
|
let ImageCompressionPipe = class ImageCompressionPipe {
|
|
17
|
-
|
|
20
|
+
constructor(options = {}) {
|
|
21
|
+
this.options = options;
|
|
22
|
+
}
|
|
18
23
|
async transform(file, metadata) {
|
|
19
24
|
try {
|
|
20
25
|
const [resolutionCap, quality] = [
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
this.options.resolutionCap ?? 2560,
|
|
27
|
+
this.options.quality ?? 70
|
|
23
28
|
];
|
|
24
29
|
const compressedBuffer = await (0, sharp_1.default)(file.buffer, { failOn: 'error' })
|
|
25
30
|
.resize({
|
|
@@ -45,5 +50,6 @@ let ImageCompressionPipe = class ImageCompressionPipe {
|
|
|
45
50
|
};
|
|
46
51
|
exports.ImageCompressionPipe = ImageCompressionPipe;
|
|
47
52
|
exports.ImageCompressionPipe = ImageCompressionPipe = __decorate([
|
|
48
|
-
(0, common_1.Injectable)()
|
|
53
|
+
(0, common_1.Injectable)(),
|
|
54
|
+
__metadata("design:paramtypes", [Object])
|
|
49
55
|
], ImageCompressionPipe);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maioradv/nestjs-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "NestJS helpers by MaiorADV",
|
|
5
5
|
"repository": "https://github.com/maioradv/nestjs-core.git",
|
|
6
6
|
"author": "Maior ADV Srl",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"image-size": "^1.1.1",
|
|
32
32
|
"nest-winston": "^1.10.0",
|
|
33
33
|
"nodemailer": "^6.9.14",
|
|
34
|
+
"request-ip": "^3.3.0",
|
|
34
35
|
"sharp": "^0.33.5",
|
|
35
36
|
"winston": "^3.13.0",
|
|
36
37
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
"@types/multer": "^1.4.11",
|
|
40
41
|
"@types/node": "^20.12.13",
|
|
41
42
|
"@types/nodemailer": "^6.4.15",
|
|
43
|
+
"@types/request-ip": "^0.0.41",
|
|
42
44
|
"ts-node": "^10.9.2",
|
|
43
45
|
"typescript": "^5.4.5"
|
|
44
46
|
},
|