Coder Social home page Coder Social logo

israamoqbel / experiment Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 38 KB

It's a mini :hatching_chick: :hatching_chick: :hatching_chick: Reddit web app using Express and handlebars.

Home Page: https://experiment-project.herokuapp.com/

CSS 12.94% JavaScript 62.50% PLpgSQL 5.77% HTML 18.79%

experiment's People

Contributors

israamoqbel avatar

Watchers

 avatar

experiment's Issues

Route naming

Do we need name here ?

router.get('/:name/:id', postPage.get);

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

Push to master

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.

console.logs

You shouldn't push console.logs in your development branch

console.log('the post content is ', body, 'for the user with userId=', decoded.user_id);

please remove all unnecessary console.logs from all the project

Commits !!!

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.

Consistency

You should be consistent when returning datatypes

if (err) return new Error(err);

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!!

Unnecessay file name in path

Node.js searches by default for the index.js file in your directory

const helpers = require('./views/helpers/index');

instead you can write it like this:
const helpers = require('./views/helpers/');

this will give you the same result

Middlewares

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.

App Config

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.

Secret Variables

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

Formatting

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.