All files / src/pages/api health.ts

0% Statements 0/6
0% Branches 0/12
0% Functions 0/1
0% Lines 0/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                                                       
import { NextApiRequest, NextApiResponse } from 'next'
 
import { HealthApiResponse } from '../../lib/types'
import { getLogger } from '../../logging/log-util'
 
const logger = getLogger('health')
 
export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse<HealthApiResponse | string>,
) {
  if (req.method !== 'GET') {
    logger.debug(`error 405: Invalid request method ${req.method}`)
    res.status(405).send(`Invalid request method ${req.method}`)
    return
  }
 
  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,
    loggingLevel: process.env.LOGGING_LEVEL ?? null,
    status: 'UP',
    uptime: `${process.uptime()} seconds`,
  })
}