// Filename - server.js file

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

const app = next({ dev: process.env.NODE_ENV !== "production" });

app.prepare().then(() => {
  const server = http.createServer((req, res) => {
    // Handle Next.js routes
    return app.getRequestHandler()(req, res);
  });

  const port = process.env.PORT || 3000;
  server.listen(port, (err) => {
    if (err) throw err;
    console.log(`> Ready on http://localhost:${port}`);
  });
});
