diff --git a/controllers/users.js b/controllers/users.js index a3573b3..45a0061 100644 --- a/controllers/users.js +++ b/controllers/users.js @@ -9,53 +9,53 @@ const User = require('../db/models/User'); // GET /signup router.get('/signup', (req, res) => { - res.render('signup.hbs', { message: req.flash('signupMessage') }); + res.render('signup.hbs', { message: req.flash('signupMessage') }); }); // POST /signup router.post('/signup', (req, res) => { - var signupStrategy = passport.authenticate('local-signup', { - successRedirect: '/users/' + req.body.email, - failureRedirect: '/users/signup', - failureFlash: true - }); + var signupStrategy = passport.authenticate('local-signup', { + successRedirect: '/users/' + req.body.email, + failureRedirect: '/users/signup', + failureFlash: true + }); - return signupStrategy(req, res); + return signupStrategy(req, res); }); // GET /login router.get('/login', (req, res) => { - res.render('login.hbs', { message: req.flash('loginMessage') }); + res.render('login.hbs', { message: req.flash('loginMessage') }); }); // POST /login router.post('/login', (req, res) => { - var loginProperty = passport.authenticate('local-login', { - successRedirect: '/users/' + req.body.email, - failureRedirect: '/users/login', - failureFlash: true - }); + var loginProperty = passport.authenticate('local-login', { + successRedirect: '/users/' + req.body.email, + failureRedirect: '/users/login', + failureFlash: true + }); - return loginProperty(req, res); + return loginProperty(req, res); }); // GET /logout router.get('/logout', (req, res) => { - req.logout(); - res.redirect('/'); + req.logout(); + res.redirect('/'); }); //GET create page router.get('/create/', (req, res) => { - res.render('create'); + res.render('create'); }); // Restricted page create/update/delete functionality router.get('/:email', (req, res) => { - User.findOne({ email: req.params.email }).then(res.render('userhome')); + User.findOne({ email: req.params.email }).then(res.render('userhome')); }); router.get('/', (req, res) => { - res.render('userhome'); + res.render('userhome'); }); module.exports = router; diff --git a/db/cheerup-seed.json b/db/cheerup-seed.json index 88ec351..016ef0f 100644 --- a/db/cheerup-seed.json +++ b/db/cheerup-seed.json @@ -1,44 +1,44 @@ [ - { - "body": "you are more beloved than you know." - }, - { - "body": "the world is your oyster." - }, - { - "body": "it's okay to not be the best at something." - }, - { - "body": "your best is good enough." - }, - { - "body": "you have the courage and strength to keep going." - }, - { - "body": "be as kind to yourself as you are to others." - }, - { - "body": "i'm proud of you and everything is going to be great." - }, - { - "body": "you are smart. you are kind. you are important." - }, - { - "body": "nothing good comes fast or easy." - }, - { - "body": "there is nobody else in the world like you." - }, - { - "body": "you are amazing. own that shit." - }, - { - "body": "on the other side of the clouds is a bright blue sky." - }, - { - "body": "forget all of the reasons that it won't work and believe the one reason why it will." - }, - { - "body": "you are divine perfection." - } + { + "body": "you are more beloved than you know." + }, + { + "body": "the world is your oyster." + }, + { + "body": "it's okay to not be the best at something." + }, + { + "body": "your best is good enough." + }, + { + "body": "you have the courage and strength to keep going." + }, + { + "body": "be as kind to yourself as you are to others." + }, + { + "body": "i'm proud of you and everything is going to be great." + }, + { + "body": "you are smart. you are kind. you are important." + }, + { + "body": "nothing good comes fast or easy." + }, + { + "body": "there is nobody else in the world like you." + }, + { + "body": "you are amazing. own that shit." + }, + { + "body": "on the other side of the clouds is a bright blue sky." + }, + { + "body": "forget all of the reasons that it won't work and believe the one reason why it will." + }, + { + "body": "you are divine perfection." + } ] diff --git a/db/connection.js b/db/connection.js index 013df23..25add9a 100644 --- a/db/connection.js +++ b/db/connection.js @@ -10,18 +10,18 @@ mongoose.Promise = Promise; // const mongoURI = "mongodb://localhost/book-e"; let mongoURI = ''; if (process.env.NODE_ENV === 'production') { - mongoURI = process.env.DB_URL; + mongoURI = process.env.DB_URL; } else { - mongoURI = 'mongodb://localhost/cheerup'; + mongoURI = 'mongodb://localhost/cheerup'; } // connect to the database, with the imported mongoose instance mongoose - .connect(mongoURI, { useNewUrlParser: true }) - .then(instance => - console.log(`Connected to db: ${instance.connections[0].name}`) - ) - .catch(error => console.log('Connection failed!', error)); + .connect(mongoURI, { useNewUrlParser: true }) + .then(instance => + console.log(`Connected to db: ${instance.connections[0].name}`) + ) + .catch(error => console.log('Connection failed!', error)); // now, our mongoose instance has a configured connection to our local db, in addition // to its model configuration diff --git a/db/models/Cheerup.js b/db/models/Cheerup.js index 5e26969..415c654 100644 --- a/db/models/Cheerup.js +++ b/db/models/Cheerup.js @@ -1,24 +1,24 @@ const mongoose = require('../connection'); const CheerupSchema = new mongoose.Schema({ - body: { - type: String, - required: true - }, - likedBy: [ - { - ref: 'User', - type: mongoose.Schema.Types.ObjectId, - required: false - } - ], - createdBy: [ - { - ref: 'User', - type: mongoose.Schema.Types.ObjectId, - required: false - } - ] + body: { + type: String, + required: true + }, + likedBy: [ + { + ref: 'User', + type: mongoose.Schema.Types.ObjectId, + required: false + } + ], + createdBy: [ + { + ref: 'User', + type: mongoose.Schema.Types.ObjectId, + required: false + } + ] }); const Cheerup = mongoose.model('Cheerup', CheerupSchema); diff --git a/db/models/User.js b/db/models/User.js index 30bc0dc..a9ec487 100644 --- a/db/models/User.js +++ b/db/models/User.js @@ -2,32 +2,32 @@ const mongoose = require('../connection.js'); const bcrypt = require('bcrypt-nodejs'); const UserSchema = mongoose.Schema({ - local: { - email: String, - password: String - }, - likes: [ - { - ref: 'Cheerup', - type: mongoose.Schema.Types.ObjectId, - required: false - } - ], - userCreated: [ - { - ref: 'Cheerup', - type: mongoose.Schema.Types.ObjectId, - required: false - } - ] + local: { + email: String, + password: String + }, + likes: [ + { + ref: 'Cheerup', + type: mongoose.Schema.Types.ObjectId, + required: false + } + ], + userCreated: [ + { + ref: 'Cheerup', + type: mongoose.Schema.Types.ObjectId, + required: false + } + ] }); UserSchema.methods.encrypt = function(password) { - return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null); + return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null); }; UserSchema.methods.validPassword = function(password) { - return bcrypt.compareSync(password, this.local.password); + return bcrypt.compareSync(password, this.local.password); }; module.exports = mongoose.model('User', UserSchema); diff --git a/db/seed.js b/db/seed.js index 702d9a1..bc7e05a 100644 --- a/db/seed.js +++ b/db/seed.js @@ -7,12 +7,12 @@ const cheerupSeeds = require('./cheerup-seed.json'); //clear db of cheerup seeds Cheerup.deleteMany({}) - .then(() => { - console.log('deleted all cheerups'); - return Cheerup.insertMany(cheerupSeeds); - }) - .then(() => { - console.log('inserted cheerup seeds'); - process.exit(); - }) - .catch(err => console.error(err)); + .then(() => { + console.log('deleted all cheerups'); + return Cheerup.insertMany(cheerupSeeds); + }) + .then(() => { + console.log('inserted cheerup seeds'); + process.exit(); + }) + .catch(err => console.error(err)); diff --git a/esin-feedback.md b/esin-feedback.md new file mode 100644 index 0000000..1c34962 --- /dev/null +++ b/esin-feedback.md @@ -0,0 +1,42 @@ +# Feedback + +See https://git.generalassemb.ly/seir-826/project-2/blob/master/evaluation.md for description of rubric. + +## Technical Requirements - Excelling + +Includes many well-structured models, and advanced functionality such as authorization, 3rd-party API integration, or other technology not covered in class + +- Great job incorporating Passport into your app on top of the CRUD functionality! +- Awesome job creating js logic to limit the number of characters to 140 characters in your cheerup! + +## Creativity and Interface - Excelling + +The app is fully responsive, incorporates CSS technologies like Grid & Flexbox. App incorporates modern UI themes, and/or adds unique flair. + +- Your app looks really professional and refined! I thought the overall design was really awesome (especially the fonts and color palette that you picked)! +- Your app looks amazing on mobile as well! + +## Code Quality - Excelling + +No major code quality issues, makes use of JS best practices appropriately, and follows techniques such as separation of concerns, abstraction, and encapsulation + +- Make sure to remove any unused code from your HTML/JS/CSS files! There's some commented out code in your HTML file that can be removed. +- Make sure to use `let` instead of `var` in your js code. +- Consider breaking up your large CSS file into separate CSS files + +## Functionality - Excelling + +App has advanced functionality that works with minimal errors, and may make use of advanced tools such as APIs, plugins, etc. + +- Passport!!! Wooot! + +## Planning/Process/Submission - Performing + +Submission contains clear evidence of planning, adequate documentation, include all from previous category, as well as additional information such as unsolved issues. Submission includes a readme and planning directory. + +- Your readme is also informative! I thought the format made a lot of sense and was easy to understand. + +## Additional Feedback + +- Take a look at some of my inline comments on your code. +- Take a look at how I've used the prettier VSCode plugin to automatically clean up your code formatting! diff --git a/index.js b/index.js index 21b4ca6..36d3e60 100644 --- a/index.js +++ b/index.js @@ -32,9 +32,9 @@ app.use(passport.initialize()); app.use(passport.session()); app.use(function(req, res, next) { - console.log(req.user); - res.locals.currentUser = req.user; - next(); + console.log(req.user); + res.locals.currentUser = req.user; + next(); }); //parser interprets key-value pairs in URLs @@ -48,7 +48,7 @@ app.use('/assets', express.static('public')); //redirect any requests to homepage app.get('/', (req, res) => { - res.redirect('/cheerups/'); + res.redirect('/cheerups/'); }); //hand off requests on '/users' route to users controller app.use('/users/', usersController); @@ -58,5 +58,5 @@ app.use('/cheerups/', cheerupsController); app.set('port', process.env.PORT || 8080); app.listen(app.get('port'), () => { - console.log(`✅ PORT: ${app.get('port')} 🌟`); + console.log(`✅ PORT: ${app.get('port')} 🌟`); }); diff --git a/public/css/style.css b/public/css/style.css index 3e59c06..9b39eb8 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -1,45 +1,45 @@ html, body { - max-width: 90%; - width: 900px; - margin: 0 auto; - padding: 0; - font-family: Geneva, sans-serif; - height: 100%; - position: relative; + max-width: 90%; + width: 900px; + margin: 0 auto; + padding: 0; + font-family: Geneva, sans-serif; + height: 100%; + position: relative; } header { - display: flex; - flex-direction: row; - justify-content: space-between; - margin: 15px auto; - align-items: center; + display: flex; + flex-direction: row; + justify-content: space-between; + margin: 15px auto; + align-items: center; } #page-content { - min-height: 100%; - position: relative; + min-height: 100%; + position: relative; } #hbs-body { - padding: 10px; - padding-bottom: 60px; + padding: 10px; + padding-bottom: 60px; } .a-button, .btn { - display: block; - position: absolute; - bottom: 5px; - left: 33%; - width: 155px; - margin-top: 25px; - margin-bottom: 25px; - text-align: center; - border: 2px transparent solid; - padding: 10px 20px; - background-color: white; + display: block; + position: absolute; + bottom: 5px; + left: 33%; + width: 155px; + margin-top: 25px; + margin-bottom: 25px; + text-align: center; + border: 2px transparent solid; + padding: 10px 20px; + background-color: white; } .a-button:hover, @@ -48,351 +48,351 @@ header { .create-btn:hover, #about-link:hover, #create:hover { - border: 2px black solid; - cursor: pointer; + border: 2px black solid; + cursor: pointer; } a { - color: black; - text-decoration: none; - border: 2px solid transparent; + color: black; + text-decoration: none; + border: 2px solid transparent; } h2 { - font-size: 36px; + font-size: 36px; } #noun { - font-style: italic; + font-style: italic; } .cheerup { - display: block; - position: relative; - height: 250px; - width: 65%; - padding: 30px; - margin: 70px auto; - background-color: rgba(255, 255, 255, 0.35); + display: block; + position: relative; + height: 250px; + width: 65%; + padding: 30px; + margin: 70px auto; + background-color: rgba(255, 255, 255, 0.35); } .home { - display: block; - position: relative; - height: 300px; - width: 65%; - padding: 30px; - margin: 70px auto; - background-color: rgba(255, 255, 255, 0.35); + display: block; + position: relative; + height: 300px; + width: 65%; + padding: 30px; + margin: 70px auto; + background-color: rgba(255, 255, 255, 0.35); } .signup-login { - display: block; - position: relative; - height: 350px; - width: 65%; - padding: 30px; - margin: 70px auto; - background-color: rgba(255, 255, 255, 0.35); + display: block; + position: relative; + height: 350px; + width: 65%; + padding: 30px; + margin: 70px auto; + background-color: rgba(255, 255, 255, 0.35); } .about { - display: block; - position: relative; - height: 600px; - width: 65%; - padding: 30px; - margin: 70px auto; - background-color: rgba(255, 255, 255, 0.35); + display: block; + position: relative; + height: 600px; + width: 65%; + padding: 30px; + margin: 70px auto; + background-color: rgba(255, 255, 255, 0.35); } .cheerup-text { - font-size: 32px; + font-size: 32px; } .cheerup-text a { - background-color: white; - padding: 5px; + background-color: white; + padding: 5px; } .message { - height: 15px; - margin: 10px 0; - text-align: center; + height: 15px; + margin: 10px 0; + text-align: center; } .alert { - margin: 20px 0; + margin: 20px 0; } .form-group { - padding: 5px; - width: 50%; - margin: 0 auto; + padding: 5px; + width: 50%; + margin: 0 auto; } input { - outline: none; - width: 100%; - padding: 10px; - font-size: 14px; - border: solid 2px transparent; + outline: none; + width: 100%; + padding: 10px; + font-size: 14px; + border: solid 2px transparent; } input:focus { - border: solid 2px black; + border: solid 2px black; } footer { - position: absolute; - bottom: 15px; - width: 100%; - height: 60px; - text-align: center; + position: absolute; + bottom: 15px; + width: 100%; + height: 60px; + text-align: center; } #user-home-display { - display: flex; - flex-direction: row; - align-content: center; - justify-content: space-around; - align-items: center; + display: flex; + flex-direction: row; + align-content: center; + justify-content: space-around; + align-items: center; } #create, #see-another { - border: 2px solid transparent; - height: 150px; - width: 200px; - display: flex; - flex-direction: row; - align-content: center; - justify-content: center; - align-items: center; - background-color: white; - font-size: 22px; + border: 2px solid transparent; + height: 150px; + width: 200px; + display: flex; + flex-direction: row; + align-content: center; + justify-content: center; + align-items: center; + background-color: white; + font-size: 22px; } #plus-sign { - margin: 5px; - width: 40px; - height: 40px; - background-color: rgba(0, 0, 0, 0.45); - border-radius: 50%; - font-size: 36px; - border: 2px solid black; - text-align: center; - line-height: 35px; + margin: 5px; + width: 40px; + height: 40px; + background-color: rgba(0, 0, 0, 0.45); + border-radius: 50%; + font-size: 36px; + border: 2px solid black; + text-align: center; + line-height: 35px; } .user-header { - display: flex; - flex-direction: row; - align-content: center; - justify-content: space-between; - align-items: center; + display: flex; + flex-direction: row; + align-content: center; + justify-content: space-between; + align-items: center; } .show-me-button { - display: block; - width: 165px; - margin-top: 25px; - margin-bottom: 25px; - text-align: center; - border: 2px transparent solid; - padding: 10px 20px; - background-color: white; - font-size: 12px; + display: block; + width: 165px; + margin-top: 25px; + margin-bottom: 25px; + text-align: center; + border: 2px transparent solid; + padding: 10px 20px; + background-color: white; + font-size: 12px; } .edit-controls { - margin-bottom: 30px; - display: flex; - flex-direction: row; - justify-content: flex-end; - align-items: baseline; - align-content: space-between; + margin-bottom: 30px; + display: flex; + flex-direction: row; + justify-content: flex-end; + align-items: baseline; + align-content: space-between; } #create-text { - height: 100px; - outline: none; - padding: 10px; - font-size: 14px; - border: solid 2px transparent; + height: 100px; + outline: none; + padding: 10px; + font-size: 14px; + border: solid 2px transparent; } #create-text:focus { - border: solid 2px black; + border: solid 2px black; } .create { - width: 500px; - margin: 0 auto; - display: block; + width: 500px; + margin: 0 auto; + display: block; } .create form { - display: inline-block; - margin-left: -100px; + display: inline-block; + margin-left: -100px; } .create-btn { - width: 100px; - margin: 25px 50%; - border: 2px solid transparent; + width: 100px; + margin: 25px 50%; + border: 2px solid transparent; } #delete-link input { - background: none; - width: 55px; - padding: 0px; - font-size: 16px; - margin: 0px; - outline: none; - border: none; + background: none; + width: 55px; + padding: 0px; + font-size: 16px; + margin: 0px; + outline: none; + border: none; } #delete-link:hover { - cursor: pointer; + cursor: pointer; } .edit { - width: 700px; - display: block; - margin: 0 auto; + width: 700px; + display: block; + margin: 0 auto; } @media (max-width: 825px) { - body { - max-width: 95%; - } - - header { - font-size: 80%; - } - - .user-header { - flex-direction: column; - } - - .user-header h2 { - margin: 0px; - } - - #user-home-display { - flex-direction: column; - } - - .home, - .cheerup, - .about, - .signup-login { - margin: 20px; - } - - .cheerup { - height: 325px; - } - - .form-group { - width: 180px; - margin-left: -5px; - } - .about { - height: 345px; - } - - #about-link { - padding: 1px; - } - - .about h2, - .signup-login h2 { - margin: 5px 0; - font-size: 24px; - font-weight: bold; - } - - .message { - font-size: 12px; - color: red; - } - - .about p { - font-size: 14px; - } - - .home p { - font-size: 125%; - } - - .cheerup-text { - font-size: 24px; - } - - .home h2, - .edit h2 { - font-size: 24px; - } - - .btn { - font-size: 12px; - margin-left: -30px; - } - - .a-button { - font-size: 12px; - width: 40%; - margin-left: -28px; - } - - a.show-me-button { - margin-top: 10px; - margin-bottom: 0px; - } - .edit-controls, - input#delete-link { - font-size: 11px; - } - - .edit .create-btn { - margin: 0 auto; - } - - .edit { - width: 200px; - margin: 10px; - } - - .create h2 { - font-size: 20px; - } - - .create form { - margin: 0 auto; - } - - #create-text { - width: 250px; - } - - .form-group { - font-size: 11px; - } - - .create-btn { - background-color: white; - } - - .create label, - #create-length { - font-size: 11px; - } - - footer { - font-size: 10px; - bottom: 10px; - height: 35px; - } + body { + max-width: 95%; + } + + header { + font-size: 80%; + } + + .user-header { + flex-direction: column; + } + + .user-header h2 { + margin: 0px; + } + + #user-home-display { + flex-direction: column; + } + + .home, + .cheerup, + .about, + .signup-login { + margin: 20px; + } + + .cheerup { + height: 325px; + } + + .form-group { + width: 180px; + margin-left: -5px; + } + .about { + height: 345px; + } + + #about-link { + padding: 1px; + } + + .about h2, + .signup-login h2 { + margin: 5px 0; + font-size: 24px; + font-weight: bold; + } + + .message { + font-size: 12px; + color: red; + } + + .about p { + font-size: 14px; + } + + .home p { + font-size: 125%; + } + + .cheerup-text { + font-size: 24px; + } + + .home h2, + .edit h2 { + font-size: 24px; + } + + .btn { + font-size: 12px; + margin-left: -30px; + } + + .a-button { + font-size: 12px; + width: 40%; + margin-left: -28px; + } + + a.show-me-button { + margin-top: 10px; + margin-bottom: 0px; + } + .edit-controls, + input#delete-link { + font-size: 11px; + } + + .edit .create-btn { + margin: 0 auto; + } + + .edit { + width: 200px; + margin: 10px; + } + + .create h2 { + font-size: 20px; + } + + .create form { + margin: 0 auto; + } + + #create-text { + width: 250px; + } + + .form-group { + font-size: 11px; + } + + .create-btn { + background-color: white; + } + + .create label, + #create-length { + font-size: 11px; + } + + footer { + font-size: 10px; + bottom: 10px; + height: 35px; + } }