My MERN project has a unique folder structure that includes:
backend, which consists of an express mongo backend with the following layout.
frontend containing 3 vite react projects, each with their own specific folder setup.
Parent Folder:
- backend
- src
- controllers
- middlewares
- models
- schemas
- types
- utils
- app.ts
- package.json
- tsconfig.json
- frontend
- client (vite app)
- src
- assets
- components
- hooks
- pages
- screens
- types
- index.html
- package.json
- tsconfig.json
- master (same as client)
- manager (same as client)
In my current setup, I have included a Types folder in each of the mentioned folders:
backend,
frontend/client,
frontend/master,
frontend/manager
When changes are made to a type in one location, I manually update it in all 4 folders to keep them consistent. This process can be tedious and error-prone, especially when types change frequently.
Moving forward, my question is:
I am looking for a solution to declare these types globally in the Parent Folder so that they can be accessed across all backend and frontend locations.
The main types I want to make global are database document schemas that are commonly used throughout the project.
Currently, managing types involves manual copying and pasting, which poses challenges with frequent updates.
Is there a more efficient way to handle this situation?