Put types and enums that both the server and web need into a common area

This commit is contained in:
Oliver-Akins 2021-12-28 20:08:42 -07:00
parent 526b4c5771
commit 4c957cce07
4 changed files with 37 additions and 0 deletions

7
common/enums/Status.ts Normal file
View file

@ -0,0 +1,7 @@
export const Status = {
Success: 200,
UnknownError: 400,
OutOfDate: 401,
NotFound: 404,
Teapot: 418,
}

4
common/types/Colour.ts Normal file
View file

@ -0,0 +1,4 @@
interface Colour {
name: string;
hex: string;
}

View file

@ -0,0 +1,8 @@
interface ServerResponse {
/** The state indicator for responses from the server */
status: number;
/** Additional information that is provided by the server */
message?: string;
}

View file

@ -0,0 +1,18 @@
/** The data the client must provide in the `SaveShip` event. */
interface SaveShip {
colour: string;
ship: string;
}
/**
* The event that get's sent out to all the other players on a successful
* `SaveShip` event
*/
interface DesignUpdate {
player: string;
ship: string;
colour: string;
}
/** The response to the client that triggered the `SaveShip` event. */
interface SaveShipResponse extends ServerResponse {}