summaryrefslogtreecommitdiff
path: root/src/pages/api/auth.ts
blob: 3ed9b76f120809c22f43c5e3df289322432d3176 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import db from "../../lib/db";
export const POST = async (request: Request): Promise<Response> => {
  const body = await request.json();

  if (!body.name || !body.creds) {
    return Response.json({ message: "Invalid" }, { status: 400 });
  }

  try {
    const res = db.loginUser(body.name, body.creds);
    console.log({ res });

    return Response.json(res, { status: 200 });
  } catch (error) {
    return Response.json({ message: "Failure" }, { status: 500 });
  }
};