export async function POST()

in appdev_with_generative_ai/src/knowledge-drive/app/api/register/route.ts [11:40]


export async function POST(request: Request) {
  const { name, email, password } = await request.json();
  try {
    const { uid } = await getAuth(firebaseAdminApp).createUser({
      email: email,
      displayName: name,
      password: password,
    });
    const batch = firestore.batch();
    const userRef = firestore.collection("users").doc(uid);
    batch.set(userRef, { timestamp: FieldValue.serverTimestamp() });
    const itemsRef = firestore
      .collection("users")
      .doc(uid)
      .collection("items")
      .doc(ROOT_FOLDER_ID);
    batch.create(itemsRef, {
      name: ROOT_FOLDER_NAME,
      timestamp: FieldValue.serverTimestamp(),
      parent: null,
      isFolder: true,
      filesize: 0,
    });
    await batch.commit();
  } catch (e) {
    console.error(e);
    return NextResponse.json({ message: e }, { status: 500 });
  }
  return NextResponse.json({ message: "success" });
}