Lines 1887-1927javascript
1887 await fs.outputFile(path.join(dest, "src", "model", `Coupon.${ext}`), content);
1889async function writeAuthExtendedRoutes(dest, opts) {
1890 const ext = opts.language === "typescript" ? "ts" : "js";
1891 const ts = opts.language === "typescript";
1892 const mwUser2 = opts.rbac ? `export const middlewares = [requireAuth('user', 'admin')];
1893` : `export const middlewares = [requireAuth];
1895 const mwUser3 = mwUser2;
1896 const reqT = ts ? `import type { Request, Response } from 'express';
1898 const RA = `import { requireAuth } from 'express-file-cluster/auth';
1900 const mongo = opts.database === "mongodb";
1901 const hasAdmin = opts.adminPortal;
1902 const uf = opts.userFeatures;
1903 const sendResetEmail = opts.mailer ? ` var appUrl = process.env.APP_URL || 'http://localhost:3000';
1904 await enqueue('SendEmail', {
1906 subject: 'Reset your password',
1907 body: 'Reset your password: ' + appUrl + '/auth/reset-password?token=' + resetToken,
1909` : ` // TODO: email this token to the user \u2014 enable the Mailer feature to auto-wire SendEmail
1911 const sendVerifyEmailResend = opts.mailer ? ` var appUrl = process.env.APP_URL || 'http://localhost:3000';
1912 await enqueue('SendEmail', {
1914 subject: 'Verify your email address',
1915 body: 'Verify your email: ' + appUrl + '/auth/verify-email?token=' + verifyToken,
1917` : ` // TODO: email this token to the user \u2014 enable the Mailer feature to auto-wire SendEmail
1919 const mailerTaskImport = opts.mailer ? `import { enqueue } from 'express-file-cluster/tasks';
1921 if (uf.accountSecurity) {
1922 const refreshMeta = mkMeta(opts, {
1924 description: "Refresh the JWT using the refresh-token cookie and issue a new access token.",
1925 response: `{ message: 'Token refreshed' }`