israamoqbel / experiment Goto Github PK
View Code? Open in Web Editor NEWIt's a mini :hatching_chick: :hatching_chick: :hatching_chick: Reddit web app using Express and handlebars.
Home Page: https://experiment-project.herokuapp.com/
It's a mini :hatching_chick: :hatching_chick: :hatching_chick: Reddit web app using Express and handlebars.
Home Page: https://experiment-project.herokuapp.com/
Do we need name
here ?
experiment/src/controllers/index.js
Line 18 in 2c03dd3
I see that you are not using name
param in the controller, replace it /posts/:id
as the dynamic part of your url is id
.
Search for RESTful API
to know more about routes naming conventions
you are pushing your code to master branch directly.
This is a bad practice, and that doesn't help you if you found a bug in the code, in that case you have to revert the branch and maybe that not help, Every push to your repo should in a branch and make a pull request, then merge that branch into master, this helps you be safe if a bug have been found, or if there a changes happened and broke something, and that way helps you track your code, specially if you are working in a team.
experiment/src/controllers/postPage.js
Line 54 in 2c03dd3
this is so offensive error message, which may affect user experience ๐ .
Are you using camelCase or snake_case as a convention for naming variables
user_id
should be userId
for consistency
You shouldn't push console.logs in your development branch
experiment/src/controllers/home.js
Line 37 in 2c03dd3
you should write descriptive commits next time.
every commit should describe what change are in it.
writing descriptive commits helps in tracking changes to the codebase, and know when a piece of code have been added.
does the user needs to know his id in the database ?!
experiment/src/views/userPage.hbs
Line 4 in 2c03dd3
You should be consistent when returning datatypes
experiment/src/controllers/home.js
Line 38 in 2c03dd3
here in case of error you are returning and Error
object and not ending the response,
and in case of success you are redirect to /
which I think returns html
. this will cause a lot of problems for user experience.
Either return html
or json
in the same handler, don't return both in the same handler!!
This is not semantic html,
footer should be wrapped in <footer>
tag for accessibility
Node.js searches by default for the index.js file in your directory
Line 6 in 2c03dd3
instead you can write it like this:
const helpers = require('./views/helpers/');
this will give you the same result
I think here you are not using any middlewares,
a useful use case for middlewares for example: in auth in every request you are using jwt.verify
to make sure that the have the permission to access the endpoint, and in every endpoint that requires the request to be authed you are repeat the same code, so you can put jwt.verify
in a middleware and use that middleware before any protected route, this reduces code repetition, and make your code reusable.
experiment/src/controllers/index.js
Line 20 in 2c03dd3
lots of unnecessary white spaces here, one line of white space is better and more readable
you don't need to push your commented code in you production branch master
in this case.
experiment/src/controllers/home.js
Line 9 in 2c03dd3
please delete any commented code in all the repo
You are configuring your app for production only!!!.
You should distinguish between development environment and production environment.
Development Environment is when you are developing and running your app in localhost, in this case you have to configure your app to connect to your development database local database
, here you are connecting to your production database, you have to make a config file to handle these things.
Production Environment is when your app is ready to be deployed, and when you deploy your app on a a server you can't connect to your local database, so in this case you need to connect to the database that is in the cloud, for this case I think you are hosting you database on heroku.
So you need to determine in which environment you are, and after you determine that you decide what environment variables are, for example: if your environment is development
then you will connect to your development database local database
, or if your environment is production
then you will connect to your cloud database the database on heroku here
.
You pushed your config.env
file which contains your secrets, they are not secrets anymore !!
you shouldn't push your .env
file to the cloud, put it in your .gitignore
file
Are you using linter ??!
linter lets you format your code and be consistent when writing your code, in order to the rules you tell the linter to check for
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.