Forgot to commit file
This commit is contained in:
parent
abd3dc9895
commit
8aa241afdd
25
src/pages/api/user/[userId]/clear-data.ts
Normal file
25
src/pages/api/user/[userId]/clear-data.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,7 @@ POST http://localhost:3000/api/user/login
|
|||||||
GET http://localhost:3000/api/user/:user_id/bank-account
|
GET http://localhost:3000/api/user/:user_id/bank-account
|
||||||
:headers
|
:headers
|
||||||
|
|
||||||
# Get bank account
|
# Clear user data
|
||||||
POST http://localhost:3000/api/user/:user_id/clear-data
|
POST http://localhost:3000/api/user/:user_id/clear-data
|
||||||
:headers
|
:headers
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user