Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/docs/api-docs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { RouteDocs } from 'koa-clay'
import { APIKeyScope } from '../entities/api-key'

type APIRouteDocs = RouteDocs & {
scopes?: APIKeyScope[]
}

type APIDocs<T> = {
[key in keyof T]?: RouteDocs
[key in keyof T]?: APIRouteDocs
}

export default APIDocs
4 changes: 3 additions & 1 deletion src/docs/event-api.docs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import EventAPIService from '../services/api/event-api.service'
import APIDocs from './api-docs'
import { APIKeyScope } from '../entities/api-key'

const EventAPIDocs: APIDocs<EventAPIService> = {
post: {
description: 'Track events',
scopes: [APIKeyScope.WRITE_EVENTS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand Down Expand Up @@ -89,4 +91,4 @@ const EventAPIDocs: APIDocs<EventAPIService> = {
}
}

export default EventAPIDocs
export { EventAPIDocs }
16 changes: 15 additions & 1 deletion src/docs/game-channel-api.docs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import GameChannelAPIService from '../services/api/game-channel-api.service'
import APIDocs from './api-docs'
import { APIKeyScope } from '../entities/api-key'

const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
index: {
description: 'List game channels',
scopes: [APIKeyScope.READ_GAME_CHANNELS],
params: {
query: {
page: 'The current pagination index (starting at 0)'
Expand Down Expand Up @@ -87,6 +89,7 @@ const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
},
get: {
description: 'Find a game channel',
scopes: [APIKeyScope.READ_GAME_CHANNELS],
params: {
route: {
id: 'The ID of the channel'
Expand Down Expand Up @@ -120,6 +123,7 @@ const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
},
subscriptions: {
description: 'List game channels that the player is subscribed to',
scopes: [APIKeyScope.READ_GAME_CHANNELS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand Down Expand Up @@ -188,6 +192,7 @@ const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
},
post: {
description: 'Create a game channel',
scopes: [APIKeyScope.WRITE_GAME_CHANNELS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand Down Expand Up @@ -251,6 +256,7 @@ const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
},
join: {
description: 'Join a game channel',
scopes: [APIKeyScope.WRITE_GAME_CHANNELS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand Down Expand Up @@ -283,6 +289,7 @@ const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
},
leave: {
description: 'Leave a game channel',
scopes: [APIKeyScope.WRITE_GAME_CHANNELS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand All @@ -294,6 +301,7 @@ const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
},
put: {
description: 'Update a game channel',
scopes: [APIKeyScope.WRITE_GAME_CHANNELS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand Down Expand Up @@ -360,6 +368,7 @@ const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
},
delete: {
description: 'Delete a game channel',
scopes: [APIKeyScope.WRITE_GAME_CHANNELS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand All @@ -371,6 +380,7 @@ const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
},
invite: {
description: 'Invite another player to a game channel',
scopes: [APIKeyScope.WRITE_GAME_CHANNELS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand All @@ -385,6 +395,7 @@ const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
},
members: {
description: 'Get the members of a game channel',
scopes: [APIKeyScope.READ_GAME_CHANNELS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand Down Expand Up @@ -433,6 +444,7 @@ const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
},
getStorage: {
description: 'Get a single storage property from a game channel',
scopes: [APIKeyScope.READ_GAME_CHANNELS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand Down Expand Up @@ -498,6 +510,7 @@ const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
},
listStorage: {
description: 'Get multiple storage properties from a game channel',
scopes: [APIKeyScope.READ_GAME_CHANNELS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand Down Expand Up @@ -606,6 +619,7 @@ const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
},
putStorage: {
description: 'Create or update storage properties in a game channel',
scopes: [APIKeyScope.WRITE_GAME_CHANNELS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand Down Expand Up @@ -832,4 +846,4 @@ const GameChannelAPIDocs: APIDocs<GameChannelAPIService> = {
}
}

export default GameChannelAPIDocs
export { GameChannelAPIDocs }
4 changes: 3 additions & 1 deletion src/docs/game-config-api.docs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import GameConfigAPIService from '../services/api/game-config-api.service'
import APIDocs from './api-docs'
import { APIKeyScope } from '../entities/api-key'

const GameConfigAPIDocs: APIDocs<GameConfigAPIService> = {
index: {
description: 'Get the live config for the game',
scopes: [APIKeyScope.READ_GAME_CONFIG],
samples: [
{
title: 'Sample response',
Expand All @@ -19,4 +21,4 @@ const GameConfigAPIDocs: APIDocs<GameConfigAPIService> = {
}
}

export default GameConfigAPIDocs
export { GameConfigAPIDocs }
5 changes: 4 additions & 1 deletion src/docs/game-feedback-api.docs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import GameFeedbackAPIService from '../services/api/game-feedback-api.service'
import APIDocs from './api-docs'
import { APIKeyScope } from '../entities/api-key'

const GameFeedbackAPIDocs: APIDocs<GameFeedbackAPIService> = {
indexCategories: {
description: 'Get available feedback categories',
scopes: [APIKeyScope.READ_GAME_FEEDBACK],
samples: [
{
title: 'Sample response',
Expand All @@ -23,6 +25,7 @@ const GameFeedbackAPIDocs: APIDocs<GameFeedbackAPIService> = {
},
post: {
description: 'Create a player feedback entry',
scopes: [APIKeyScope.WRITE_GAME_FEEDBACK],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand Down Expand Up @@ -102,4 +105,4 @@ const GameFeedbackAPIDocs: APIDocs<GameFeedbackAPIService> = {
}
}

export default GameFeedbackAPIDocs
export { GameFeedbackAPIDocs }
7 changes: 6 additions & 1 deletion src/docs/game-save-api.docs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import GameSaveAPIService from '../services/api/game-save-api.service'
import APIDocs from './api-docs'
import { APIKeyScope } from '../entities/api-key'

const sampleSave = {
id: 143,
Expand Down Expand Up @@ -51,6 +52,7 @@ const sampleSave = {
const GameSaveAPIDocs: APIDocs<GameSaveAPIService> = {
index: {
description: 'Get a player\'s saves',
scopes: [APIKeyScope.READ_GAME_SAVES],
params: {
headers: {
'x-talo-player': 'The ID of the player'
Expand All @@ -67,6 +69,7 @@ const GameSaveAPIDocs: APIDocs<GameSaveAPIService> = {
},
post: {
description: 'Create a save',
scopes: [APIKeyScope.WRITE_GAME_SAVES],
params: {
headers: {
'x-talo-player': 'The ID of the player'
Expand Down Expand Up @@ -94,6 +97,7 @@ const GameSaveAPIDocs: APIDocs<GameSaveAPIService> = {
},
patch: {
description: 'Update a save',
scopes: [APIKeyScope.WRITE_GAME_SAVES],
params: {
headers: {
'x-talo-player': 'The ID of the player'
Expand Down Expand Up @@ -124,6 +128,7 @@ const GameSaveAPIDocs: APIDocs<GameSaveAPIService> = {
},
delete: {
description: 'Delete a save',
scopes: [APIKeyScope.WRITE_GAME_SAVES],
params: {
headers: {
'x-talo-player': 'The ID of the player'
Expand All @@ -135,4 +140,4 @@ const GameSaveAPIDocs: APIDocs<GameSaveAPIService> = {
}
}

export default GameSaveAPIDocs
export { GameSaveAPIDocs }
10 changes: 9 additions & 1 deletion src/docs/game-stat-api.docs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import GameStatAPIService from '../services/api/game-stat-api.service'
import APIDocs from './api-docs'
import { APIKeyScope } from '../entities/api-key'

const GameStatAPIDocs: APIDocs<GameStatAPIService> = {
index: {
description: 'Get all game stats',
scopes: [APIKeyScope.READ_GAME_STATS],
samples: [
{
title: 'Sample response',
Expand Down Expand Up @@ -44,6 +46,7 @@ const GameStatAPIDocs: APIDocs<GameStatAPIService> = {
},
get: {
description: 'Get an individual game stat',
scopes: [APIKeyScope.READ_GAME_STATS],
params: {
route: {
internalName: 'The internal name of the stat'
Expand Down Expand Up @@ -73,6 +76,7 @@ const GameStatAPIDocs: APIDocs<GameStatAPIService> = {
},
getPlayerStat: {
description: 'Get the current value of a player\'s stat',
scopes: [APIKeyScope.READ_GAME_STATS],
params: {
route: {
internalName: 'The internal name of the stat'
Expand Down Expand Up @@ -108,6 +112,7 @@ const GameStatAPIDocs: APIDocs<GameStatAPIService> = {
},
put: {
description: 'Update a stat value',
scopes: [APIKeyScope.WRITE_GAME_STATS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand Down Expand Up @@ -155,6 +160,7 @@ const GameStatAPIDocs: APIDocs<GameStatAPIService> = {
},
history: {
description: 'Get a history of changes to a player stat',
scopes: [APIKeyScope.READ_GAME_STATS],
params: {
headers: {
'x-talo-player': 'The ID of the player'
Expand Down Expand Up @@ -263,6 +269,7 @@ const GameStatAPIDocs: APIDocs<GameStatAPIService> = {
},
globalHistory: {
description: 'Get a history of changes to a global stat',
scopes: [APIKeyScope.READ_GAME_STATS],
params: {
route: {
internalName: 'The internal name of the stat'
Expand Down Expand Up @@ -429,6 +436,7 @@ const GameStatAPIDocs: APIDocs<GameStatAPIService> = {
},
listPlayerStats: {
description: 'Get the current values of all the player\'s stats',
scopes: [APIKeyScope.READ_GAME_STATS],
samples: [
{
title: 'Sample response',
Expand Down Expand Up @@ -481,4 +489,4 @@ const GameStatAPIDocs: APIDocs<GameStatAPIService> = {
}
}

export default GameStatAPIDocs
export { GameStatAPIDocs }
12 changes: 12 additions & 0 deletions src/docs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export * from './player-api.docs'
export * from './game-config-api.docs'
export * from './event-api.docs'
export * from './game-feedback-api.docs'
export * from './game-save-api.docs'
export * from './player-auth-api.docs'
export * from './player-presence-api.docs'
export * from './player-group-api.docs'
export * from './game-channel-api.docs'
export * from './game-stat-api.docs'
export * from './leaderboard-api.docs'
export * from './socket-tickets-api.docs'
5 changes: 4 additions & 1 deletion src/docs/leaderboard-api.docs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import LeaderboardAPIService from '../services/api/leaderboard-api.service'
import APIDocs from './api-docs'
import { APIKeyScope } from '../entities/api-key'

const LeaderboardAPIDocs: APIDocs<LeaderboardAPIService> = {
get: {
description: 'Get a leaderboard\'s entries\n50 results are returned per page, in the sort order defined by the leaderboard',
scopes: [APIKeyScope.READ_LEADERBOARDS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand Down Expand Up @@ -142,6 +144,7 @@ const LeaderboardAPIDocs: APIDocs<LeaderboardAPIService> = {
},
post: {
description: 'Create or update a leaderboard\'s entry\nIf an entry exists for the player and the leaderboard mode is set to unique, that entry will be updated with the new score (and the updated key will return true)',
scopes: [APIKeyScope.WRITE_LEADERBOARDS],
params: {
body: {
score: 'A numeric score for the entry'
Expand Down Expand Up @@ -190,4 +193,4 @@ const LeaderboardAPIDocs: APIDocs<LeaderboardAPIService> = {
}
}

export default LeaderboardAPIDocs
export { LeaderboardAPIDocs }
9 changes: 8 additions & 1 deletion src/docs/player-api.docs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import PlayerAPIService from '../services/api/player-api.service'
import APIDocs from './api-docs'
import { APIKeyScope } from '../entities/api-key'

const PlayerAPIDocs: APIDocs<PlayerAPIService> = {
identify: {
description: 'Identify a player',
scopes: [APIKeyScope.READ_PLAYERS, APIKeyScope.WRITE_PLAYERS],
params: {
headers: {
'x-talo-session': 'The session token (required if using Talo player authentication)'
Expand Down Expand Up @@ -62,6 +64,7 @@ const PlayerAPIDocs: APIDocs<PlayerAPIService> = {
},
search: {
description: 'Search for players',
scopes: [APIKeyScope.READ_PLAYERS],
params: {
route: {
id: 'The ID of the player'
Expand Down Expand Up @@ -128,6 +131,7 @@ const PlayerAPIDocs: APIDocs<PlayerAPIService> = {
},
get: {
description: 'Find a player',
scopes: [APIKeyScope.READ_PLAYERS],
params: {
route: {
id: 'The ID of the player'
Expand Down Expand Up @@ -163,6 +167,7 @@ const PlayerAPIDocs: APIDocs<PlayerAPIService> = {
},
patch: {
description: 'Update a player\'s props',
scopes: [APIKeyScope.WRITE_PLAYERS],
params: {
body: {
props: 'An array of @type(Props:prop). Props that the player doesn\'t have will be added. Props with updated values will overwrite existing props. Props with a null value will be deleted from the player'
Expand Down Expand Up @@ -209,6 +214,7 @@ const PlayerAPIDocs: APIDocs<PlayerAPIService> = {
},
merge: {
description: 'Merge two players',
scopes: [APIKeyScope.READ_PLAYERS, APIKeyScope.WRITE_PLAYERS],
params: {
body: {
playerId1: 'The first player ID - the second player will be merged into this player',
Expand Down Expand Up @@ -252,6 +258,7 @@ const PlayerAPIDocs: APIDocs<PlayerAPIService> = {
},
socketToken: {
description: 'Create a socket token for a player',
scopes: [APIKeyScope.WRITE_PLAYERS],
params: {
headers: {
'x-talo-alias': 'The ID of the player\'s alias'
Expand All @@ -268,4 +275,4 @@ const PlayerAPIDocs: APIDocs<PlayerAPIService> = {
}
}

export default PlayerAPIDocs
export { PlayerAPIDocs }
Loading