Something that I'd really like to add here is some unit testing, so that we can test that our endpoints are behaving the way that they should be. While this PR doesn't do that, it does set up some of the groundwork - it refactors the overall architecture so that the app is set up via a createApp function, and the database connection via getDatabaseConnection, so that these can be instantiated in the main.ts, rather than these being constants that get imported elsewhere. Additionally, each sub-router now exports a setup function (in addition to the router object itself) that takes in the app and the database and does whatever setup is necessary (currently, initializing models and setting up associations). This is called during the app setup in main.ts.
I've also added in some testing dependencies and a simple test here, but I'll actually set up the testing CI later. I mostly want to having this working and merged in because rebasing against changes to the main branch would inevitably be annoying.
Something that I'd really like to add here is some unit testing, so that we can test that our endpoints are behaving the way that they should be. While this PR doesn't do that, it does set up some of the groundwork - it refactors the overall architecture so that the app is set up via a
createApp
function, and the database connection viagetDatabaseConnection
, so that these can be instantiated in themain.ts
, rather than these being constants that get imported elsewhere. Additionally, each sub-router now exports asetup
function (in addition to the router object itself) that takes in the app and the database and does whatever setup is necessary (currently, initializing models and setting up associations). This is called during the app setup inmain.ts
.I've also added in some testing dependencies and a simple test here, but I'll actually set up the testing CI later. I mostly want to having this working and merged in because rebasing against changes to the main branch would inevitably be annoying.