Continued working on the final project in the web security section of the Node.js
course from The Odin Project. I worked on building out the post controller that handles the submission data from the “Add Message” form. I had to review and look at some of the other projects I have built to reference how I should sanitize the data. I found the express-validator
package and decided to use that again. Everything went fairly smooth although I did have some doubts. I was really tempted to look into the package details again to get a better understanding but opted to focus on finishing the project. I really have to keep myself disciplined or I will be stuck on the same project for the rest of the year LOL.
Overall, I am actually really excited about my work. I seem to be handling everything well. When I get an error I am able to recognize and make the appropriate changes to solve the problem. I genuinely feel like I am getting better and more comfortable working in the backend and especially with all the various topics. I still have a lot to learn and a whole lot more experience to gain but I don’t feel like a fraud anymore. I feel like I have some genuine claim to saying I am familiar with the backend. I hope I continue to have this feeling but when I meet some super talented devs, I am sure the imposter syndrome will start to come back in full force LOL. For now, I will just keep working.
TLDR;
Okay, so here are the highlights of what I did:
- Backend -> Continued working on the Members Only Project from the web security section. Finished building out the message functionality. Now the home page displays messages as they should. I now need to add the admin and membership features and then I will be done. Step by step I’m making progress!
Add Message Controller Updated
const Message = require('../../models/Message')
const { body, validationResult } = require('express-validator')
exports.getAddMessagePage = [
(req, res, next) => {
// if the User is logged in...
if (req.session && req.session.passport && req.session.passport.user)
res.render('add-message')
// User not logged in, therfore...
else {
const err = new Error('User must be logged in to access this page.');
err.status = 401
err.message = 'User is not authorized to access this page. User must be logged in to access this page. <a href="/login">Login Here.</a>'
return next(err)
}
}
]
exports.postAddMessagePage = [
body('title', 'Title must not be empty.').trim().isLength({ min: 1 }).escape(),
body('text', 'Text must not be empty.').trim().isLength({ min: 1 }).escape(),
(req, res, next) => {
const errors = validationResult(req)
const {title, text} = req.body
// Reload page on error with previous values
if (!errors.isEmpty()) {
res.render('add-message', {title, text} )
return
}
else {
const message = new Message({
title,
text,
author: req.user._id
})
message.save((err) => {
if (err) return next(err)
//successful - redirect to new book record.
res.redirect('/')
})
return
}
}
]
Goal For Round 8 of the #100DaysofCode Challenge
This is my eighth round of the “#100daysofcode” challenge. I will be continuing my work from round five, six, and seven into round eight. I was working through the book “Cracking the Coding Interview” by Gayle Laakmann McDowell. My goal was to become more familiar with algorithms and data structures. This goal was derived from my goal to better understand operating systems and key programs that I use in the terminal regularly e.g. Git. This goal was in turn derived from my desire to better understand the fundamental tools used for coding outside of popular GUIs. This in turn was derived from my desire to be a better back-end developer.
I am currently putting a pause on the algorithm work to build some backend/full stack projects. I primarily want to improve my skills with the back-end from an implementation perspective. I have improved tremendously in terminal and CLI skills but I lost focus due to how abstract the algorithm concepts got. I wanted to work on things that were more tangible until I can get to a position where I could directly benefit from improving my algorithm skills and theoretical knowledge. So that’s the focus right now. Build my backend skills and prove my full stack capabilities by building some dope projects.
Again, I still have no idea if my path is correct but I am walking down this road anyways. Worst case scenario I learn a whole bunch of stuff that will help me out on my own personal projects. Best case scenario I actually become one of those unicorn developers that go on to start a billion dollar company… You never know LOL.