swassistant

package
v0.0.0-...-1694169 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2024 License: MIT, MIT Imports: 13 Imported by: 0

README

swassistant-backend

Custom backend for SWAssistant. Extension of darkstorm-backend

APIs

For POST requests, the X-API-Key http header must be set.

Profiles
Upload profile to share

Character, vehicles, and minion profiles.

POST: /profile?type={character|vehicle|minion}

Upload a profile. type query is required.

Request Body:

{
  // profile data
}

Note: Only allows up to 5MB of data. If over 5MB returns 413. Further limits might be imposed in the future.

Response:

{
  "id": "profile ID",
  "expiration": 0 // Unix time (Seconds) of expiration
}
Get a shared profile

GET: /profile/{profileID}

Get an uploaded profile.

Response:

{
  "type": "character|vehicle|minion",
  // profile data minus uid
}
Rooms

All room requests must include both X-API-Key and Authorization headers.

Room list

GET: /rooms

Get a list of rooms your currently a part of.

Response:

[
  {
    "id": "room ID",
    "name": "room name",
    "owner": "username"
  }
]
Create new room

POST: /rooms/new?name={roomName}

Create a new room. name query is required.

Response:

{
  "id": "room ID",
  "name": "room name"
}
Get room info

GET: /rooms/{roomID}

Get info about a room.

{
  "id": "room ID",
  "name": "room name",
  "owner": "username",
  "users": [
    "username"
  ],
  "profiles": [
    "profile uuids"
  ]
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Room

type Room struct {
	ID       string   `json:"id" bson:"_id"`
	Name     string   `json:"name" bson:"name"`
	Owner    string   `json:"owner" bson:"owner"`
	Users    []string `json:"users" bson:"users"`
	Profiles []string `json:"profiles" bson:"profiles"`
}

type SWBackend

type SWBackend struct {
	// contains filtered or unexported fields
}

func NewSWBackend

func NewSWBackend(db *mongo.Database) *SWBackend

func (*SWBackend) AddBackend

func (s *SWBackend) AddBackend(b *backend.Backend)

func (*SWBackend) AppID

func (s *SWBackend) AppID() string

func (*SWBackend) CountTable

func (s *SWBackend) CountTable() backend.CountTable

func (*SWBackend) CrashTable

func (s *SWBackend) CrashTable() backend.CrashTable

func (*SWBackend) Extension

func (s *SWBackend) Extension(mux *http.ServeMux)

func (*SWBackend) GetProfile

func (s *SWBackend) GetProfile(w http.ResponseWriter, r *http.Request)

func (*SWBackend) GetRoom

func (s *SWBackend) GetRoom(w http.ResponseWriter, r *http.Request)

func (*SWBackend) ListRooms

func (s *SWBackend) ListRooms(w http.ResponseWriter, r *http.Request)

func (*SWBackend) NewRoom

func (s *SWBackend) NewRoom(w http.ResponseWriter, r *http.Request)

func (*SWBackend) ShouldAddCrash

func (s *SWBackend) ShouldAddCrash(ctx context.Context, cr backend.IndividualCrash) bool

func (*SWBackend) UploadProfile

func (s *SWBackend) UploadProfile(w http.ResponseWriter, r *http.Request)

type UploadedProf

type UploadedProf struct {
	Profile    map[string]any `json:"profile" bson:"profile"`
	ID         string         `json:"id" bson:"_id"`
	Type       string         `json:"type" bson:"type"`
	Expiration int64          `json:"expiration" bson:"expiration"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL