-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add better error handling, specification, & docs
The trifecta
- Loading branch information
1 parent
084db0c
commit d5e661c
Showing
13 changed files
with
266 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
HackIllinois' backend API | ||
|
||
## Authentication | ||
|
||
[Attendee Authentication](https://adonix.hackillinois.org/auth/login/github?device=dev) | ||
|
||
[Staff Authentication](https://adonix.hackillinois.org/auth/login/google?device=dev) | ||
|
||
You can get a JWT to test with using the two links above - you'll have to do it programmatically in the apps, though. | ||
|
||
Authentication is required for most endpoints, and most endpoints have a role requirement as well (staff-only, for example). | ||
You can see these requirements on each endpoint's description. | ||
|
||
## Errors | ||
Errors are formatted like: | ||
```json | ||
{ | ||
"error": "NotFound", | ||
"message": "Couldn't find that", | ||
} | ||
``` | ||
Where `error` is a error type that can be compared in code, and `message` is a user-facing message for that error. | ||
|
||
This way, handling errors is straight-forward. | ||
|
||
## Shared Errors | ||
These error types are **not listed** under endpoints specifically, since each endpoint shares them. | ||
|
||
Authentication: | ||
- `NoToken` - you haven't specified a token on an endpoint that requires one | ||
- `InvalidToken` - the token specified is invalid, try re-logging | ||
- `TokenExpired` - the token has expired, you'll need to get a new one. To prevent this, use `GET /auth/token/refresh/`. | ||
- `Forbidden` - you don't have the role required to use this endpoint | ||
|
||
Specification has one key type as well - `BadRequest`. | ||
If you ever get this error code, you're sending a request in the wrong format. | ||
This error will also include information about what information is wrong, | ||
but you should always consult the docs if you get this error to verify. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.