This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bcrypt from 'bcrypt'; | |
import { Request, Response } from 'express'; | |
import { TokenService } from 'src/services/TokenService'; | |
import { UserModel } from 'src/models/UserModel'; | |
import type { User } from 'src/@types'; | |
export const resetPasswordController = async (req: Request, res: Response) => { | |
try { | |
const token = req.params.token; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import path from 'path'; | |
import { Extension } from 'src/@types/enums'; | |
type AttachmentFile = { | |
name: string; | |
ext?: Extension; | |
cid?: string; | |
}; | |
export const generateAttachments = (files: AttachmentFile[] = []) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import path from 'path'; | |
import fs from 'fs'; | |
import handlebars from 'handlebars'; | |
export const generateTemplate = <T>(name: string, props: T): string => { | |
const templatePath = path.join(__dirname, '..', 'src/templates', `${name}.hbs`); | |
const templateSource = fs.readFileSync(templatePath, 'utf8'); | |
const template = handlebars.compile(templateSource); | |
return template(props); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as dotenv from 'dotenv'; | |
import process from 'process'; | |
dotenv.config(); | |
export const getHost = (): string => { | |
const isProduction = process.env.NODE_ENV === 'production'; | |
const protocol = isProduction ? 'https' : 'http'; | |
const port = isProduction ? '' : `:${process.env.CLIENT_PORT}`; | |
return `${protocol}://${process.env.WEB_HOST}${port}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import process from 'process'; | |
import * as nodemailer from 'nodemailer'; | |
import * as dotenv from 'dotenv'; | |
import { generateAttachments } from 'src/helpers/generateAttachments'; | |
import { generateTemplate } from 'src/helpers/generateTemplate'; | |
import { getHost } from 'src/helpers/getHost'; | |
dotenv.config(); | |
export class EmailService { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import process from 'process'; | |
import * as nodemailer from 'nodemailer'; | |
import * as dotenv from 'dotenv'; | |
dotenv.config(); | |
export class EmailService { | |
private static transporter: nodemailer.Transporter; | |
private static env = { | |
USER: process.env.MAIL_USER, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { TokenService } from 'src/services/TokenService'; | |
import { RedisService } from 'src/services/RedisService'; | |
import { EmailService } from 'src/services/EmailService'; | |
export const initialize = async () => { | |
await RedisService.initialize(); | |
TokenService.initialize(); | |
EmailService.initialize(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import process from 'process'; | |
import * as nodemailer from 'nodemailer'; | |
import * as dotenv from 'dotenv'; | |
dotenv.config(); | |
export class EmailService { | |
private static transporter: nodemailer.Transporter; | |
private static env = { | |
USER: process.env.MAIL_USER, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Request, Response } from 'express'; | |
import { UserModel } from 'src/models/UserModel'; | |
import type { User } from 'src/@types'; | |
import { TokenService } from 'src/services/TokenService'; | |
import { EmailService } from 'src/services/EmailService'; | |
export const forgotPasswordController = async (req: Request, res: Response) => { | |
try { | |
const { | |
email, |
NewerOlder