Skip to content

Commit

Permalink
resolve conflict page #12 #33 #34
Browse files Browse the repository at this point in the history
  • Loading branch information
Salam-Dalloul committed Jan 24, 2018
2 parents 8c18a09 + c20ca06 commit cd00dd8
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 16 deletions.
Binary file added public/image/error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/controllers/blogs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const view = require('../models/queries/viewBlogs.js');

exports.get = (req, res) => {
exports.get = (req, res ,next) => {
view.viewAllBlogs((dataBaseConnectionError, blog) =>{
if (dataBaseConnectionError) return res.status(500).send({ error: dataBaseConnectionError });
if (dataBaseConnectionError) return next(dataBaseConnectionError);
const newBlog = blog.map((element, i ) => {
element.mod = i%3;
return element;
Expand Down
6 changes: 6 additions & 0 deletions src/controllers/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
exports.client = (req, res) => {
res.render('404',{layout:false});
};
exports.server = (err, req, res, next) => {
res.render('500',{layout:false});
};
Empty file removed src/controllers/index.js
Empty file.
6 changes: 2 additions & 4 deletions src/controllers/men.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const viewMenFa = require('../models/queries/viewMenFashion');
const jwt = require('jsonwebtoken');

exports.get = (req, res) => {
exports.get = (req, res, next) => {
viewMenFa.viewMenFashion((dataBaseConnectionError, menFashion) => {
if (dataBaseConnectionError) {
return res.status(500).send({
error: dataBaseConnectionError,
});
return next(dataBaseConnectionError);
}
const { accessToken } = req.cookies;
if (accessToken) {
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/menOutfits.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const viewMenOutfits = require('../models/queries/viewMenOutfits');

exports.get = (req, res) => {
exports.get = (req, res ,next) => {
viewMenOutfits((dataBaseConnectionError, menOutfits) => {
if (dataBaseConnectionError) return res.status(500).send({ error: dataBaseConnectionError });
if (dataBaseConnectionError) return next(dataBaseConnectionError);
return res.render('menOutfits', {
layout: 'fashion', menOutfits, style: 'style', title: 'Men Outfits',
});
Expand Down
4 changes: 4 additions & 0 deletions src/controllers/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const menOutfits = require('./menOutfits');
const womenOutfits = require('./womenOutfits');
const saved = require('./savedFashion');
const unsaved = require('./unsaved');
const error = require('./error');

router.post('/signup', signup.post);
router.post('/loginuser', login.post);
Expand All @@ -43,5 +44,8 @@ router.get('/women-fashion', women.get);
router.get('/women-outfits', womenOutfits.get);
router.get('/men-outfits', menOutfits.get);
router.post('/unsaved', unsaved.post);
router.use(error.client);
router.use(error.server);


module.exports = router;
9 changes: 3 additions & 6 deletions src/controllers/women.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ const viewWomenFa = require('../models/queries/viewWomenFashion');
const viewMenFa = require('../models/queries/viewMenFashion');
const jwt = require('jsonwebtoken');

exports.get = (req, res) => {
exports.get = (req, res, next) => {
viewWomenFa((dataBaseConnectionError, womenFashion) => {
if (dataBaseConnectionError) {
return res.status(500).send({
error: dataBaseConnectionError,
});
}
if (dataBaseConnectionError) return next(dataBaseConnectionError);
const { accessToken } = req.cookies;
if (accessToken) {
const verifyCookie = jwt.verify(accessToken, process.env.SECRET_COOKIE);
Expand All @@ -31,5 +27,6 @@ exports.get = (req, res) => {
});
}
}
return null;
});
};
4 changes: 2 additions & 2 deletions src/controllers/womenOutfits.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const viewWomenOutfits = require('../models/queries/viewWomenOutfits');

exports.get = (req, res) => {
exports.get = (req, res, next) => {
viewWomenOutfits((dataBaseConnectionError, womenOutfits) => {
if (dataBaseConnectionError) return res.status(500).send({ error: dataBaseConnectionError });
if (dataBaseConnectionError) return next(dataBaseConnectionError);
return res.render('womenOutfits', {
layout: 'fashion', womenOutfits, style: 'style', title: 'Women Outfits',
});
Expand Down
15 changes: 15 additions & 0 deletions src/views/404.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<main class="main">
<center>
<h2 class="error__desc">404. Page Not Found</2>
<br>
<a href="/" style="
text-decoration: none;
color:red;">
<h4>Go back! at the home page</h4>
</a>
<section class="error">
<img class="error__image" src="./image/error.png" alt="error">
</section>
</center>

</main>
11 changes: 11 additions & 0 deletions src/views/500.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<main class="main">
<section class="error">
<a href="/" style="
text-decoration: none;
color:red;">
<h4>Go back! at the home page</h4>
</a>
<p class="error__desc">500. <span class="error__msg">Internal server error</span></p>
<img class="error__image" src="./image/error.png" alt="error">
</section>
</main>

0 comments on commit cd00dd8

Please sign in to comment.