// console.clear();
const app = require("./server").app;
var express = require("express");
var path = require("path");
var indexRouter = require("./routes/index");
var cron = require("node-cron");
const domainMiddleware = require("./middlewares/domainAuth");
// const admin = require("firebase-admin");
// var serviceAccount = require("./config/altcabs-firebase-adminsdk-odurf-75b335c559.json");
// admin.initializeApp({
//   credential: admin.credential.cert(serviceAccount),
// });

app.set("view engine", "ejs");

// catch 404 and forward to error handler

app.use("/", indexRouter);

app.get("/iframe", async (req, res) => {
  res.sendFile(path.join(__dirname, "istariframe", "build", "index.html"));
});
app.get("/iframe/*", async (req, res) => {
  res.sendFile(path.join(__dirname, "istariframe", "build", "index.html"));
});
app.use(express.static(path.join(__dirname, "istariframe", "build")));

app.get("/admin", async (req, res) => {
  res.sendFile(path.join(__dirname, "istar-admin", "build", "index.html"));
});
app.get("/admin/*", async (req, res) => {
  res.sendFile(path.join(__dirname, "istar-admin", "build", "index.html"));
});
app.use(express.static(path.join(__dirname, "istar-admin", "build")));

// require("./routes")(app);

// app.get("/vender", async (req, res) => {
//   res.sendFile(
//     path.join(__dirname, "hypermarketVendor", "build", "index.html")
//   );
// });
// app.get("/vender/*", async (req, res) => {
//   res.sendFile(
//     path.join(__dirname, "hypermarketVendor", "build", "index.html")
//   );
// });
// app.use(express.static(path.join(__dirname, "hypermarketVendor", "build")));
