-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Backend] article-rating interlink #78
base: master
Are you sure you want to change the base?
Conversation
@@ -1,3 +1,4 @@ | |||
import { Article } from "../models/article"; | |||
import { Rating } from "../models/rating"; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need status codes and response messages on all responses.
@@ -72,6 +81,10 @@ export const updateRating = async (req: any, res: any) => { | |||
try { | |||
const rating = await Rating.findById({ _id: req.params.id }) | |||
if (!rating) return res.status(404).send("Rating not found to be updated") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change response message since this would be shown to users on the frontend. like.. "Rating not found!"
@@ -2,7 +2,7 @@ import app from "./app" | |||
import mongoose from 'mongoose'; | |||
|
|||
const PORT = process.env.PORT || 8000 | |||
const DB_URI = process.env.MONGO_URI || "mongodb://localhost:27017/test"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to reveal database strings here. use env variables.
@@ -2,7 +2,7 @@ import app from "./app" | |||
import mongoose from 'mongoose'; | |||
|
|||
const PORT = process.env.PORT || 8000 | |||
const DB_URI = process.env.MONGO_URI || "mongodb://localhost:27017/test"; | |||
const DB_URI = process.env.mongodb_url || "mongodb://localhost:27017/rating"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make the variable naming better and readable.. like MONGO_URI and MONGO_URI_TEST bla bla :)
article rating interlinks