2022-10-26 03:07:10 +00:00
|
|
|
require("dotenv").config({ path: "./config.env" });
|
2022-10-06 18:49:58 +00:00
|
|
|
const express = require("express");
|
|
|
|
const app = express();
|
2022-10-26 03:07:10 +00:00
|
|
|
|
|
|
|
const apiRoutes = require("./routes.js");
|
2022-10-06 18:49:58 +00:00
|
|
|
|
|
|
|
app.use(express.json());
|
|
|
|
app.use(express.urlencoded({ extended: true }));
|
|
|
|
|
|
|
|
app.use("/api", apiRoutes);
|
|
|
|
|
2023-03-03 13:58:02 +00:00
|
|
|
app.use((req, res, next) => {
|
|
|
|
res.header("Access-Control-Allow-Origin", "*");
|
|
|
|
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
|
2022-10-06 18:49:58 +00:00
|
|
|
app.use("*", (req, res) => {
|
2022-10-18 12:10:11 +00:00
|
|
|
return res.status(404).json({ error: "Resource not found" });
|
2022-10-06 18:49:58 +00:00
|
|
|
});
|
|
|
|
|
2022-10-18 12:10:11 +00:00
|
|
|
const port = process.env.PORT || 3001;
|
|
|
|
|
|
|
|
app.listen(port, () => {
|
|
|
|
console.log("Suggestion Service API is up on port " + port);
|
2022-11-14 20:20:43 +00:00
|
|
|
console.log("Running at http://localhost:" + port + "/");
|
2022-10-06 18:49:58 +00:00
|
|
|
});
|