-
Notifications
You must be signed in to change notification settings - Fork 0
/
api-routes.js
54 lines (48 loc) · 2.56 KB
/
api-routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
let router = require('express').Router();
let jwt = require('jsonwebtoken')
let config = require('./config')
let User = require('./models/userModel');
router.get('/', function (req, res) {
res.json({
status: 'API Its Working',
message: 'Welcome to RESTHub crafted with love!'
});
});
// Import controllers
const userController = require('./controllers/userController');
const signupController = require('./controllers/signupController');
const loginController = require('./controllers/loginController');
const logoutController = require('./controllers/logoutController');
const userProfileController = require('./controllers/userProfileController');
const emailVerificationController = require('./controllers/emailVerificationController');
const forgetPasswordController = require('./controllers/forgetPassswordController');
const commentController = require('./controllers/commentController');
// Contact routes
router.route('/message').get((req,res)=> {
res.send('Hello');
});
router.route('/users').get(userController.index);
//router.route('/users/signup').post(signupController.signup);
router.post('/users/signup',signupController.validateSignupInput,signupController.signup);
router.route('/confirmation/:token').get(emailVerificationController.verifyEmail); // verify email after signup
router.post('/users/login',loginController.validateLoginInput,loginController.login);
router.post('/forgetpassword',forgetPasswordController.validateForgetPasswordInput,forgetPasswordController.forgetPassword);
router.route('/redirect-password-change/:token').get(forgetPasswordController.redirectPasswordChange);
router.route('/changepassword').post(forgetPasswordController.changePassword);
//router.route('/users/login').post(loginController.login);
router.route('/users/logout').get(logoutController.logout);
router.route('/users/favoriteIDs').get(userProfileController.favoriteIDs);
router.route('/users/favorites').get(userProfileController.favorites);
router.route('/users/addfavorite').post(userProfileController.addFavorite);
router.route('/users/favorites/remove').delete(userProfileController.removeFromFavorites);
router.route('/comments').get(commentController.getComments);
router.post('/user/make-comment',commentController.validateMakeCommentInput,commentController.makeComment);
router.route('/movie/comments/:movieId').get(commentController.getMovieComments);
/*
router.route('/users/:user_id')
.get(userController.view)
.patch(userController.update)
.put(userController.update)
.delete(userController.delete); */
// Export API routes
module.exports = router;