Skip to content

Commit

Permalink
create end point to log out #16
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammedsalah7 committed Oct 26, 2021
1 parent 44a0802 commit 2818cea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion server/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const getAllUsers = require('./users/getAllUsers');
const logout = require('./logout');

module.exports = { getAllUsers };
module.exports = { getAllUsers, logout };
5 changes: 5 additions & 0 deletions server/controllers/logout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const logout = (req, res) => {
res.clearCookie('token');
res.json({ message: 'logged out Succefully' });
};
module.exports = logout;
3 changes: 2 additions & 1 deletion server/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const express = require('express');
const { notFoundError, serverError } = require('../controllers/errors');
const { getAllUsers } = require('../controllers');
const { getAllUsers, logout } = require('../controllers');

const router = express.Router();

router.get('/users', getAllUsers);
router.get('/logout', logout);
router.use(notFoundError);
router.use(serverError);

Expand Down

0 comments on commit 2818cea

Please sign in to comment.