(request)
| 2 | |
| 3 | |
| 4 | export async function POST(request) { |
| 5 | const body = await request.json() |
| 6 | |
| 7 | const client = await clientPromise; |
| 8 | const db = client.db("bittree") |
| 9 | const collection = db.collection("links") |
| 10 | |
| 11 | // If the handle is already claimed, you cannot create the bittree |
| 12 | const doc = await collection.findOne({handle: body.handle}) |
| 13 | |
| 14 | if (doc){ |
| 15 | return Response.json({ success: false, error: true, message: 'This Bittree already exists!', result: null }) |
| 16 | } |
| 17 | |
| 18 | const result = await collection.insertOne(body) |
| 19 | |
| 20 | return Response.json({ success: true, error: false, message: 'Your Bittree has been generated!', result: result, }) |
| 21 | } |
nothing calls this directly
no outgoing calls
no test coverage detected