const http = require("http");
const next = require("next");

const port = Number(process.env.PORT || 3000);
const hostname = "0.0.0.0";
const app = next({ dev: false, hostname, port });
const handle = app.getRequestHandler();

app.prepare().then(() => {
  http.createServer((request, response) => {
    handle(request, response);
  }).listen(port, hostname, () => {
    console.log(`BD Offers Mini App listening on ${hostname}:${port}`);
  });
}).catch((error) => {
  console.error("Failed to start BD Offers Mini App", error);
  process.exit(1);
});
