Untitled

 avatar
unknown
plain_text
a month ago
1.0 kB
2
Indexable
express = require("express");
const admin = require("firebase-admin");
const bodyParser = require("body-parser");

admin.initializeApp({
  credential: admin.credential.applicationDefault(),
});

const app = express();
app.use(bodyParser.json());

// Sign up route
app.post("/signup", async (req, res) => {
  const { email, password } = req.body;
  try {
    const user = await admin.auth().createUser({
      email,
      password,
    });
    res.status(201).send({ message: "User created successfully", user });
  } catch (error) {
    res.status(400).send({ error: error.message });
  }
});

// Login route
app.post("/login", async (req, res) => {
  const { email, password } = req.body;
  // Use Firebase Authentication for user verification
  // Add JWT token creation here if needed
  res.status(200).send({ message: "Login successful" });
});

app.listen(3000, () => console.log("Server is running on port 3000"));

Would you like guidance on a specific feature, such as the restaurant menu or order tracking?

Leave a Comment