import express from "express";
import cors from "cors";
import dotenv from "dotenv";
import stateRouter from "./routes/state.js";
import loginRouter from "./routes/login.js";

dotenv.config();

const app = express();
const port = Number(process.env.PORT || 3001);

app.use(cors());
app.use(express.json({ limit: "25mb" }));

app.get("/api/health", (_req, res) => {
  res.json({ ok: true, message: "Mineral Scents POS state API running" });
});

app.use("/api/login", loginRouter);
app.use("/api/state", stateRouter);

app.listen(port, () => {
  console.log(`Backend running on port ${port}`);
});
