diff --git a/API.md b/API.md index 6e1907f..202326f 100644 --- a/API.md +++ b/API.md @@ -1,3 +1,83 @@ +# Table of contents +- [Table of contents](#table-of-contents) +- [1. Description of custom types](#1-description-of-custom-types) + - [AccessToken](#accesstoken) + - [Building](#building) + - [Planet](#planet) + - [Research](#research) + - [Resource](#resource) + - [User](#user) +- [2. API endpoints](#2-api-endpoints) + - [/generateAccessToken](#generateaccesstoken) + - [/testAccessToken](#testaccesstoken) + - [/planets/getPlanet](#planetsgetplanet) + - [/planets/getAllPlanets](#planetsgetallplanets) + - [/research/getResearch](#researchgetresearch) + - [/research/performResearch](#researchperformresearch) + - [/build/createBuilding](#buildcreatebuilding) + +# 1. Description of custom types + +## AccessToken +```ts +_id: ObjectId // (MongoDB) +type: "A" | "S" | "X" // Auth, Spy, Master +user: ObjectId | null // master token has this field empty +entropy: string // random bytes +createdAt: Date +expiresAt: Date | null // null for "never expires" +createdFrom: string +``` + +## Building +```ts +id: string +level: number +``` + +## Planet +```ts +_id: ObjectId, +owner: User, +name: string, +fields: number, +resources: Array, +buildings: Array, +ships: Array, +``` + +## Research +```ts +id: string +level: number +``` + +## Resource +```ts +name: string +amount: number +lastUpdated: Date +perHourMiningRate: number +``` + +## User +```ts +_id: ObjectId +username: string +email: string +password: string // hashed with argon2 +lastLogin: Date +research: Array +planets: { // getting user planets requires second call to DB + partial: boolean; // so by default "partial" is true, and "data" is empty + data: Array // unless specified otherwise in code +} +createdAt: Date +updatedAt: Date +``` + +# 2. API endpoints + ## /generateAccessToken **URL: POST** /generateAccessToken @@ -159,5 +239,4 @@ "code": 200, "message": "OK" } -``` - +``` \ No newline at end of file