Skip to content

Commit

Permalink
feat: adding insert and select queries, reading the user login input …
Browse files Browse the repository at this point in the history
…and check in the data base. chore:adding body-parser module. fix:fix some bugs in hbs and app file
  • Loading branch information
MohammedYehia committed May 2, 2018
1 parent d25cb09 commit 1b3b676
Show file tree
Hide file tree
Showing 13 changed files with 197 additions and 90 deletions.
152 changes: 76 additions & 76 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"homepage": "https://github.com/FACG4/chat#readme",
"dependencies": {
"body-parser": "^1.18.2",
"env2": "^2.2.0",
"express": "^4.16.3",
"express-handlebars": "^3.0.0",
Expand Down
8 changes: 7 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
const express = require("express");
const favicon = require("serve-favicon");
const exphbs = require("express-handlebars");
const bodyParser = require('body-parser');
const app = express();
const controllers = require("./controllers/index");
const helpers = require("./views/helpers/index");
const path = require("path");


app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

app.set("views", path.join(__dirname, "views"));
app.set("view engine", "hbs");
app.set("port", process.env.PORT || 3000);
app.use(favicon(path.join(__dirname, "..", "public", "favicon.ico")));
app.use(express.static(path.join(__dirname, "..", "public")));
app.use(express.static("public"));
// app.use('/user/Israa',express.static(path.join(__dirname,"..", "public")));
app.use(controllers);

app.engine(
Expand Down
15 changes: 12 additions & 3 deletions src/controllers/home.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
const select = require('../model/queries/select');




exports.get = (req, res) => {
res.render("home", {
title: "Chat"
});
select.selectUserData({username:'Israa', password:123}, (err,result)=>{
if(err) console.log(err);
res.render("home", {
title: "Chat",
data: result.rows[0]
});
})
};
2 changes: 2 additions & 0 deletions src/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const signup = require("./signup");
const login = require("./login");
router.get("/", home.get);
router.get("/login", login.get);
router.post("/login", login.post);
router.get("/signup", signup.get);
router.get("/user/:name", home.get);

module.exports = router;
Loading

0 comments on commit 1b3b676

Please sign in to comment.