snowberb – 09-42 Jul 3

I have multiple repositories for multiple APIs. Each of these apis has a custom fetch function which is duplicated code. There are times where I have to update the code of that fetch to adapt to back changes, and right now I have to make the change on all the different repos. Should I create a new repo that contains this fetch file and import that in all other repos? Would that be the best way to do this?
UU
Unknown User290d ago
S
Sniberb289d ago
no, I mean multiple APIs I made a script to autogenerate the TS code for every endpoint in every api, but everytime I make a new change, I have to manually update it in each one of the repos
UU
Unknown User289d ago
S
Sniberb289d ago
would you say having a mono repo with subfolders for each api would be better?
UU
Unknown User289d ago
S
Sniberb289d ago
yes, but what would be better?
UU
Unknown User289d ago
S
Sniberb289d ago
if I have a mono repo I could have the custom fetch and the script in the root and just import it to every folder yes
UU
Unknown User289d ago
S
Sniberb289d ago
if I give you some more context could you share your opinion?
UU
Unknown User289d ago
S
Sniberb289d ago
- Backend uses yaml files to type each endpoint of an API using schemas - For every API, there is a gitlab repo which I use as an npm package in the main app - I have a script that reads that yaml and generates react-query hooks + type definitions using zod. The script and the custom fetch is duplicated code that every single API repo needs, and everytime I make a change in the script so I can adapt better to the yaml as there are still not controlled cases, I have to update every single repo (there are like +10 different APIs). The bad thing about this is that it's a bit hard to maintain consistency between all the repos and in a close future, I wanted to make another project which would automatically update every yaml of every repo by just hitting a button
UU
Unknown User289d ago
S
Sniberb289d ago
the product im working is being built, and there are frequent backend changes that force the yaml to update and I need the yaml update so the main project can compile
UU
Unknown User289d ago
S
Sniberb289d ago
no
UU
Unknown User287d ago