hack4impact-calpoly / general-vms

General volunteer management system.
2 stars 0 forks source link

[Frontend] Create Mock Backend #6

Open bglossner opened 2 years ago

bglossner commented 2 years ago

Sometimes when developing, it's not convenient to use the actual backend and get it running, since it might be broken or not scale well. This task is to create a mock backend. What that means is creating a mock backend (in frontend) that the frontend uses by default instead of connecting to the backend.

This means creating classes that can be switched out (common interface called like Backend or Server) that extend calls the frontend will need to make to the backend.

Example: Let's say on the frontend we need to get the user's volunteer events. The component that needs to do that may call serverInstance().getVolunteerEvents(user). The server instance would have a function called getVolunteerEvents that takes a user and makes the appropriate HTTP request to do so. It then parses the response and gives it back to the component. The mock backend would not make the HTTP request; instead it would return some default mocked response to the frontend.

bglossner commented 2 years ago

Another easier approach: Just make a simple express server that returns mocked data. Might be easier.