Skip to content

Commit

Permalink
Hotfix collection
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroavpereira committed Aug 29, 2024
1 parent a23eb9e commit 932201f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ENV PORT 3000
ENV NODE_ENV development
ENV DB_URL postgresql://postgres.qlqsmadmjmmcipubfzwo:[email protected]:6543/postgres

ENV AUTH_API_URL http://127.0.0.1:5000
ENV AUTH_API_URL http://54.75.137.47:5000

EXPOSE 3000

Expand Down
2 changes: 2 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ const reviewRouter = require("./routes/reviewRouter");
const wishlistRouter = require("./routes/wishlistRouter");
const roomsRouter = require("./routes/rooms");
const bookRatingsRouter = require("./routes/bookRatingsRouter");
const logger = require("./middleware/logger");

const app = express();

app.use(cors());
app.use(express.json());
app.use(logger);

app.use("/swaps", swapsRouter);

Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const server = require("./websocket");

const PORT = process.env.PORT || 3001;

console.log("TESTING");

server.listen(PORT, () => {
console.log(`SERVER RUNNING ON PORT ${PORT}`);
});
2 changes: 2 additions & 0 deletions middleware/authenticator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ const axios = require("axios");

const authenticator = async (req, res, next) => {
try {
console.log("Authenticator");
const response = await axios.get(
`${process.env.AUTH_API_URL}/validate-token`,
{ headers: { authorization: req.headers.authorization } }
);
console.log("After Authenticator axios");
req.user_id = response.data.user_id;
next();
} catch (err) {
Expand Down
6 changes: 6 additions & 0 deletions middleware/logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const logger = (req, res, next) => {
console.log(req.method, req.originalUrl);
next();
};

module.exports = logger;
2 changes: 1 addition & 1 deletion routes/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const collectionsController = require("../controllers/collections");
const collectionsRouter = Router();

collectionsRouter.get("/search", collectionsController.searchProximity);
collectionsRouter.get("/:collection_id", collectionsController.searchById);
collectionsRouter.get("/id/:collection_id", collectionsController.searchById);
collectionsRouter.get("/user/:user_id", collectionsController.searchByUser);

collectionsRouter.use(authenticator);
Expand Down

0 comments on commit 932201f

Please sign in to comment.