Skip to content

Commit b983acc

Browse files
committed
Fix package version lock
1 parent db85f66 commit b983acc

12 files changed

+186
-110
lines changed

.eslintrc.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

eslint.config.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const eslint = require('@eslint/js');
2+
const tseslint = require('@typescript-eslint/eslint-plugin');
3+
const tseslintParser = require('@typescript-eslint/parser');
4+
const prettier = require('eslint-plugin-prettier');
5+
const prettierConfig = require('eslint-config-prettier');
6+
7+
module.exports = [
8+
eslint.configs.recommended,
9+
{
10+
files: ['**/*.ts'],
11+
languageOptions: {
12+
parser: tseslintParser,
13+
parserOptions: {
14+
project: './tsconfig.json',
15+
sourceType: 'module',
16+
},
17+
},
18+
plugins: {
19+
'@typescript-eslint': tseslint,
20+
prettier: prettier,
21+
},
22+
rules: {
23+
...tseslint.configs.recommended.rules,
24+
...prettierConfig.rules,
25+
'@typescript-eslint/interface-name-prefix': 'off',
26+
'@typescript-eslint/explicit-function-return-type': 'warn',
27+
'@typescript-eslint/explicit-module-boundary-types': 'warn',
28+
'@typescript-eslint/no-explicit-any': 'warn',
29+
},
30+
},
31+
{
32+
ignores: ['dist/**', 'node_modules/**', 'eslint.config.js'],
33+
},
34+
];

package-lock.json

Lines changed: 122 additions & 78 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
},
7272
"devDependencies": {
7373
"@types/jest": "^29.5.14",
74-
"@types/minio": "^7.1.1",
7574
"@types/node": "^22.14.0",
7675
"@typescript-eslint/eslint-plugin": "^8.27.0",
7776
"@typescript-eslint/parser": "^8.27.0",

src/decorators/file-field.decorator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface FileFieldOptions {
88
description?: string;
99
}
1010

11-
export function FileField(options: FileFieldOptions) {
11+
export function FileField(options: FileFieldOptions): PropertyDecorator {
1212
const { bucketName, required = false, description = 'File upload field' } = options;
1313

1414
// Store metadata on the property

src/decorators/file-schema-field.decorator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type FileSchemaFieldOptions = PropOptions & {
44
bucketName?: string;
55
};
66

7-
export function FileSchemaField(options: FileSchemaFieldOptions = {}) {
7+
export function FileSchemaField(options: FileSchemaFieldOptions = {}): PropertyDecorator {
88
// Add a metadata marker to identify this as a file field
99
const fileOptions = {
1010
...(options as object),

src/decorators/file-upload.decorator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ApiConsumes } from '@nestjs/swagger';
44
import { FileFieldConfig } from 'src/interfaces/file-field.interface';
55
import { MinioFileInterceptor } from '../interceptors/file.interceptor';
66

7-
export function FileUpload(fileFields: FileFieldConfig[]) {
7+
export function FileUpload(fileFields: FileFieldConfig[]): PropertyDecorator {
88
// Store configurations in a custom property for later use
99
const multerFields = fileFields.map((field) => ({
1010
name: field.name,
@@ -15,7 +15,7 @@ export function FileUpload(fileFields: FileFieldConfig[]) {
1515
// Create decorator that applies both interceptors and stores metadata
1616
return applyDecorators(
1717
// Set metadata on the method
18-
(target: any, key: string, descriptor: PropertyDescriptor) => {
18+
(target: object, key: string, descriptor: PropertyDescriptor) => {
1919
// Store the file field configurations directly on the method
2020
Reflect.defineMetadata('fileField', fileFields, descriptor.value);
2121
return descriptor;

src/interceptors/file-url-transform.interceptor.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
1+
import { Injectable, NestInterceptor, ExecutionContext, CallHandler, Logger } from '@nestjs/common';
22
import { Observable } from 'rxjs';
33
import { map } from 'rxjs/operators';
44
import { MinioService } from '../minio.service';
@@ -7,8 +7,11 @@ import { IncomingMessage, ServerResponse } from 'http';
77

88
@Injectable()
99
export class FileUrlTransformInterceptor implements NestInterceptor {
10+
private readonly logger = new Logger(FileUrlTransformInterceptor.name);
11+
1012
constructor(private readonly minioService: MinioService) {}
1113

14+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1215
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
1316
return next.handle().pipe(
1417
map(async (data) => {
@@ -25,6 +28,12 @@ export class FileUrlTransformInterceptor implements NestInterceptor {
2528
);
2629
}
2730

31+
/**
32+
* Transforms URLs in the given data to presigned URLs using the Minio service.
33+
* @param data - The data to transform.
34+
* @returns The transformed data with URLs replaced by presigned URLs.
35+
*/
36+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2837
private async transformUrls(data: any): Promise<any> {
2938
if (!data) return data;
3039

@@ -60,7 +69,7 @@ export class FileUrlTransformInterceptor implements NestInterceptor {
6069
try {
6170
obj[key] = await this.minioService.getPresignedUrl(bucketName, pathParts.join('/'));
6271
} catch (error) {
63-
console.error(`Error generating presigned URL for ${key}:`, error);
72+
this.logger.error(`Error generating presigned URL for ${key}:`, error);
6473
}
6574
}
6675
}

src/interceptors/file.interceptor.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ import {
44
Injectable,
55
NestInterceptor,
66
BadRequestException,
7+
Logger,
78
} from '@nestjs/common';
89
import { Observable } from 'rxjs';
910
import { MinioService } from '../minio.service';
1011
import { map } from 'rxjs/operators';
1112

1213
@Injectable()
1314
export class MinioFileInterceptor implements NestInterceptor {
15+
private readonly logger = new Logger(MinioFileInterceptor.name);
16+
1417
constructor(private readonly minioService: MinioService) {}
1518

19+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1620
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
1721
const request = context.switchToHttp().getRequest();
1822
const files = request.files || {};
@@ -90,6 +94,7 @@ export class MinioFileInterceptor implements NestInterceptor {
9094
});
9195
}
9296

97+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9398
private async transformUrls(data: any): Promise<any> {
9499
if (!data) return data;
95100

@@ -104,7 +109,7 @@ export class MinioFileInterceptor implements NestInterceptor {
104109
try {
105110
obj[key] = await this.minioService.getPresignedUrl(bucketName, pathParts.join('/'));
106111
} catch (error) {
107-
console.error(`Error generating presigned URL for ${key}:`, error);
112+
this.logger.error(`Error generating presigned URL for ${key}:`, error);
108113
}
109114
}
110115
}
@@ -113,7 +118,8 @@ export class MinioFileInterceptor implements NestInterceptor {
113118
return obj;
114119
}
115120

116-
private validateFile(file: any, config: any) {
121+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
122+
private validateFile(file: any, config: any): void {
117123
// Get validation metadata from both decorators
118124
const validationConfig = {
119125
allowedMimeTypes: config.allowedMimeTypes || [],

src/interfaces/file.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Buffer } from 'buffer';
2+
13
export interface IFileUpload {
24
fieldname: string;
35
originalname: string;

0 commit comments

Comments
 (0)