- Alex
- Ayub
- Pat
- Roshan
- Clone the repo
- In the root directory, create a .env file with the PostgreSQL URL DB_URL
- To build the database npm run db_init
- npm start
- In browser open localhost:2262
- Build an app using the Express framework.
- Use a PostgreSQL database to store and retrieve your data.
- Use the retrieved data to populate a Handlebars template for server-side rendering to be displayed on the front-end.
Stretch Goals
- Authorisation (editing to header partial for when logged in vs not)
- Animated svg
//goodBad.js
module.exports = array => {
const totalGoodPoints = array.reduce((acc, currNum) => {
return acc + parseInt(currNum);
}, 0);
return totalGoodPoints;
};
{{#each users}}
<tr>
<td> {{capitaliseFirstLetter name}} </td>
<td> {{gift}} </td>
<td> {{goodBad behaviour}} </td>
<td><a href="/delete-user/{{name}}"><button id="delete-button">X</button></a></td>
</tr>
{{/each}}
const deleteUserData = require("../model/queries/deleteData");
exports.deleteUser = (req, res) => {
const nameUser = req.params.name;
deleteUserData(nameUser)
.then(() => {
res.redirect("/presents");
})
.catch(err => {
console.log("this is err", err.message);
throw err;
});
};
exports.client = (req, res) => {
res.status(404).render("error", {
layout: "error",
statusCode: 404,
errorMessage: "Page not found :(",
imageUrl: "https://gph.is/2ify9JA"
});
};
postData({
name: req.body.username,
behaviour: goodOrBad,
category: req.body.category
})
.then(() => {
res.redirect("/presents");
})
.catch(error => {
throw error;
});