At @mifeng's request, I looked at the Gateway API repo. The goal is to make sure we are following best practices.
Here is a list of changes I'm proposing. I also implemented several changes as a part of this PR:
Re-organize repo structure so that it is more standard to nodeJS conventions. Please refer to this guide for the rationale behind the re-org. The re-org is already done as a part of this PR.
Add a code linter, which is standard for JS repos. This is included in the PR as well.
Separated app routing logic from business logic. This is recommended because it makes the codebase more readable, and allows developers to test individual components. I refactored the balancer route as an example.
Use modern JS ES6. Meaning import, export, class, etc. This has less direct impact, but is also pretty standard. I refactored relevant code in the balancer route as examples.
Specify node/npm/yarn version in package.json. I didn't do this because I'm not sure what version of node @sdgoh is using currently. But this is important because it could cause version incompatibility later on, and is always a pain to debug.
Long term: add unit tests.
Long term: consider converting to Typescript. For a backend API, typing will help improve stability.
At @mifeng's request, I looked at the Gateway API repo. The goal is to make sure we are following best practices.
Here is a list of changes I'm proposing. I also implemented several changes as a part of this PR:
Re-organize repo structure so that it is more standard to nodeJS conventions. Please refer to this guide for the rationale behind the re-org. The re-org is already done as a part of this PR.
Add a code linter, which is standard for JS repos. This is included in the PR as well.
Separated app routing logic from business logic. This is recommended because it makes the codebase more readable, and allows developers to test individual components. I refactored the balancer route as an example.
Use modern JS ES6. Meaning
import
,export
,class
, etc. This has less direct impact, but is also pretty standard. I refactored relevant code in the balancer route as examples.Specify node/npm/yarn version in
package.json
. I didn't do this because I'm not sure what version of node @sdgoh is using currently. But this is important because it could cause version incompatibility later on, and is always a pain to debug.Long term: add unit tests.
Long term: consider converting to Typescript. For a backend API, typing will help improve stability.