chore(email): strict true
This commit is contained in:
@@ -48,10 +48,13 @@ async function buildEmail(
|
|||||||
emailConfig?: NodemailerAdapterArgs,
|
emailConfig?: NodemailerAdapterArgs,
|
||||||
): Promise<{ defaultFromAddress: string; defaultFromName: string; transport: Transporter }> {
|
): Promise<{ defaultFromAddress: string; defaultFromName: string; transport: Transporter }> {
|
||||||
if (!emailConfig) {
|
if (!emailConfig) {
|
||||||
|
const transport = await createMockAccount(emailConfig)
|
||||||
|
if (!transport) throw new InvalidConfiguration('Unable to create Nodemailer test account.')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
defaultFromAddress: 'info@payloadcms.com',
|
defaultFromAddress: 'info@payloadcms.com',
|
||||||
defaultFromName: 'Payload',
|
defaultFromName: 'Payload',
|
||||||
transport: await createMockAccount(emailConfig),
|
transport,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,12 +97,12 @@ const ensureConfigHasFrom = (emailConfig: NodemailerAdapterArgs) => {
|
|||||||
/**
|
/**
|
||||||
* Use ethereal.email to create a mock email account
|
* Use ethereal.email to create a mock email account
|
||||||
*/
|
*/
|
||||||
async function createMockAccount(emailConfig: NodemailerAdapterArgs) {
|
async function createMockAccount(emailConfig?: NodemailerAdapterArgs) {
|
||||||
try {
|
try {
|
||||||
const etherealAccount = await nodemailer.createTestAccount()
|
const etherealAccount = await nodemailer.createTestAccount()
|
||||||
|
|
||||||
const smtpOptions = {
|
const smtpOptions = {
|
||||||
...emailConfig,
|
...(emailConfig || {}),
|
||||||
auth: {
|
auth: {
|
||||||
pass: etherealAccount.pass,
|
pass: etherealAccount.pass,
|
||||||
user: etherealAccount.user,
|
user: etherealAccount.user,
|
||||||
@@ -120,7 +123,13 @@ async function createMockAccount(emailConfig: NodemailerAdapterArgs) {
|
|||||||
console.info(`Mock email account password: ${pass}`)
|
console.info(`Mock email account password: ${pass}`)
|
||||||
}
|
}
|
||||||
return transport
|
return transport
|
||||||
} catch (err) {
|
} catch (err: unknown) {
|
||||||
console.error({ err, msg: 'There was a problem setting up the mock email handler' })
|
if (err instanceof Error) {
|
||||||
|
console.error({ err, msg: 'There was a problem setting up the mock email handler' })
|
||||||
|
throw new InvalidConfiguration(
|
||||||
|
`Unable to create Nodemailer test account. Error: ${err.message}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
throw new InvalidConfiguration('Unable to create Nodemailer test account.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,18 @@
|
|||||||
"emitDeclarationOnly": true,
|
"emitDeclarationOnly": true,
|
||||||
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
||||||
"rootDir": "./src" /* Specify the root folder within your source files. */,
|
"rootDir": "./src" /* Specify the root folder within your source files. */,
|
||||||
|
"strict": true,
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"dist",
|
"dist",
|
||||||
|
"node_modules",
|
||||||
"src/**/*.spec.js",
|
"src/**/*.spec.js",
|
||||||
"src/**/*.spec.jsx",
|
"src/**/*.spec.jsx",
|
||||||
"src/**/*.spec.ts",
|
"src/**/*.spec.ts",
|
||||||
"src/**/*.spec.tsx"
|
"src/**/*.spec.tsx"
|
||||||
],
|
],
|
||||||
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
|
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts", "src/**/*.json"],
|
||||||
|
"references": [
|
||||||
|
{ "path": "../payload" },
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user