Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc #561

Merged
merged 2 commits into from
Nov 15, 2023
Merged

Misc #561

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
1 change: 1 addition & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface EmailEsrfApiRequestBody {
}

export interface HealthApiResponse {
adobeAnalyticsScriptSrc: string | null
appBaseUri: string | null
buildDate: string | null
environment: string | null
Expand Down
19 changes: 10 additions & 9 deletions src/pages/api/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ export default async function handler(
res: NextApiResponse<Alert[] | string>,
) {
try {
if (!process.env.ALERT_JSON_URI) {
logger.error('ALERT_JSON_URI must not be undefined, null or empty')
throw Error(
'process.env.ALERT_JSON_URI must not be undefined, null or empty',
)
}

if (req.method !== 'GET') {
logger.debug(`error 405: Invalid request method ${req.method}`)
return res.status(405).send(`Invalid request method ${req.method}`)
}

if (!process.env.ALERT_JSON_URI?.trim()) {
logger.warn(
'ALERT_JSON_URI is either undefined, null, or an empty string. Consequently, an empty array is being returned.',
)
res.status(200).json([])
return
}

const query = req.query
const { page } = query

Expand Down Expand Up @@ -52,10 +53,10 @@ export default async function handler(
type: alert.type,
}))

return res.status(200).json(alerts)
res.status(200).json(alerts)
} catch (error) {
// If there's a problem with the alerts, we return 500 but with an empty list
logger.error(error, 'Failed to fetch alerts')
return res.status(500).json([])
res.status(500).json([])
}
}
1 change: 1 addition & 0 deletions src/pages/api/health.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default async function handler(
}

res.status(200).json({
adobeAnalyticsScriptSrc: process.env.ADOBE_ANALYTICS_SCRIPT_SRC ?? null,
appBaseUri: process.env.APP_BASE_URI ?? null,
buildDate: process.env.NEXT_PUBLIC_BUILD_DATE ?? null,
environment: process.env.ENVIRONMENT ?? null,
Expand Down