Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Exclude, Expose } from 'class-transformer';
import { IsOptional, IsString, MinLength } from 'class-validator';
@Exclude()
export class WorldCountryName {
@IsString()
@IsOptional()
@MinLength(1)
@Expose()
common: string;
@IsString()
@IsOptional()
@MinLength(1)
@Expose()
official: string;
}
import { Exclude, Expose, Transform } from 'class-transformer';
import { IsBoolean, IsIn, IsNumber, IsOptional, IsString, IsUrl, Matches } from 'class-validator';
import { trim } from 'lodash';
import { v1 as uuidv1 } from 'uuid';
export const NODE_ENVIRONMENT_OPTIONS = [ 'development', 'production', 'test' ];
export const SMEE_IO_REGEX = /^https:\/\/(?:www\.)?smee\.io\/[a-zA-Z0-9_-]+\/?/;
export const ENDPONT_PATH_REGEX = /^([\w]+)?(\/[\w-]+)*$/;
@Exclude()
export class AchievibitConfig {
@Expose()
@IsString()
@IsIn(NODE_ENVIRONMENT_OPTIONS)
nodeEnv = 'development';
@Expose()
@IsNumber()
port = 10101;
@Expose()
@IsOptional()
@IsString()
@IsUrl({ protocols: [ 'mongodb', 'mongodb+srv' ], require_tld: false }, {
message: '$property should be a valid mongodb URL'
})
import { classToPlain, ClassTransformOptions, Exclude, Expose } from 'class-transformer';
import { SuggestionInterface } from '../interface';
@Exclude()
export class Suggestion implements SuggestionInterface {
@Expose()
formattedAddress: string;
@Expose()
placeId: string;
@Expose()
provider: string;
@Expose({ groups: ['raw', 'all'] })
raw?: ProviderRawEntryType;
toObject(options?: ClassTransformOptions): SuggestionInterface {
return classToPlain>(this, options) as SuggestionInterface;
}
* 登录密码
*/
password: string;
/**
* 手机号码
*/
mobile: string;
/**
* 手机验证码
*/
code: string;
}
export interface Token { expiresIn: number; accessToken: string; tokenType: string; }
@Exclude()
export class UserInfo {
@Expose() public id: string;
@Expose() public nickname: string;
@Expose() public avatar: string;
}
export interface LoginDao {
user: UserInfo;
token: Token;
}
import { Exclude, Expose, Transform } from 'class-transformer';
import { IsOptional, IsString, MaxLength, MinLength } from 'class-validator';
import { WorldCountryStateInterface } from './world-country-state.interface';
@Exclude()
export class WorldCountryState implements WorldCountryStateInterface {
@IsString()
@MinLength(2)
@MaxLength(2)
@Transform((v: string) =>
v
.toString()
.trim()
.toUpperCase(),
)
@Expose()
countryCode: string;
@IsOptional()
@IsString()
@MinLength(2)
import { classToPlain, ClassTransformOptions, Exclude, Expose } from 'class-transformer';
import { LocationInterface } from '../interface';
@Exclude()
export class Location implements LocationInterface {
@Expose()
provider: string;
/**
* @example 1200 E 89th St, Chicago, IL 60619, USA
* @example 1158 E 89th St, Chicago, Illinois 60619, US
*/
@Expose({ name: 'formattedAddress', toClassOnly: true })
formattedAddress?: string;
@Expose()
latitude: number;
@Expose()
longitude: number;
import { Exclude, Expose, Transform } from 'class-transformer';
import { IsOptional, IsString, MaxLength, MinLength } from 'class-validator';
import { WorldCountryStateQueryInterface } from './world-country-state-query.interface';
@Exclude()
export class WorldCountryStateQuery implements WorldCountryStateQueryInterface {
@IsString()
@MinLength(2)
@MaxLength(2)
@Transform((v: string) => v.trim())
@Expose()
countryCode: string;
@IsOptional()
@IsString()
@MinLength(2)
@MaxLength(2)
@Transform((v: string) =>
v
? v
.toString()
export function transient (target: Object, propertyKey: string) {
Reflect.metadata ("transient", true)(target, propertyKey)
Exclude()(target, propertyKey)
}
parseValues: true,
transform: transformToLowerCase
})
.file({ file: configFilePath });
let smee: SmeeClient;
let events: any;
let configService: ConfigService;
/**
* This is a **Forced Singleton**.
* This means that even if you try to create
* another ConfigService, you'll always get the
* first one.
*/
@Exclude()
export class ConfigService extends AchievibitConfig {
private readonly logger: Logger = new Logger('ConfigService');
private readonly mode: string = environment;
get smee(): SmeeClient {
return smee;
}
get events(): any {
return events;
}
get packageDetails(): PackageDetailsDto {
return packageDetails;
}
import { Exclude, Expose, Transform } from 'class-transformer';
import { IsInt, IsNumberString, IsOptional, IsString, MaxLength, MinLength } from 'class-validator';
import { WorldCountryQueryInterface } from './world-country-query.interface';
@Exclude()
export class WorldCountryQuery implements WorldCountryQueryInterface {
@IsString()
@IsOptional()
@MinLength(1)
@Transform((v: string) => (v ? v.trim() : undefined))
@Expose()
name?: string;
@IsOptional()
@IsString()
@MinLength(2)
@MaxLength(2)
@Transform((v: string) =>
v
? v
.toString()