Filling out docs some more

This commit is contained in:
Caleb Gardner
2024-05-18 22:07:24 -05:00
parent 75f8356893
commit f7bbdaa4b3
4 changed files with 91 additions and 17 deletions
+4 -4
View File
@@ -2,9 +2,9 @@ module github.com/CalebQ42/darkstorm-server
go 1.22.3 go 1.22.3
require golang.org/x/crypto v0.23.0
require ( require (
github.com/google/uuid v1.6.0 // indirect github.com/google/uuid v1.6.0
golang.org/x/sys v0.20.0 // indirect golang.org/x/crypto v0.23.0
) )
require golang.org/x/sys v0.20.0 // indirect
+66 -12
View File
@@ -8,8 +8,8 @@ This is a purposefully "simple" application backend made specifically for _my_ a
```json ```json
{ {
appName: "app name", id: "API Key",
key: "API Key", appID: "appID",
death: -1, // unix timestamp when the key is no longer valid. -1 means there is not expected expiration (that can change in the future) death: -1, // unix timestamp when the key is no longer valid. -1 means there is not expected expiration (that can change in the future)
perm: { perm: {
user: true, // create and login users user: true, // create and login users
@@ -22,6 +22,8 @@ This is a purposefully "simple" application backend made specifically for _my_ a
### User ### User
Users are stored per backend and not per app.
```json ```json
{ {
id: "UUID", id: "UUID",
@@ -36,18 +38,46 @@ This is a purposefully "simple" application backend made specifically for _my_ a
} }
``` ```
## Standard Header ### Crash Reports
Any request might or might not need these values. These values can be authenticated via the `TODO` function. #### Individual Report
```json
{
count: 1, // We do not store duplicates. If a duplicate does occur
platform: "android",
error: "error",
stack: "stacktrace"
}
```
#### Crashes
```json
{
id: "UUID",
error: "error",
firstLine: "first line of error",
individual: [
// Individual Crash Reports
]
}
```
## Requests
### Standard Header
Any request might or might not need these headers. These values can be authenticated via the `ParseHeader` function.
```json ```json
{ {
X-API-Key: "{API Key}", X-API-Key: "{API Key}",
Authorization: "Bearer {JWT Token}" Authorization: "Bearer {JWT Token}" // No built-in functions require a JWT Token, but may be required by specific implementations.
} }
``` ```
## Error Response ### Error Response
If an error status code is returned then the body will be as follows. If an error status code is returned then the body will be as follows.
@@ -58,23 +88,26 @@ If an error status code is returned then the body will be as follows.
} }
``` ```
## Users ### Users
> TODO: Add the ability to create users and log-in through third-parties (such as Google). > 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 and the key must have the `users` permission. All requsests pertaining to users requires the `X-API-Key` header and the key must have the `users` permission.
### Create User #### Create User
> TODO: Email user to confirm. > TODO: Email user to confirm.
>
> TODO: Screen username for offensive words and phrases. > TODO: Screen username for offensive words and phrases.
Request: Request:
> POST: /user/create
```json ```json
{ {
username: "Username", username: "Username",
password: "Password", password: "Password", // Password must be
email: "Email", email: "Email",
} }
``` ```
@@ -90,19 +123,23 @@ Return:
If returned status is 401, the errorCode will be one of the following: If returned status is 401, the errorCode will be one of the following:
* username * usernameTaken
* Username is already taken * Username is already taken
* usernameDisallowed
* Username is not allowed (due to offensive words/phrases)
* password * password
* Password does not follow rules * Password is to short or too long.
* email * email
* Email is already linked to an account * Email is already linked to an account
* disallowed * disallowed
* Username contains words/phases that are not allowed * Username contains words/phases that are not allowed
### Login #### Login
Request: Request:
> POST: /user
```json ```json
{ {
username: "Username", username: "Username",
@@ -118,3 +155,20 @@ Return:
timeout: 0, // login attempt timeout (in seconds). If non-zero, token will be empty. timeout: 0, // login attempt timeout (in seconds). If non-zero, token will be empty.
} }
``` ```
### Crash Report
Crash reports require the `X-API-Key` header and the key must match the URL's appID and have the `crash` permission
Request:
> POST: /{appID}/crash
```json
{
id: "UUID", // This is an ignored value, but it is highly recommended to include it to prevent reporting the same crash multiple times.
platform: "android",
error: "error",
stack: "stacktrace"
}
```
+12 -1
View File
@@ -1,4 +1,15 @@
package darkstorm package darkstorm
type CrashReport struct{} type IndividualCrash struct {
Platform string
Error string
Stack string
Count int
}
type CrashReport struct {
ID string
Error string
FirstLine string
Individual []IndividualCrash
}
@@ -1 +1,10 @@
package darkstorm package darkstorm
import (
"os"
"testing"
)
func TestMain(t *testing.M) {
os.Exit(t.Run())
}