Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Review #1

Open
regmicmahesh opened this issue Feb 6, 2022 · 0 comments
Open

Code Review #1

regmicmahesh opened this issue Feb 6, 2022 · 0 comments

Comments

@regmicmahesh
Copy link

1

When you define routes like this, the second parameter is the handler.

aot-api/index.js

Lines 24 to 26 in d66ee8e

app.get('/', (req, res) => {
res.render('index', {amount: numOfQuotes()})
})

But you have a separate file called handlers.js which isn't directly handling the response. It'd be better if you did something like this.

 app.get('/', homepageHandler)

and, all the logic of handling the route goes inside the homepageHandler.

2

port = process.env.PORT || 3000

Never ever do this when you build an application.

For example, let me consider you're hosting this application in a server and the server expects you to run your app in port 4050. Now, your app will be working perfectly fine if you forgot to provide the value of PORT . But you'll not be able to access since you've a defeault value of 3000 instead of 4050. Throw a error instead when value is not provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant