My Voting App Feedback Please

Finally finished my voting app. There is still a lot I want to do with this, but for now it meets all the requirements, so I’m calling it done. I used the MERN stack ( Mongodb/Express/React/Node ). Any feedback would be appreciated.
App - http://the-poll-it.herokuapp.com/
Github - https://github.com/Josh5231/votingApp/

I think you put the wrong link for your app. It directs to your github account.

I suggest creating a README.md that includes a link to your app demo :slight_smile:

1 Like

Thanks for the feedback. I updated the link and added the readme.md file to the github repo.

Looks like you have CORS issue

XMLHttpRequest cannot load http://pollit-josh5231.c9users.io/newUser. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://the-poll-it.herokuapp.com’ is therefore not allowed access. The response had HTTP status code 503.

I can’t seem to sign up when first time

:expressionless: Well, it seems I was a little too excited to be done with this one and didn’t do enough testing. While fixing the bug you pointed out I found two more :fearful: Rebuilding now and I will have it redeployed here in just a few minutes. Thanks for the help.

Well it looks like there are even more bugs with the signup page :frowning: For now if you still want to look it over you can sign in with the user-name: admin and the password: admin. I will work on getting the remaining bugs out of the system tomorrow as its 2:30 in the morning here now. Again thanks for pointing these out to me.

1 Like

No worries! It’s all about learning process.

Trust me, you did a great job! My Voting app isn’t the most robust either, but I did learned a lot about RESTful concepts and authentication.

Couple things I noticed:

  • you have Discription: misspelled in your new poll
  • It would be nice to be re-directed to the poll I’ve just created instead of going back to homepage
  • more on the CSS style, but your font goes over the red bar

Thank again. I managed to get a little bit done before work today, but not much. Will get back at it when I make it home tonight.

Here are some thoughts in regards to backend code in no particular order.

  • You seem to establish new mongodb connection for every request. Consider moving the client initialization on the outermost scope of your application.

  • There appears to be some duplication of logic in the way you serve static files. Consider using express.static middleware to make the contents of your entire build directory publicly accessible.

  • There are some stylistic inconsistencies within your code and leftover console statements. Consider including eslint in your workflow.

  • Your routes are not always restful.For example, from what I understand, in RESTful application, the nomenclature for adding a new poll option would look something like this: POST /polls/:id/options. Key point is to include resource name and identifier in the url, and to avoid using verbs in favor of the various request methods.

  • Consider catching thrown errors in your express pipeline. You wouldn’t want errors in your request-response cycle to crash the entire application. Error handling in express.js

1 Like

Yeah, there were a number of problems with that version, I’m currently working on cleaning it up. I definitely need to look into express.static middleware. Moving the mongodb connections to global scope is something I hadn’t considered, but I will give it a try :slight_smile: As far as the routes go, it seems to me that keeping the data out of the url for post is more secure. The error handling that you have seen was done that way for development figuring it is better to let it crash and get the error output than let it just keep going. But yeah that definitely not the way to go for production and its on my list of things to fix. Thank you for taking the time to look over my code and give me feedback :smile:

I have fixed the issues you pointed out and it’s now live. Everything on the front end is working as it should, including the user sign up page. Still need to work on the backend stuff tho, and there are a few more changes I want to make on the front-end like reworking the nav-bar :slight_smile:

Don’t take this as criticism. I am curious as to why you used the MERN Stack on this. I am also learning the MERN Stack currently and one of the things I learned recently actually is that for an app like this it would be overkill to use a big stack like MERN. I am just curious not criticizing at all as I think based on what I see you did a very nice job on it.

1 Like

Yeah, it probably is a bit overkill. At the time I had not done any fullstack apps or worked with react in months, so the idea for using it was more to just get a feel for it and brush up on react. If I were to redo this today I would just jquery.

No worries I am a big fan of React myself and find myself constantly stopping myself from using it it in pretty much everything. I find jQuery not very exciting but it is the best thing to use on smaller things such as this. No matter as you said practice makes perfect.