Skip to content

Commit

Permalink
error fix for API, project eplorer
Browse files Browse the repository at this point in the history
  • Loading branch information
iamrahimi committed Jan 20, 2025
1 parent c2c46f7 commit a630af9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const authenticateToken = require('./middlewares/authMiddleware');

app.use('/api/v1', authRouter);
app.use('/api/v1', userRouter);
app.use('/api/v1', authenticateToken, mainRouter);
app.use('/api/v1', mainRouter);
app.use('/api/v1', authenticateToken, projectRouter);


Expand Down
3 changes: 2 additions & 1 deletion src/controllers/projectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ const projectController = {
parseInt(user_id, 10),
parseInt(project_id, 10)
);
return res.status(200).json(result);
}else {
return res.status(405).json({
success: false,
Expand All @@ -262,7 +263,7 @@ const projectController = {
}


return res.status(200).json(result);

} catch (error) {
return res.status(500).json({
success: false,
Expand Down
4 changes: 2 additions & 2 deletions src/routes/authRouter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const express = require('express');
const { loginUser } = require('../services/authService');
const { forgotPassword, resetPassword, changePassword } = require('../controllers/authController');
const { forgotPassword, resetPassword } = require('../controllers/authController');


const router = express.Router();

Expand Down Expand Up @@ -40,7 +41,6 @@ router.post('/logout', async (req, res) => {
});

router.post('/forgot-password', forgotPassword);
router.get('/change-password/:token', changePassword);
router.post('/reset-password/:token', resetPassword);

module.exports = router;
10 changes: 8 additions & 2 deletions src/routes/mainRouter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
const express = require('express');
const router = express.Router();
const mainController = require('../controllers/mainController.js');
const projectController = require('../controllers/projectController');

router.get('/', mainController.get);

router.get('/projects', projectController.getAllProjects); // Endpoint to get all projects
router.get('/projects/:id', projectController.getProjectById); // Endpoint to get a specific project by ID
router.get('/dashboard', projectController.dashboard); // endpoint for getting total project, comments and users.
router.get('/projects/:id', projectController.getProjectById); // Endpoint to get a specific project by ID
router.get('/comments/:project_id', projectController.getCommentsByProjectId); // Endpoint to get all comments for a specific project
router.get('/likes/:project_id', projectController.getLikesByProjectId); //Endpoint for get all likes for a specific project

module.exports = router;
9 changes: 4 additions & 5 deletions src/routes/projectRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ const express = require('express');
const router = express.Router();
const projectController = require('../controllers/projectController');

router.get('/dashboard', projectController.dashboard); // endpoint for getting total project, comments and users.
router.get('/projects', projectController.getAllProjects); // Endpoint to get all projects
router.get('/projects/:id', projectController.getProjectById); // Endpoint to get a specific project by ID



router.post('/addproject', projectController.addProject); // Endpoint to add a new project
router.put('/updateproject/:project_id', projectController.updateProject); // Endpoint to update a project
router.get('/userprojects/', projectController.getProjectsByUser); // Endpoint to get all projects by a specific user
router.post('/addcomment/:project_id', projectController.addComment); // Endpoint to add a comment to a project
router.get('/comments/:project_id', projectController.getCommentsByProjectId); // Endpoint to get all comments for a specific project
router.delete("/deleteproject/:project_id", projectController.deleteProject); // Endpoint to delete a project
router.post('/addlike/:project_id', projectController.addLike); // Endpoint to add a like to a project
router.delete('/removelike/:project_id', projectController.removeLike); // Endpoint to delete a like from the project
router.get('/likes/:project_id', projectController.getLikesByProjectId); //Endpoint for get all likes for a specific project


module.exports = router;

0 comments on commit a630af9

Please sign in to comment.