hack4impact-calpoly / general-vms

General volunteer management system.
2 stars 0 forks source link

[Backend] Create endpoint for creating shift and define shift scheme #11

Closed bglossner closed 2 years ago

bglossner commented 2 years ago

Assume a isUserAdmin middleware function works.

This endpoint (/api/new-shift for now?) should take information as a POST request about a Shift and create that shift. Here is an example: https://github.com/hack4impact-calpoly/happy-hats/blob/173baba2ae7f17eb92ad839cf7fef506d7d6b378/backend/calendar/calendar-api.js#L108

For this endpoint, make sure to do error detection and send appropriate responses back. For when this needs to interact with the database, add to the Database abstract class and any instances of it a new function that would be called that you can use in the endpoint code.

Also need to create a shift schema:

adameza commented 2 years ago

@bglossner What format will the dates initially be in before they need to be converted from number?

bglossner commented 2 years ago

From the server, the dates will come in as a number ((new Date).getTime() sorta thing). You can use getTime() on a date object to convert from date to number and can pass the number into Date (new Date(number)) to get a date object from a number.