diff --git a/pages/api/health.ts b/pages/api/health.ts new file mode 100644 index 0000000..1a7f618 --- /dev/null +++ b/pages/api/health.ts @@ -0,0 +1,18 @@ +import { NextApiRequest, NextApiResponse } from 'next'; + +import packageInfo from '../../package.json'; + +export default async function handler(req: NextApiRequest, res: NextApiResponse) { + try { + if (req.method !== 'GET') { + throw new Error('Method not allowed'); + } + + res.status(200).json({ + version: packageInfo.version, + }); + } catch (err: any) { + const { statusCode = 503 } = err; + res.status(statusCode).json({}); + } +}