added health endpoint (#345)

This commit is contained in:
Deepak Prabhakara 2023-10-10 20:09:53 +01:00 committed by GitHub
parent cb04198656
commit 1c1e644ca0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

18
pages/api/health.ts Normal file
View File

@ -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({});
}
}