first commit v3 initialiazed a temporary repository for darmanet client

This commit is contained in:
2026-09-08 16:04:01 +03:30
commit 5c7fd95052
216 changed files with 30050 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
import { HttpStatus } from '@nestjs/common';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsInt, IsOptional, Min } from 'class-validator';
export class PageOptionsDto {
@ApiPropertyOptional({
minimum: 1,
default: 1,
})
@Type(() => Number)
@IsInt()
@Min(1)
@IsOptional()
readonly page?: number = 1;
@ApiPropertyOptional({
minimum: 1,
// maximum: 50,
default: 10,
})
@Type(() => Number)
@IsInt()
@Min(1)
// @Max(50)
@IsOptional()
readonly take?: number = 10;
get skip(): number {
return (this.page - 1) * this.take;
}
}
export interface PageMetaDtoParameters {
pageOptionsDto: PageOptionsDto;
itemCount: number;
}
export class PageMetaDto {
@ApiProperty()
readonly page: number;
@ApiProperty()
readonly take: number;
@ApiProperty()
readonly itemCount: number;
@ApiProperty()
readonly pageCount: number;
constructor({ pageOptionsDto, itemCount }: PageMetaDtoParameters) {
this.page = pageOptionsDto.page;
this.take = pageOptionsDto.take;
this.itemCount = itemCount;
this.pageCount = Math.ceil(this.itemCount / this.take);
}
}
export class BaseResponseDTO {
statusCode: HttpStatus;
message: string;
data: any;
@ApiProperty({ type: () => PageMetaDto })
readonly meta: PageMetaDto;
constructor(statusCode: HttpStatus, message, data: any, meta?: PageMetaDto) {
this.statusCode = statusCode;
this.message = message;
this.data = data;
this.meta = meta;
}
mapDataIfArray<T>(mapper: (item: any) => T): T[] {
if (Array.isArray(this.data)) {
return this.data.map(mapper);
}
return { ...this.data };
}
}

View File

@@ -0,0 +1,8 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsEmail } from 'class-validator';
export class ForgetPasswordDTO {
@IsEmail()
@ApiProperty()
username: string;
}

View File

@@ -0,0 +1,70 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, ValidateIf } from 'class-validator';
export class UserLoginDTO {
@ApiProperty({
required: true,
type: 'string',
description: 'mobile of user',
example: '09226187419',
})
mobile: string;
@ApiProperty({
required: false,
type: 'string',
description: 'nationalCode of user',
example: '4311402422',
})
@ValidateIf((o) => o.twoFactor === true)
nationalCode: string | null;
@ApiProperty({
required: true,
type: 'string',
default: false,
description:
'if true , both nationalCode and mobile and if false , just mobile should be sent.',
example: false,
})
twoFactor: boolean;
}
export class UserVerifyOtpDTO {
@ApiProperty({
required: true,
type: 'string',
description: 'mobile of user',
example: '09226187419',
})
mobile: string;
@ApiProperty({
required: true,
type: 'string',
description: 'otp send to the mobile of user',
example: '27246',
})
otp: string;
}
export class AdminLoginDTO {
@ApiProperty({
required: true,
type: 'string',
description: 'username of admin',
example: 'admin@chatbot.com',
})
@IsEmail()
username: string;
@ApiProperty({
required: true,
type: 'string',
description: 'password of admin',
example: 'p@$$word123321',
})
password: string;
// @ApiProperty({ examples: Role, required: true, enum: Role })
// role: Role;
}

View File

@@ -0,0 +1,12 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsStrongPassword } from 'class-validator';
export class ResetPasswordDTO {
@ApiProperty()
@IsString()
resetToken: string;
@ApiProperty()
@IsStrongPassword()
newPassword: string;
}