From 2818cea166720ae29fcb977fd17ddf50854497f6 Mon Sep 17 00:00:00 2001 From: mohammedsalah7 Date: Wed, 27 Oct 2021 00:19:28 +0300 Subject: [PATCH 1/3] create end point to log out #16 --- server/controllers/index.js | 3 ++- server/controllers/logout.js | 5 +++++ server/routes/index.js | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 server/controllers/logout.js diff --git a/server/controllers/index.js b/server/controllers/index.js index b158217..7713304 100644 --- a/server/controllers/index.js +++ b/server/controllers/index.js @@ -1,3 +1,4 @@ const getAllUsers = require('./users/getAllUsers'); +const logout = require('./logout'); -module.exports = { getAllUsers }; +module.exports = { getAllUsers, logout }; diff --git a/server/controllers/logout.js b/server/controllers/logout.js new file mode 100644 index 0000000..c497d9e --- /dev/null +++ b/server/controllers/logout.js @@ -0,0 +1,5 @@ +const logout = (req, res) => { + res.clearCookie('token'); + res.json({ message: 'logged out Succefully' }); +}; +module.exports = logout; diff --git a/server/routes/index.js b/server/routes/index.js index 0c66e24..08068d6 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -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); From 57615cf01d08bf7e17b0768a321bf847894050bd Mon Sep 17 00:00:00 2001 From: mohammedsalah7 Date: Wed, 27 Oct 2021 10:16:57 +0300 Subject: [PATCH 2/3] edit require Router #16 --- server/routes/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/server/routes/index.js b/server/routes/index.js index 08068d6..fc6af5b 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -1,9 +1,7 @@ -const express = require('express'); +const router = require('express').Router(); const { notFoundError, serverError } = require('../controllers/errors'); const { getAllUsers, logout } = require('../controllers'); -const router = express.Router(); - router.get('/users', getAllUsers); router.get('/logout', logout); router.use(notFoundError); From f0729c414edbd314a652bfd9547165abb838d737 Mon Sep 17 00:00:00 2001 From: Muhammad Abdulhadi Date: Wed, 27 Oct 2021 15:16:08 +0300 Subject: [PATCH 3/3] edit project name --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b7d5949..eed6e3b 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "Housy", + "name": "housy", "version": "1.0.0", "description": "", "main": "index.js",