DigitalCommons / mykomap-monolith

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

Add ts-rest contract #8

Closed rogup closed 2 months ago

rogup commented 2 months ago

What? Why?

Related to issue #6

This PR converts @mykomap/common into a Typescript module, built with Vite, and adds a contract.ts to define the REST API. This contract can be comsumed by ts-rest in the back-end and front-end for API implementations and calls.

We also have added a ts-rest contract -> OpenAPI spec generator and generated an OpenAPI spec. I have checked it against the old OpenAPI spec, and it looks more-or-less the same with a few syntax changes, which I don't think matter in practice.

Checklist

Deployment notes

rogup commented 2 months ago

@wu-lee Please could you review that the generated openapi spec looks fine? There are a few differences due to the way the generator library does things e.g. nesting of the 'description', but I think all info is still there and it's a valid spec that makes sense.

If it looks good, feel free to merge this into main

I'm hoping my changes to this module haven't broken the backend build after your typescript-ification

After my holiday, I can then start working on migrating to ts-rest on the FE side, and hopefully it will all connect up nicely without too much pain!

wu-lee commented 2 months ago

Thanks, I've rebased it up to the top of the main branch, and fixed the minor conflicts with the work I've pushed prior to that.

As part of reviewing it, I also split one of the commits up ("Fix module entry point") so that the npm install and index.ts steps are in separate commits, mainly to highlight what those npm modules are.

The monorepo.md document changes are committed in an earlier branch.

Merging this as you suggests, it seems to work fine with the back end.

All of this ends up in an identical endpoint - I've not changed the net content of the commits.