Merge branch 'beta' of https://github.com/payloadcms/payload into fix/row-table-names
This commit is contained in:
@@ -4,6 +4,7 @@ import httpStatus from 'http-status'
|
||||
import { APIError } from 'payload/errors'
|
||||
|
||||
import { getPayloadHMR } from '../../utilities/getPayloadHMR.js'
|
||||
import { headersWithCors } from '../../utilities/headersWithCors.js'
|
||||
|
||||
export type ErrorResponse = { data?: any; errors: unknown[]; stack?: string }
|
||||
|
||||
@@ -81,6 +82,11 @@ export const routeError = async ({
|
||||
}) => {
|
||||
let payload = req?.payload
|
||||
|
||||
const headers = headersWithCors({
|
||||
headers: new Headers(),
|
||||
req,
|
||||
})
|
||||
|
||||
if (!payload) {
|
||||
try {
|
||||
payload = await getPayloadHMR({ config: configArg })
|
||||
@@ -89,7 +95,7 @@ export const routeError = async ({
|
||||
{
|
||||
message: 'There was an error initializing Payload',
|
||||
},
|
||||
{ status: httpStatus.INTERNAL_SERVER_ERROR },
|
||||
{ headers, status: httpStatus.INTERNAL_SERVER_ERROR },
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -133,5 +139,5 @@ export const routeError = async ({
|
||||
})
|
||||
}
|
||||
|
||||
return Response.json(response, { status })
|
||||
return Response.json(response, { headers, status })
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ import type { EmailAdapter } from './types.js'
|
||||
import { emailDefaults } from './defaults.js'
|
||||
import { getStringifiedToAddress } from './getStringifiedToAddress.js'
|
||||
|
||||
export const stdoutAdapter: EmailAdapter<void> = ({ payload }) => ({
|
||||
export const consoleEmailAdapter: EmailAdapter<void> = ({ payload }) => ({
|
||||
defaultFromAddress: emailDefaults.defaultFromAddress,
|
||||
defaultFromName: emailDefaults.defaultFromName,
|
||||
sendEmail: async (message) => {
|
||||
const stringifiedTo = getStringifiedToAddress(message)
|
||||
const res = `EMAIL NON-DELIVERY. To: '${stringifiedTo}', Subject: '${message.subject}'`
|
||||
const res = `Email attempted without being configured. To: '${stringifiedTo}', Subject: '${message.subject}'`
|
||||
payload.logger.info({ msg: res })
|
||||
return Promise.resolve()
|
||||
},
|
||||
@@ -49,7 +49,7 @@ import { APIKeyAuthentication } from './auth/strategies/apiKey.js'
|
||||
import { JWTAuthentication } from './auth/strategies/jwt.js'
|
||||
import localOperations from './collections/operations/local/index.js'
|
||||
import { validateSchema } from './config/validate.js'
|
||||
import { stdoutAdapter } from './email/stdoutAdapter.js'
|
||||
import { consoleEmailAdapter } from './email/consoleEmailAdapter.js'
|
||||
import { fieldAffectsData } from './exports/types.js'
|
||||
import localGlobalOperations from './globals/operations/local/index.js'
|
||||
import flattenFields from './utilities/flattenTopLevelFields.js'
|
||||
@@ -382,10 +382,10 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
||||
this.email = this.config.email({ payload: this })
|
||||
} else {
|
||||
this.logger.warn(
|
||||
`No email adapter provided. Email will be written to stdout. More info at https://payloadcms.com/docs/email/overview.`,
|
||||
`No email adapter provided. Email will be written to console. More info at https://payloadcms.com/docs/email/overview.`,
|
||||
)
|
||||
|
||||
this.email = stdoutAdapter({ payload: this })
|
||||
this.email = consoleEmailAdapter({ payload: this })
|
||||
}
|
||||
|
||||
this.sendEmail = this.email['sendEmail']
|
||||
|
||||
Reference in New Issue
Block a user