27 lines
597 B
JavaScript
27 lines
597 B
JavaScript
const express = require("express");
|
|
const app = express();
|
|
|
|
const apiRoutes = require("./routes.js");
|
|
|
|
app.use(express.json());
|
|
app.use(express.urlencoded({ extended: true }));
|
|
|
|
app.use("/api", apiRoutes);
|
|
|
|
app.use((req, res, next) => {
|
|
res.header("Access-Control-Allow-Origin", "*");
|
|
|
|
next();
|
|
});
|
|
|
|
app.use("*", (req, res) => {
|
|
return res.status(404).json({ error: "Resource not found" });
|
|
});
|
|
|
|
const port = process.env.API_PORT || 3001;
|
|
|
|
app.listen(port, () => {
|
|
console.log("Suggestion Service API is up on port " + port);
|
|
console.log("Running at http://localhost:" + port + "/");
|
|
});
|