This package contains utility functions, classes, types, etc. that are shared between the frontend and the backend.
Keep in mind to add new exports to the index.ts file in the folde r.
- src/data/ data like default objects for the state or dummy objects for testing
- src/export-import/ contains schemas for export and import files
- src/models/ schemas and their types that are used in the state
- src/socket-api/ the types for socket.io
- src/state-helpers/ utilities for working with the state.
- src/state-migrations/ migrations to update old states and actions to the newest version.
- src/store/ reducers, actions and utilities that are used with the state
- src/utils/ general utilities
Note that whenever the state types get updated you have to increase currentStateVersion in state.ts.
In addition, you have to add a migration in state-migrations. Look at ./src/state-migrations/migration-functions.ts for more information.
To test the migrations, you can run the tests.
When writing new actions, note the comments in src/store/action-reducer.ts and src/store/action-reducers/action-reducers.ts.
You can orient yourself at the already existing actions in src/store/action-reducers.
Note especially that new actions have to be registered in actionReducers in src/store/action-reducers/action-reducers.ts.
When adding new models to the state, you should write a new schema within src/models and add a new attribute to the exercise state.
We are using Zod schemas for validating all elements in the state and all actions.
It is desirable to narrow down the types of the validation as much as possible, within reason.