Skip to content

Commit

Permalink
Merge pull request #15 from GSG-G7/handle-routes
Browse files Browse the repository at this point in the history
Handle routes
  • Loading branch information
SajedaIsmail authored Aug 27, 2019
2 parents 5b55ee6 + 78821b9 commit d751fa4
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 7 deletions.
7 changes: 7 additions & 0 deletions server/controllers/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exports.clientError = (req, res) => {
res.status(404).render('clientError');
};

exports.serverError = (err, req, res, next) => {
res.status(500).render('serverError');
};
28 changes: 28 additions & 0 deletions server/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
const router = require('express').Router();
const { clientError, serverError } = require('./error');

router.get('/', (req, res) => {
res.render('home');
});

router.get('/login', (req, res) => {
res.render('login');
});

router.post('/login-data', (req, res) => {
console.log(req.body);
res.redirect('/posts');
});

router.get('/signup', (req, res) => {
res.render('signup');
});

router.post('/signup-data', (req, res) => {
console.log(req.body);
res.redirect('/posts');
});

router.get('/profile', (req, res) => {
res.render('profile');
});
router.get('/posts', (req, res) => {
res.render('posts');
});

router.use(clientError);
router.use(serverError);
module.exports = router;
2 changes: 1 addition & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
const app = require('./app');

const port = app.get('port');
app.listen(port,()=> {
app.listen(port, () => {
console.log(`your server is up to http://localhost:${port}`);
})
2 changes: 1 addition & 1 deletion server/views/home.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h1 class="home__heading">Home Title Here...</h1>
<p class="home__paragraph">Lorem, ipsum dolor sit amet consectetur adipisicing elit. Corrupti dignissimos
distinctio quae labore velit harum ipsum deleniti error eligendi consequuntur?</p>
<a href="#" class="home__signup">Sign Up</a>
<a href="/signup" class="home__signup">Sign Up</a>
</section>
</section>
{{> footer}}
2 changes: 1 addition & 1 deletion server/views/login.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{> header}}

<section class="login">
<form action="" class="login__form">
<form action="/login-data" method="post" class="login__form">
<input type="email" name="email" class="login__email" placeholder="Enter Your Email">
<input type="password" name="password" class="login__password" placeholder="Enter Your password">
<input type="submit" name="submit" value="Login" class="login__button">
Expand Down
2 changes: 1 addition & 1 deletion server/views/partials/header.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<header class="header">
<div class="header__logo">LOGO</div>
<a href="#" class="header__login">Login</a>
<a href="/login" class="header__login">Login</a>
</header>
2 changes: 1 addition & 1 deletion server/views/allTweet.hbs → server/views/posts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="header__list">
<a>Username</a>
<ul>
<li><a>profile</a></li>
<li><a href="/profile">profile</a></li>
<li><a>logout</a></li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion server/views/profile.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<nav class="header__nav">
<div class="header__logo">LOGO</div>
<div>
<a href="#" class="header__home">Home</a>
<a href="/posts" class="header__home">Home</a>
</div>
<div class="header__list">
<a>Username</a>
Expand Down
5 changes: 4 additions & 1 deletion server/views/signup.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{> header}}

<section class="Signup">
<form action="" class="Signup__form">
<form action="/signup-data" method="POST" class="Signup__form">
<input type="text" name="username" class="Signup__username" placeholder="Enter Your Username">
<input type="email" name="email" class="Signup__email" placeholder="Enter Your Email">
<input type="password" name="password" class="Signup__password" placeholder="Enter Your password">
Expand All @@ -11,7 +11,10 @@
<option value="Female">Female</option>
</select>
<input type="date" name="date" class="Signup__date" placeholder="Enter Your birthday">
<input type="text" name="country" class="country" placeholder="Enter Your country">
<input type="text" name="bio" class="bio" placeholder="Enter your bio">
<input type="submit" name="submit" value="Signup" class="Signup__button">

</form>
</section>

Expand Down

0 comments on commit d751fa4

Please sign in to comment.