-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
234 additions
and
10 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 |
---|---|---|
|
@@ -33,6 +33,7 @@ Go-Echo Boilerplate API is designed to be a fast and efficient solution for buil | |
|
||
- PORT: The port on which the server will run, e.g. :8000 | ||
- MONGO_URL: The connection string for your MongoDB Atlas cluster, e.g. mongodb+srv://<username>:<password>@cluster0.mongodb.net/test?retryWrites=true&w=majority | ||
|
||
- MONGO_DB: The name of the database, e.g. databaseName | ||
- BCRYPT_PASSWORD: The bcrypt password, e.g. bcryptPassword | ||
- EMAIL_FROM: The email address from which emails will be sent, e.g. [email protected] | ||
|
@@ -53,17 +54,18 @@ Go-Echo Boilerplate API is designed to be a fast and efficient solution for buil | |
``` go run main.go ``` | ||
|
||
## Endpoints | ||
- [Health Check](health_check.md): GET /health | ||
- [User Registration](user_registration.md): POST /register | ||
- [Health Check](health.md): GET /health | ||
- [Check username availability](username_availability.md): GET /username/:username | ||
- [Register](register.md): POST /register | ||
- [Login](login.md): POST /login | ||
- [Refresh Token](refresh_token.md): POST /refresh | ||
- [Invalidate Token](invalidate_token.md): POST /invalidate | ||
- [Password Reset](password_reset.md): POST /reset-password | ||
- [Update Profile](update_profile.md): PUT /profile | ||
- [Retrieve Profile](retrieve_profile.md): GET /profile/:user_id | ||
- [Verify Email](verify_email.md): GET /verify/:token | ||
- [Resend Verification Email](resend_verification.md): POST /resend-verification | ||
- [Reset Password](password_reset.md): POST /reset-password | ||
- [Refresh Token](refresh_token.md): POST /refresh | ||
- [Invalidate Refresh Token](invalidate_token.md): DELETE /refresh | ||
|
||
- [Update Profile](update_profile.md): PUT /profile *** | ||
- [Retrieve Profile](retrieve_profile.md): GET /profile/:user_id *** | ||
|
||
## How to Contribute | ||
If you would like to contribute to the project, please follow these steps: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Your request headers, e.g. | ||
POST http://localhost:8080/refresh/ | ||
Content-Type: application/json | ||
|
||
# The request body, if any | ||
{ | ||
"refreshToken": "token here", | ||
} |
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,19 @@ | ||
# Health Endpoint | ||
|
||
## Get Health Status | ||
|
||
### Request | ||
|
||
`GET /health` | ||
|
||
### Response | ||
|
||
#### Success | ||
|
||
- Status Code: 200 OK | ||
- Content: | ||
|
||
```json | ||
{ | ||
"status": "OK" | ||
} |
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,37 @@ | ||
# Refresh Delete Endpoint Error Responses | ||
|
||
The `RefreshDelete` endpoint may return the following error responses in case of a failure. | ||
|
||
## Responses | ||
|
||
The endpoint returns a JSON object with the following fields: | ||
|
||
| Field | Type | Description | | ||
|------------|--------|-----------------------------------------------------------------------| | ||
| Message | string | A string indicating the status of the request. Can be an error message. | | ||
|
||
### HTTP 400 Bad Request | ||
|
||
When the provided `refreshToken` is invalid, the endpoint returns the following response: | ||
|
||
|
||
``` | ||
HTTP 400 Bad Request | ||
{ | ||
"Message": "Invalid refresh token" | ||
} | ||
``` | ||
|
||
### HTTP 500 Internal Server Error | ||
|
||
In case of a failure to update the user in the database, the endpoint returns the following response: | ||
|
||
|
||
``` | ||
HTTP 500 Internal Server Error | ||
{ | ||
"Message": "Failed to update user in database" | ||
} | ||
``` |
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,51 @@ | ||
# Endpoint: RefreshPost | ||
|
||
Refreshes a JWT for a user with a valid refresh token. | ||
|
||
## Request | ||
|
||
Method | Endpoint | Description | ||
-------|----------|------------ | ||
POST | /refresh | Refreshes a JWT for a user with a valid refresh token | ||
|
||
### Request Body | ||
|
||
Field | Type | Required | Description | ||
------|------|----------|------------ | ||
refreshToken | string | Yes | Refresh token of the user | ||
|
||
## Response | ||
|
||
HTTP Code | Response Body | Description | ||
----------|---------------|------------ | ||
200 | `{"message": "Success", "data": {"jwt": "<jwt>"}}` | If the JWT was successfully refreshed | ||
400 | `{"message": "Invalid refresh token"}` | If the provided refresh token is invalid | ||
500 | `{"message": "Failed to find user in database"}` | If there was a problem finding the user in the database | ||
500 | `{"message": "Failed to generate JWT"}` | If there was a problem generating the JWT | ||
|
||
### Response Body | ||
|
||
Field | Type | Description | ||
--------|--------|------------ | ||
message | string | Status message | ||
data | object | JSON object with the refreshed JWT | ||
|
||
## Example | ||
|
||
Request: | ||
|
||
``` | ||
POST /refresh | ||
Content-Type: application/x-www-form-urlencoded | ||
refreshToken=<refresh_token> | ||
``` | ||
|
||
Response: | ||
|
||
``` | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
{"message": "Success", "data": {"jwt": "<jwt>"}} | ||
``` |
File renamed without changes.
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,70 @@ | ||
# Check Username Endpoint | ||
|
||
## Get a user's availability by checking their username | ||
|
||
### Request | ||
|
||
`GET /check-username?username=<username>` | ||
|
||
### Parameters | ||
|
||
| Name | Type | Description | | ||
| ---- | ---- | ----------- | | ||
| username | string | Required. The username to check availability for | | ||
|
||
### Response | ||
|
||
Success: | ||
``` | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
{ | ||
"message": "Username available", | ||
"available": true | ||
} | ||
``` | ||
|
||
or | ||
|
||
``` | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
{ | ||
"message": "Username not available", | ||
"available": false | ||
} | ||
``` | ||
|
||
### Error Responses | ||
|
||
| HTTP Code | Description | | ||
| --------- | ----------- | | ||
| 400 Bad Request | If the query parameter `username` is missing | | ||
| 500 Internal Server Error | If an error occurs while checking the username in the database | | ||
|
||
### Response | ||
|
||
Bad Request: | ||
|
||
``` | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
{ | ||
"message": "Username is required" | ||
} | ||
``` | ||
|
||
Internal Server Error: | ||
|
||
``` | ||
HTTP/1.1 500 Internal Server Error | ||
Content-Type: application/json | ||
{ | ||
"message": "An error occurred while checking the username", | ||
"error": "<error message>" | ||
} | ||
``` |
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,37 @@ | ||
# Verify Email | ||
|
||
Verifies an email using the provided `verificationCode` as a query parameter in the URL. | ||
|
||
#### Endpoint | ||
|
||
``` | ||
GET /verify-email?verificationCode=<verificationCode> | ||
``` | ||
|
||
#### URL Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| verificationCode | string | Required. The verification code used to verify the email. | | ||
|
||
#### Success Response | ||
|
||
Status Code: 200 OK | ||
|
||
``` | ||
{ | ||
"message": "User marked as verified successfully!" | ||
} | ||
``` | ||
|
||
#### Error Responses | ||
|
||
|
||
The following table lists the possible error responses for the `GET /verify-email` endpoint: | ||
|
||
| HTTP Status Code | Error Code | Description | | ||
| --- | --- | --- | | ||
| 500 Internal Server Error | `Failed to verify the user` | The verification failed due to a server-side error. | | ||
| 500 Internal Server Error | `Invalid verification code` | The provided `verificationCode` is invalid. | | ||
|
||
|