DigitalCommons / mykomap-monolith

A web application for mapping initiatives in the Solidarity Economy
0 stars 0 forks source link

Ts restify the backend #15

Closed wu-lee closed 1 month ago

wu-lee commented 1 month ago

What? Why?

Related to issue #6

This PR converts the back end from using the fastify-openapi-glue implementation to an equivalent one using the new ts-rest based contract. It also fixes the test suite (such that there is) and adjusts the contract to match the API in use, in particular with respect to the errors (they now return messages), the dataset ID (it's now a number) and the version endpoint (the response is more specific, not just a pass-through).

What should we test?

Checklist

Deployment notes

wu-lee commented 1 month ago

This whole branch has been rebased to the end of main and some minor conflicts resolved (just package-lock.json)

wu-lee commented 1 month ago

Some extra things to note. As well as fixing-up those things as requested, I found some other problems and addressed them too. These were:

As I said earlier, I plan to flatten these corrections into the appropriate commits before merging. I'm not sure if it's easier for you to review before or after that, so let me know if you want me to do that first.

I've tested npm run dev/start/build on the front end, and npm run dev/build/test on the back end. These seem to work as expected now.

To test npm run start you need to set VITE_API_URL=/api in the front-end environment before building. It then mimics the way the app will run when deployed in production, when the API is served from /api.

You can check this is working by:

Setting SERVER_DATA_ROOT=test/data (or an equivalent) in the back-end environment isn't necessary in development (npm run start), but is necessary in production. Of course an alternative location can be used, pointing to different data. Our new back-end implementation, when it arrives, should continue to respect this option, as this is used by the production deployment to define where the data is.

rogup commented 1 month ago

@wu-lee Thanks, this is looking good.

wu-lee commented 1 month ago

Fixes for above changes requested now added as fixup commits above, then the branch rebased on to the current main branch to verify it can be integrated.

Then fixups squashed into relevant commits, or promoted to primary commits, as appropriate.

Result rebased again to integrate a fix added to main branch.