import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { MailerService } from '@nestjs-modules/mailer';
import { ConfigService } from '@nestjs/config';
import { join } from 'path';
import { IMail } from './interfaces/mail.interface';
@Injectable()
export class MailService {
constructor(
private readonly mailerService: MailerService,
private configService: ConfigService
) {}
async emailSend(mailData:IMail<T>) {
const urlConfirmAddress = this.configService.get<string>(
'URL_CONFIRM_ADDRESS',
);
return this.mailerService.sendMail({
to: mailData.to,
subject: mailData.subject,
template: join(__dirname, '/../templates', mailData.template),
context: mailData.context
}).catch((e) => {
throw new HttpException(
`Ошибка работы почты: ${JSON.stringify(e)}`,
HttpStatus.UNPROCESSABLE_ENTITY,
);
});
}
}
Proxy { <target>: {…}, <handler>: {…} }
<target>: Object { candidats: Getter & Setter, vacancies: Getter & Setter, … }
candidats: Proxy { <target>: (1) […], <handler>: {…} }
<target>: Array [ Proxy ]
0: Proxy { <target>: {…}, <handler>: {…} }
<target>: Object { id: Getter & Setter, candidatId: Getter & Setter, categoryId: Getter & Setter, … }
adress: "Treviso, via Cacciatori del sile, 21"
avatar: "avatar"
birthday: "24/11/1988"
candidatId: 1
categoryId:
cognomen:
email:
id:
name:
nationality:
phone:
profession:
Symbol(mobx administration): Object { target_: {…}, name_: "HomeStore@1.content.candidats[..]", isPlainObject_: true, … }
<get adress()>: function get()
<set adress()>: function set(value)
<get avatar()>: function get()
<set avatar()>: function set(value)
<get birthday()>: function get()
<set birthday()>: function set(value)
<get candidatId()>: function get()
<set candidatId()>: function set(value)
<get categoryId()>: function get()
<set categoryId()>: function set(value)
<get cognomen()>: function get()
<set cognomen()>: function set(value)
<get email()>: function get()
<set email()>: function set(value)
<get id()>: function get()
<set id()>: function set(value)
<get name()>: function get()
<set name()>: function set(value)
<get nationality()>: function get()
<set nationality()>: function set(value)
<get phone()>: function get()
<set phone()>: function set(value)
<get profession()>: function get()
<set profession()>: function set(value)
<prototype>: Object { … }
<handler>: Object { has: has(target, name), get: get(target, name), set: set(target, name, value), … }
length: 1
Symbol(mobx administration): Object { owned_: false, legacyMode_: false, lastKnownLength_: 1, … }
<prototype>: Array []
<handler>: Object { get: get(target, name), set: set(target, name, value), preventExtensions: preventExtensions() }
vacancies: Proxy { <target>: [], <handler>: {…} }
Symbol(mobx administration): Object { target_: {…}, name_: "HomeStore@1.content", isPlainObject_: true, … }
<get candidats()>: function get()
<set candidats()>: function set(value)
<get vacancies()>: function get()
<set vacancies()>: function set(value)
<prototype>: Object { … }
<handler>: Object { has: has(target, name), get: get(target, name), set: set(target, name, value), … }
HomePage.tsx:20
import { ApiProperty } from "@nestjs/swagger";
import { BelongsToMany } from "sequelize-typescript";
import { Column, DataType, Model, Table } from "sequelize-typescript";
import { Users } from "src/users/users.model";
import { UserRoles } from "./user-roles.model";
interface RoleCreationAttrs {
value: string;
description: string;
}
@Table({tableName: 'roles'})
export class Role extends Model<Role, RoleCreationAttrs> {
@ApiProperty({example: '1', description: 'User unique Id number'})
@Column({type: DataType.INTEGER, unique: true, autoIncrement: true, primaryKey: true})
id: number;
@ApiProperty({example: 'Admin/Moder/User', description: 'Role unique value'})
@Column({type: DataType.STRING, unique: true, allowNull: false})
value: string;
@ApiProperty({example: 'Short desc', description: 'Short description of role'})
@Column({type: DataType.STRING, allowNull: false})
description: string;
@BelongsToMany(() => Users, () => UserRoles)
users: Users[];
}