Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
<h3>How to reset your password:</h3>
<ul>
<li>Return to the password reset page on our website</li>
<li>Enter the 6-digit code shown above</li>
<li>Enter the 4-digit code shown above</li>
<li>Follow the instructions to set a new password</li>
</ul>
</div>
Expand Down
28 changes: 19 additions & 9 deletions apps/auth-service/src/utils/sendMail/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import dotenv from 'dotenv';
import ejs from 'ejs';
import nodemail from 'nodemailer';
import path from 'path';
import { existsSync } from 'node:fs';

dotenv.config();

Expand All @@ -17,15 +18,24 @@ const transporter = nodemail.createTransport({

//Render an EJS email template
const renderEmailTemplate = async (templateName: string, data: Record<string, any>): Promise<string> => {
const templatePath = path.join(
process.cwd(),
'apps',
'auth-service',
'src',
'utils',
'email-templates',
`${templateName}.ejs`,
);
const templateCandidates = [
path.join(__dirname, '..', 'email-templates', `${templateName}.ejs`),
path.join(
process.cwd(),
'apps',
'auth-service',
'src',
'utils',
'email-templates',
`${templateName}.ejs`,
),
];

const templatePath = templateCandidates.find((candidate) => existsSync(candidate));

if (!templatePath) {
throw new Error(`Email template ${templateName} not found`);
}

return ejs.renderFile(templatePath, data);
};
Expand Down
9 changes: 8 additions & 1 deletion apps/auth-service/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ module.exports = {
compiler: 'tsc',
main: './src/main.ts',
tsConfig: './tsconfig.app.json',
assets: ['apps/auth-service/src/assets'], // Changed from './src/assets' to 'apps/auth-service/src/assets'
assets: [
'apps/auth-service/src/assets',
{
input: 'apps/auth-service/src/utils/email-templates',
glob: '**/*',
output: 'email-templates',
},
], // ensure email templates ship with the build output
optimization: false,
outputHashing: 'none',
generatePackageJson: true,
Expand Down
29 changes: 20 additions & 9 deletions apps/order-service/src/utils/send-email/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import dotenv from 'dotenv';
import ejs from 'ejs';
import nodemail from 'nodemailer';
import path from 'path';
import { existsSync } from 'node:fs';

dotenv.config();

Expand All @@ -17,15 +18,25 @@ const transporter = nodemail.createTransport({

//Render an EJS email template
const renderEmailTemplate = async (templateName: string, data: Record<string, any>): Promise<string> => {
const templatePath = path.join(
process.cwd(),
'apps',
'auth-service',
'src',
'utils',
'email-templates',
`${templateName}.ejs`,
);
const templateCandidates = [
path.join(__dirname, 'email-templates', `${templateName}.ejs`),
path.join(__dirname, '..', 'email-templates', `${templateName}.ejs`),
path.join(
process.cwd(),
'apps',
'order-service',
'src',
'utils',
'email-templates',
`${templateName}.ejs`,
),
];

const templatePath = templateCandidates.find((candidate) => existsSync(candidate));

if (!templatePath) {
throw new Error(`Email template ${templateName} not found`);
}

return ejs.renderFile(templatePath, data);
};
Expand Down
9 changes: 8 additions & 1 deletion apps/order-service/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ module.exports = {
compiler: 'tsc',
main: './src/main.ts',
tsConfig: './tsconfig.app.json',
assets: ['./src/assets'],
assets: [
'./src/assets',
{
input: 'apps/order-service/src/utils/email-templates',
glob: '**/*',
output: 'email-templates',
},
],
optimization: false,
outputHashing: 'none',
generatePackageJson: true,
Expand Down
Loading