These endpoints are present in all the controllers unless stated otherwise.
Every endpoint can return with a 500 Status Code (Internal Server Error) but are not limited to it.
- If sucessful returns the data with pagination format.
- Receives an ID as a parameter.
- Gets one record from the database given the id.
- If the record is found returns it with a 200 Status Code (OK).
- Else returns 'Record {id} not found.' with a 404 Status Code (Not Found).
- Receives a request body with the model data.
- Creates the record on the database with the data received.
- If sucessfuly created, returns the created record with a 200 Status Code (OK).
- Else returns a 'Failed to save record' with a 304 Status Code (Not Modified).
- Receives a request body with the model data and an ID parameter.
- Check if the record is found in the database.
- If found, updates the record and returns it with a 200 Status Code (OK).
- Else returns 'Record {id} no found.' with a 404 Status Code (Not Found).
- Receives a ID as a parameter.
- Tries to delete the record.
- If sucessfuly delete returns '1' with a 200 Status Code (OK).
- Else returns '0' with a 404 Status Code (Not Found).
- Receives query that is passed to its' query filter.
- If returns the found information with a 200 Status Code (OK).
This class handles user authentication with JWT tokens.
Does not have any generic endpoints
-
Receives a request body with email and password for authentication.
{ "email": "user@example.com", "password": "your_password" }
-
Upon successful login, a JSON response containing the JWT will be returned:
{ "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." }
-
Attempt to refresh given token on authentication header.
-
If the refresh is successful, a new JWT will be returned:
{ "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." }
This class is handles the management for user accounts.
Does not have the generic Create function, instead it's named Register.
- Receives a request body with the model data.
{ 'first_name': string, 'last_name': string, 'email': string, 'password': string, }
- If sucessfuly created, returns a JWT token with a 201 Status Code (Created).
- Else returns 'Failed to register user.' with a 400 Status Code (Bad Request).
- Can return 'Email already registered.' with a 409 Status Code (Conflict) if the email is already registered
- Authenticates the Bearer token from the authorization header.
- If authenticated, returns user information with a 200 Status Code (OK).
- Else returns 'Could not authenticate user.' with a 401 Status Code (Unauthorized).
- Receives the user information and Bearer token to authenticate the user.
- If authenticaded, updates the user record and returns it with a 200 Status Code (OK).
- If not possible to update returns 'Unable to update the user.'with a 304 Status Code (Not Modified).
- Receives manufacturer name as param.
- If found manufacturer like the name returns the products as paginate with 200 Status Code (OK).