chore(workspace): eradicate all tsc errors and eslint warnings across frontend, admin, and backend
Deploy Canina / deploy (push) Failing after 29s
Deploy Canina / deploy (push) Failing after 29s
This commit is contained in:
1 parent
4659a7b1de
commit
9f11d8fb2d
98 files changed
+1272
-1009
No files matched your search
@@ -7,6 +7,12 @@ import {
|
||||
import { Reflector } from '@nestjs/core';
|
||||
import { ROLES_KEY } from '../decorators/roles.decorator';
|
||||
|
||||
interface RequestWithUser {
|
||||
user?: {
|
||||
role?: string;
|
||||
};
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class RolesGuard implements CanActivate {
|
||||
constructor(private reflector: Reflector) {}
|
||||
@@ -21,7 +27,8 @@ export class RolesGuard implements CanActivate {
|
||||
return true;
|
||||
}
|
||||
|
||||
const { user } = context.switchToHttp().getRequest();
|
||||
const request = context.switchToHttp().getRequest<RequestWithUser>();
|
||||
const user = request.user;
|
||||
if (!user || !user.role) {
|
||||
throw new ForbiddenException('شما دسترسی لازم برای این بخش را ندارید');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { DecimalInterceptor } from './decimal.interceptor';
|
||||
import { ExecutionContext, CallHandler } from '@nestjs/common';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
@@ -25,8 +26,8 @@ describe('DecimalInterceptor', () => {
|
||||
],
|
||||
};
|
||||
|
||||
const executionContext: any = {};
|
||||
const callHandler: any = {
|
||||
const executionContext = {} as ExecutionContext;
|
||||
const callHandler: CallHandler = {
|
||||
handle: () => of(mockData),
|
||||
};
|
||||
|
||||
@@ -53,11 +54,12 @@ describe('DecimalInterceptor', () => {
|
||||
createdAt: new Date('2026-01-01T00:00:00.000Z'),
|
||||
};
|
||||
|
||||
const callHandler: any = {
|
||||
const executionContext = {} as ExecutionContext;
|
||||
const callHandler: CallHandler = {
|
||||
handle: () => of(mockData),
|
||||
};
|
||||
|
||||
interceptor.intercept({} as any, callHandler).subscribe((result) => {
|
||||
interceptor.intercept(executionContext, callHandler).subscribe((result) => {
|
||||
expect(result).toEqual(mockData);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -10,11 +10,11 @@ import { Prisma } from '@prisma/client';
|
||||
|
||||
@Injectable()
|
||||
export class DecimalInterceptor implements NestInterceptor {
|
||||
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
|
||||
return next.handle().pipe(map((data) => this.transform(data)));
|
||||
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {
|
||||
return next.handle().pipe(map((data: unknown) => this.transform(data)));
|
||||
}
|
||||
|
||||
private transform(data: any): any {
|
||||
private transform(data: unknown): unknown {
|
||||
if (data === null || data === undefined) {
|
||||
return data;
|
||||
}
|
||||
@@ -24,13 +24,14 @@ export class DecimalInterceptor implements NestInterceptor {
|
||||
}
|
||||
|
||||
if (Array.isArray(data)) {
|
||||
return data.map((item) => this.transform(item));
|
||||
return data.map((item: unknown) => this.transform(item));
|
||||
}
|
||||
|
||||
if (typeof data === 'object' && !(data instanceof Date)) {
|
||||
const transformedObj: Record<string, any> = {};
|
||||
for (const key of Object.keys(data)) {
|
||||
transformedObj[key] = this.transform(data[key]);
|
||||
const obj = data as Record<string, unknown>;
|
||||
const transformedObj: Record<string, unknown> = {};
|
||||
for (const key of Object.keys(obj)) {
|
||||
transformedObj[key] = this.transform(obj[key]);
|
||||
}
|
||||
return transformedObj;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export class MetricsController {
|
||||
let dbStatus = 1;
|
||||
try {
|
||||
await this.prisma.$queryRaw`SELECT 1`;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
dbStatus = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ export class PaginatedResponse<T> {
|
||||
meta: PaginationMeta;
|
||||
}
|
||||
|
||||
export function createPaginatedSchema(dtoModel: any) {
|
||||
export function createPaginatedSchema(dtoModel: { name: string }) {
|
||||
return {
|
||||
schema: {
|
||||
allOf: [
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import * as http from 'http';
|
||||
import * as https from 'https';
|
||||
|
||||
export interface SendPatternSmsOptions {
|
||||
@@ -8,6 +7,11 @@ export interface SendPatternSmsOptions {
|
||||
args: string[]; // Dynamic variables inside pattern
|
||||
}
|
||||
|
||||
interface MeliPayamakResponse {
|
||||
Value?: number;
|
||||
RetStatus?: number;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SmsService {
|
||||
private readonly logger = new Logger(SmsService.name);
|
||||
@@ -48,15 +52,16 @@ export class SmsService {
|
||||
res.on('data', (chunk) => (data += chunk));
|
||||
res.on('end', () => {
|
||||
try {
|
||||
const json = JSON.parse(data);
|
||||
if (json && (json.Value > 15 || json.RetStatus === 1)) {
|
||||
const json = JSON.parse(data) as MeliPayamakResponse;
|
||||
const val = json.Value ?? 0;
|
||||
if (json && (val > 15 || json.RetStatus === 1)) {
|
||||
this.logger.log(
|
||||
`[SMS Sent] Pattern SMS ${options.bodyId} dispatched to ${options.to} (RecId: ${json.Value})`,
|
||||
`[SMS Sent] Pattern SMS ${options.bodyId} dispatched to ${options.to} (RecId: ${val})`,
|
||||
);
|
||||
resolve(true);
|
||||
} else {
|
||||
this.logger.error(
|
||||
`[SMS Error] Failed sending pattern SMS to ${options.to}. Code: ${json?.Value}`,
|
||||
`[SMS Error] Failed sending pattern SMS to ${options.to}. Code: ${val}`,
|
||||
);
|
||||
resolve(false);
|
||||
}
|
||||
@@ -174,6 +179,6 @@ export class SmsService {
|
||||
*/
|
||||
async sendSms(phone: string, message: string): Promise<boolean> {
|
||||
this.logger.log(`[SMS Text Sent] To: ${phone}, Content: ${message}`);
|
||||
return true;
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user