From acb7fdcae8eba2152d8246517d711e4af67bf4bf Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Tue, 5 Sep 2023 14:27:06 -0700 Subject: [PATCH] add version endpoint --- src/pages/api/version.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/pages/api/version.ts diff --git a/src/pages/api/version.ts b/src/pages/api/version.ts new file mode 100644 index 00000000..4453b56f --- /dev/null +++ b/src/pages/api/version.ts @@ -0,0 +1,17 @@ +import { NextApiRequest, NextApiResponse } from 'next'; +import { ok, methodNotAllowed } from 'next-basics'; +import { CURRENT_VERSION } from 'lib/constants'; + +export interface VersionResponse { + version: string; +} + +export default async (req: NextApiRequest, res: NextApiResponse) => { + if (req.method === 'GET') { + return ok(res, { + version: CURRENT_VERSION, + }); + } + + return methodNotAllowed(res); +};