Skip to content

Commit

Permalink
chore: drop qualifiable any
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-lebleu committed Jan 18, 2025
1 parent 8c1ba69 commit e9bf203
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/api/config/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import * as Cors from 'cors';
import * as Compression from 'compression';
import { rateLimit as RateLimit } from 'express-rate-limit';
import * as Helmet from 'helmet';
import { Handler as MorganHandler } from 'morgan';

import { notAcceptable } from '@hapi/boom';

import { ENVIRONMENT } from '@enums/environment.enum';

import { API_VERSION, AUTHORIZED, CONTENT_TYPE, DOMAIN, ENV, UPLOAD } from '@config/environment.config';
import { API_VERSION, AUTHORIZED, DOMAIN, ENV } from '@config/environment.config';

import { Authentication } from '@config/authentication.config';
import { LoggerConfiguration } from '@config/logger.config';
Expand Down Expand Up @@ -173,7 +174,7 @@ export class ExpressConfiguration {
* @see https://github.com/winstonjs/winston
* @see https://github.com/expressjs/morgan
*/
this.application.use( LoggerConfiguration.writeStream() as any );
this.application.use( LoggerConfiguration.writeStream() as MorganHandler );

/**
* Lifecyle of a classic request
Expand Down
6 changes: 3 additions & 3 deletions src/api/config/upload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class UploadConfiguration {
limits: {
fileSize: options.filesize
},
fileFilter: (req: Request, file: IMedia, next: (e?: Error, v?: any) => void) => {
fileFilter: (req: Request, file: IMedia, next: (e?: Error, v?: boolean) => void) => {
if(options.wildcards.filter( mime => file.mimetype === mime ).length === 0) {
return next( unsupportedMediaType('File mimetype not supported'), false );
}
Expand All @@ -73,7 +73,7 @@ class UploadConfiguration {
private storage(destination?: string): IStorage {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return Multer.diskStorage({
destination: (req: Request, file: IMedia, next: (e?: Error, v?: any) => void) => {
destination: (req: Request, file: IMedia, next: (e?: Error, v?: string) => void) => {
let towards = `${destination}/${getTypeOfMedia(file.mimetype)}s`;
if (IMAGE_MIME_TYPE[file.mimetype]) {
towards += `/${SCALING.PATH_MASTER}`;
Expand All @@ -84,7 +84,7 @@ class UploadConfiguration {
}
next(null, towards);
},
filename: (req: Request, file: IMedia, next: (e?: Error, v?: any) => void) => {
filename: (req: Request, file: IMedia, next: (e?: Error, v?: string) => void) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const name = filenamify( foldername(file.originalname), { replacement: '-', maxLength: 128 } )
.replace(' ', '-')
Expand Down
4 changes: 2 additions & 2 deletions src/api/core/services/cache.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CacheService {
/**
* @description
*/
get engine(): ICache {
get engine(): ICache {
return CacheConfiguration.start
}

Expand All @@ -34,7 +34,7 @@ class CacheService {
/**
* @description
*/
get isActive(): boolean {
get isActive(): boolean {
return CacheConfiguration.options.IS_ACTIVE;
}

Expand Down
8 changes: 6 additions & 2 deletions src/api/core/services/sanitizer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import * as Pluralize from 'pluralize';
import { IModel } from '@interfaces';
import { isObject } from '@utils/object.util';

type SanitizableData = Record<string, unknown> | unknown[] | string | number | boolean;

class SanitizeService {

/**
Expand All @@ -27,7 +29,7 @@ class SanitizeService {
*
* @param data
*/
hasEligibleMember(data: { [key: string]: any }): boolean {
hasEligibleMember(data: { [key: string]: SanitizableData }): boolean {
return ( this.implementsWhitelist(data) && !Array.isArray(data) ) || ( Array.isArray(data) && [].concat(data).some(obj => this.implementsWhitelist(obj) ) || ( isObject(data) && Object.keys(data).some(key => this.implementsWhitelist(data[key]) ) ) )
}

Expand All @@ -39,7 +41,9 @@ class SanitizeService {
process(data: { [key: string]: any }) {

if ( Array.isArray(data) ) {
return [].concat(data).map( (d: any ) => this.implementsWhitelist(d) ? this.sanitize(d as IModel) : d as Record<string,unknown>);
return []
.concat(data)
.map( (d: any ) => this.implementsWhitelist(d) ? this.sanitize(d as IModel) : d as Record<string,unknown>);
}

if ( this.implementsWhitelist(data) ) {
Expand Down

0 comments on commit e9bf203

Please sign in to comment.