Expirementing with building everthing from scratch.

1st steps
This commit is contained in:
Caleb Gardner
2024-05-17 06:45:45 -05:00
parent 14a486866e
commit abfc67d10f
12 changed files with 97 additions and 1032 deletions
+86
View File
@@ -0,0 +1,86 @@
# Darkstorm Backend
This is a purposefully "simple" application backend made specifically for _my_ apps. It's purpose is to collect minimal (only what's absolutely necessary) amounts of data while still fulfilling all my needs. I've found that other, off the shelf options such as Firebase are a bit heavy on the data collection. Plus I like to make things :P.
## Standard Header
Any request might or might not need these values. These values can be authenticated via the `TODO` function.
```json
{
X-API-Key: "{API Key}",
Authorization: "Bearer {JWT Token}"
}
```
## Error Response
If an error status code is returned then the body will be as follows.
```json
{
errorCode: "Error value for internal use",
errorMsg: "User error message", //This message is meant to be displayed to the user. May be empty.
}
```
## Users
> TODO: Add the ability to create users and log-in through third-parties (such as Google).
All requsests pertaining to users requires the `X-API-Key` header.
### Create User
> TODO: Email user to confirm.
> TODO: Screen username for offensive words and phrases.
Request:
```json
{
username: "Username",
password: "Password",
email: "Email",
}
```
Return:
```json
{
username: "Username",
token: "JWT Token"
}
```
If returned status is 401, the errorCode will be one of the following:
* username
* Username is already taken
* password
* Password does not follow rules
* email
* Email is already linked to an account
* disallowed
* Username contains words/phases that are not allowed
### Login
Request:
```json
{
username: "Username",
password: "Password",
}
```
Return:
```json
{
token: "JWT Token",
timeout: 0,
}
```
+3
View File
@@ -0,0 +1,3 @@
package darkstorm
type App interface{}
+7
View File
@@ -0,0 +1,7 @@
package darkstorm
import "net/http"
type Backend struct {
http.ServeMux
}