├── .gitignore
├── src
├── public
│ ├── img
│ │ ├── bg.jpg
│ │ └── logo.png
│ ├── js
│ │ └── index.js
│ └── css
│ │ └── style.css
├── keys.js
├── lib
│ ├── handlebars.js
│ ├── authentication.js
│ ├── bcrypt.js
│ └── passport.js
├── routes
│ ├── index.js
│ ├── authentication.js
│ ├── contacts.js
│ └── api.js
├── views
│ ├── index.hbs
│ ├── profile.hbs
│ ├── contacts
│ │ ├── add.hbs
│ │ ├── edit.hbs
│ │ └── list.hbs
│ ├── authentication
│ │ ├── signin.hbs
│ │ └── signup.hbs
│ ├── partials
│ │ ├── message.hbs
│ │ └── nav.hbs
│ └── layouts
│ │ └── main.hbs
├── database.js
└── index.js
├── README.md
├── database
└── db.sql
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/src/public/img/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/antoniosarosi/Contacts-App-Nodejs/HEAD/src/public/img/bg.jpg
--------------------------------------------------------------------------------
/src/public/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/antoniosarosi/Contacts-App-Nodejs/HEAD/src/public/img/logo.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Contacts App
2 |
3 | ## Local Setup
4 |
5 | ```bash
6 | npm init
7 | npm run dev
8 | ```
9 |
10 | ## Database
11 |
12 | Copy SQL from **/database/db.sql**
--------------------------------------------------------------------------------
/src/keys.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | database: {
3 | host: 'localhost',
4 | user: 'antonio',
5 | password: 'admin',
6 | database: 'contacts'
7 | }
8 | };
--------------------------------------------------------------------------------
/src/lib/handlebars.js:
--------------------------------------------------------------------------------
1 | const { format } = require('timeago.js');
2 |
3 | const helpers = {};
4 |
5 | helpers.timeago = (timestamp) => {
6 | return format(timestamp);
7 | };
8 |
9 | module.exports = helpers;
--------------------------------------------------------------------------------
/src/routes/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 |
4 | router.get('/', (req, res) => {
5 | res.render('index', { index: true });
6 | });
7 |
8 | module.exports = router;
--------------------------------------------------------------------------------
/src/public/js/index.js:
--------------------------------------------------------------------------------
1 | document.addEventListener('DOMContentLoaded', () => {
2 |
3 | // Don't show overflow on index page
4 | function removeOverflow() {
5 | document.body.style.overflow = 'hidden';
6 | }
7 |
8 | removeOverflow();
9 | window.addEventListener('resize', removeOverflow);
10 | });
--------------------------------------------------------------------------------
/src/views/index.hbs:
--------------------------------------------------------------------------------
1 |
{{number}}
11 |{{timeago created_at}}
12 | Edit Contact 13 | Delete Contact 14 |No contacts saved yet
21 | Add One! 22 |