Forgot to commit file

This commit is contained in:
Joseph Ferano 2023-04-11 21:36:18 +07:00
parent abd3dc9895
commit 8aa241afdd
2 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1,25 @@
import { postgresConnection } from "db";
import type { NextApiRequest, NextApiResponse } from "next";
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
try {
if (req.method === "POST") {
let { userId } = req.query;
const db = postgresConnection;
const result = await db.query("select clear_user_data($1)", [userId]);
console.log(result);
if (result.rowCount > 0) {
return res.status(200).json({message: "Success!"});
} else {
return res.status(404).json({ message: "User not found" });
}
}
} catch (error) {
res.status(500).json(error.message);
}
}

View File

@ -20,7 +20,7 @@ POST http://localhost:3000/api/user/login
GET http://localhost:3000/api/user/:user_id/bank-account
:headers
# Get bank account
# Clear user data
POST http://localhost:3000/api/user/:user_id/clear-data
:headers