mirror of
https://github.com/Xevion/bus-reminder.git
synced 2025-12-09 08:06:50 -06:00
Add atomic health check API route
This commit is contained in:
18
src/pages/api/health.ts
Normal file
18
src/pages/api/health.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { env } from "@/env/server.mjs";
|
||||
|
||||
type ResponseData = {
|
||||
now: number;
|
||||
status: string;
|
||||
};
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse<ResponseData>
|
||||
) {
|
||||
res.status(200).json({
|
||||
now: new Date().getTime(),
|
||||
status: req.query.key == env.API_KEY ? "Authorized" : "Unauthorized",
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user