Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
toObject(options?: ClassTransformOptions): LocationInterface {
return classToPlain>(this, options) as LocationInterface;
}
}
public toProtocolFormat(): object {
const jsonObj = {};
jsonObj[this.Type] = classToPlain(this);
return jsonObj;
}
}
get params() {
return camelKeys(classToPlain(this), { deep: true });
}
}
const emailValidation = await this.emailValidator.validateEmail(req.email);
if (!emailValidation.isValid) {
throw new BadRequestException('Invalid email!');
}
const passwordValidation = await this.passwordValidator.validatePassword(req.password);
if (!emailValidation.isValid) {
throw new BadRequestException('Invalid password!');
}
const user = await this.userService.findOneByEmail(req.email);
if (!user || !await this.passwordCryptographerService.doCompare(req.password, user.password.hash)) {
throw new BadRequestException('Incorrect email or password!');
}
const token = this.authService.createToken(classToPlain(user));
return {
user,
token
};
}
}
public toJSON(): string {
const jsonObj = {};
const instance: any = this.constructor;
jsonObj[instance.name] = classToPlain(this);
return JSON.stringify(jsonObj);
}
}
constructor(configure: () => MinioConfigObject, opts: { defaultBucket?: string } = {}) {
this.defaultBucket = opts.defaultBucket || 'default';
this.configObject = configure();
if (this.configObject.enable !== true) {
throw new Error(
`minio must enable when using minio storage engine: ${r({
configs: classToPlain(this.configObject),
opts,
})}`,
);
}
MinioStorage.logger.log(`[constructor] init ${r({ configs: classToPlain(this.configObject), opts })}`);
/*
Hermes.setupJobProcessor(AsunaSystemQueue.UPLOAD, (job: Job) => {
const { bucket, filenameWithPrefix, file } = job.data;
return this.client
.fPutObject(bucket, filenameWithPrefix, file.path, {
'Content-Type': file.mimetype,
})
.then(uploaded => {
MinioStorage.logger.log(`[saveEntity] [${uploaded}] ...`);
return uploaded;
})
.catch(error => {
MinioStorage.logger.error(
`[saveEntity] [${filenameWithPrefix}] error: ${error}`,
error.trace,
);
public toJson(): {} {
return classToPlain(this);
}
}
content: bookings.map(booking => {
return {
booking:
booking && classToPlain(booking, { excludeExtraneousValues: true }),
table: booking.table && classToPlain(booking.table),
invitedGuests:
booking.invitedGuests && classToPlain(booking.invitedGuests),
order: booking.order && classToPlain(booking.order),
orders:
booking.order &&
booking.invitedGuests &&
booking.invitedGuests.map(element => element.order),
user: booking.user && classToPlain(booking.user),
};
}),
});
protected transform(dto: any, data: any) {
if (!isObject(data) || isFalse(dto)) {
return data;
}
if (!isFunction(dto)) {
return data.constructor !== Object ? classToPlain(data) : data;
}
return data instanceof dto
? classToPlain(data)
: classToPlain(classToPlainFromExist(data, new dto()));
}
public toJson(): {} {
return classToPlain(this);
}
}