const express = require("express");
const path = require("path");

const apiRouter = require("./routes/api");

const app = express();

app.use(express.json());

app.use(
    express.static(
        path.join(__dirname, "../public")
    )
);

app.use("/api", apiRouter);

if (require.main === module) {
    const PORT =
        process.env.PORT || 3000;

    app.listen(
        PORT,
        "0.0.0.0",
        () => {
            console.log(
                `Steg app listening on port ${PORT}`
            );
        }
    );
}

module.exports = app;