Skip to content

Commit

Permalink
Make Some Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadAkthamObeidat committed Jan 17, 2020
1 parent bf0ea61 commit a4cbb34
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 14 deletions.
24 changes: 14 additions & 10 deletions controllers/UsersController.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ deleteMovieFromWatchList = (req, res, next) => {
let userID = req.params.userID;
let movieID = req.params.movieID;
user.deleteMovieFromWatchList(userID, movieID, result => {
res.status(200).json({
res.status(204).json({
status: 'Success Delete Movie From Watch List.',
data: {
deletedMovie: result
}
data: NULL
})
})
}
Expand All @@ -53,14 +51,12 @@ addMovieToWatchedList = (req, res, next) => {
deleteMovieFromWatchedList = (req, res, next) => {
let userID = req.params.userID;
let movieID = req.params.movieID;
user.deleteMovieFromWatchedList = (userID, movieID, result) => {
res.status(200).json({
user.deleteMovieFromWatchedList(userID, movieID, result => {
res.status(204).json({
status: 'Success Delete Movie From Watch List.',
data: {
deletedMovie: result
}
data: NULL
})
}
})
}


Expand All @@ -87,6 +83,10 @@ deleteShowFromWatchList = (req, res, next) => {
let showID = req.params.showID;
user.deleteShowFromWatchList(userID, showID, result => {
//res.json(result);
res.status(204).json({
status: 'Success Delete Show From Watch List.',
data: NULL
})
})
}

Expand All @@ -110,6 +110,10 @@ deleteShowFromWatchedList = (req, res, next) => {
let showID = req.params.showID;
user.deleteShowFromWatchedList(userID, showID, result => {
//res.json(result);
res.status(204).json({
status: 'Success Delete Show From Watched List.',
data: NULL
})
})
}

Expand Down
30 changes: 30 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"express": "^4.17.1",
"express-session": "^1.17.0",
"mongoose": "^5.8.3",
"morgan": "^1.9.1",
"node": "^13.5.0",
"validator": "^12.1.0"
},
Expand Down
8 changes: 4 additions & 4 deletions routes/userRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ const userController = require("../controllers/UsersController")
router.patch("/movie/add/watchlist/:userID", userController.addMovieToWatchList);
// @DELETE
// Remove movie from watch list.
router.patch("/movie/delete/watchlist/:userID/:movieID", userController.deleteMovieFromWatchList);
router.delete("/movie/delete/watchlist/:userID/:movieID", userController.deleteMovieFromWatchList);
// @PUT
// Add movie to watched list.
router.patch("/movie/add/watchedlist/:userID", userController.addMovieToWatchedList);
// @DELETE
// Remove movie from watched list.
router.patch("/movie/delete/watchedlist/:userID/:movieID", userController.deleteMovieFromWatchedList);
router.delete("/movie/delete/watchedlist/:userID/:movieID", userController.deleteMovieFromWatchedList);

// TV SHOW ROUTES. **************************************************************
// @PUT
// Add TvShow to watch list.
router.patch("/show/add/watchlist/:userID", userController.addShowToWatchList);
// @DELETE
// Remove TvShow from watch list.
router.patch("/show/delete/watchlist/:userID/:showID", userController.deleteShowFromWatchList);
router.delete("/show/delete/watchlist/:userID/:showID", userController.deleteShowFromWatchList);
// @PUT
// Add TvShow to watched list.
router.patch("/show/add/watchedlist/:userID", userController.addShowToWatchedList);
// @DELETE
// Remove TvShow from watched list.
router.patch("/show/add/watchedlist/:userID/:showID", userController.deleteShowFromWatchedList);
router.delete("/show/add/watchedlist/:userID/:showID", userController.deleteShowFromWatchedList);

module.exports = router;
4 changes: 4 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const MONGODB_URI = 'mongodb+srv://mohamad:[email protected]
const cors = require("cors");
const bodyParser = require('body-parser');
const express = require("express");
const morgan = require("morgan");
// Call EXPRESS method and store it in 'app' variable.
const app = express();

Expand All @@ -14,6 +15,7 @@ app.use(cors());
// Middleware function to use 'req' parameters.
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(morgan('dev'));

// Import routes.
const moviesRoutes = require("./routes/moviesRoutes.js");
Expand Down Expand Up @@ -43,5 +45,7 @@ app.use(session({
store: mongoStore
}));


// Start Server.
const PORT = process.env.PORT || 9000;
app.listen(PORT, () => console.log(`Server listening to ${PORT} ^.^ ******`));

0 comments on commit a4cbb34

Please sign in to comment.