Skip to content

Commit aac4878

Browse files
authored
Merge pull request #115 from TaloDev/develop
Release 0.17.0
2 parents 160e9ba + 507f00e commit aac4878

23 files changed

+561
-278
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "game-services",
3-
"version": "0.16.0",
3+
"version": "0.17.0",
44
"description": "",
55
"main": "src/index.ts",
66
"scripts": {
@@ -68,7 +68,7 @@
6868
"jsonwebtoken": "^8.5.1",
6969
"koa": "^2.13.4",
7070
"koa-bodyparser": "^4.3.0",
71-
"koa-clay": "^6.1.1",
71+
"koa-clay": "^6.2.0",
7272
"koa-helmet": "^6.1.0",
7373
"koa-jwt": "^4.0.3",
7474
"koa-logger": "^3.2.1",

src/docs/event-api.docs.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { RouteDocs } from 'koa-clay'
2+
3+
const EventAPIDocs: Record<string, RouteDocs> = {
4+
post: {
5+
description: 'Track events',
6+
params: {
7+
body: {
8+
events: 'An array of @type(EventData:eventdata)'
9+
}
10+
},
11+
samples: [
12+
{
13+
title: 'Sample request',
14+
sample: {
15+
events: [
16+
{ aliasId: 1, name: 'Levelled up', timestamp: 1657063169020, props: [{ key: 'newLevel', value: '81' }] },
17+
{ aliasId: 1, name: 'Quest completed', timestamp: 1657063169324, props: [{ key: 'questId', value: '122' }] },
18+
{ aliasId: 1, name: 'Quested started', timestamp: 1657063169819, props: [{ key: 'questId', value: '128' }] }
19+
]
20+
}
21+
},
22+
{
23+
title: 'Sample response',
24+
sample: {
25+
events: [
26+
{ aliasId: 1, name: 'Levelled up', timestamp: 1657063169020, props: [{ key: 'newLevel', value: '81' }] },
27+
{ aliasId: 1, name: 'Quest completed', timestamp: 1657063169324, props: [{ key: 'questId', value: '122' }] }
28+
],
29+
errors: [
30+
'Event is missing the key: timestamp'
31+
]
32+
}
33+
}
34+
]
35+
}
36+
}
37+
38+
export default EventAPIDocs

src/docs/game-save-api.docs.ts

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import { RouteDocs } from 'koa-clay'
2+
3+
const sampleSave = {
4+
id: 143,
5+
name: 'Autosave 86 - Blade Merchant Shop',
6+
content: {
7+
objects: [
8+
{
9+
id: 'b9339e0a-b91b-439e-bb30-b3b6f23d8159',
10+
name: 'Interactables.Items.SmallKnife',
11+
data: [
12+
{
13+
key: 'pickedUp',
14+
value: 'True',
15+
type: 'System.Boolean'
16+
},
17+
{
18+
key: 'meta.destroyed',
19+
value: 'True',
20+
type: 'System.Boolean'
21+
}
22+
]
23+
},
24+
{
25+
id: '9b772ede-ddd0-4dc0-aaf3-e59c9258e672',
26+
name: 'NPCs.BladeMerchant',
27+
data: [
28+
{
29+
key: 'lastWords',
30+
value: 'Wait...where did you find that knife?',
31+
type: 'System.String'
32+
},
33+
{
34+
key: 'isAlive',
35+
value: 'False',
36+
type: 'System.Boolean'
37+
},
38+
{
39+
key: 'meta.destroyed',
40+
value: 'False',
41+
type: 'System.Boolean'
42+
}
43+
]
44+
}
45+
]
46+
},
47+
updatedAt: '2022-06-07 14:58:13'
48+
}
49+
50+
const GameSaveAPIDocs: Record<string, RouteDocs> = {
51+
index: {
52+
description: 'Get a player\'s saves',
53+
params: {
54+
query: {
55+
aliasId: 'The ID of the player\'s alias'
56+
}
57+
},
58+
samples: [
59+
{
60+
title: 'Sample response',
61+
sample: {
62+
saves: [sampleSave]
63+
}
64+
}
65+
]
66+
},
67+
post: {
68+
description: 'Create a save',
69+
params: {
70+
body: {
71+
name: 'The name of the save',
72+
content: 'The @type(SaveContent:savecontent) of the save file',
73+
aliasId: 'The ID of the player\'s alias'
74+
}
75+
},
76+
samples: [
77+
{
78+
title: 'Sample request',
79+
sample: {
80+
name: sampleSave.name,
81+
content: sampleSave.content,
82+
aliasId: 15
83+
}
84+
},
85+
{
86+
title: 'Sample response',
87+
sample: {
88+
save: sampleSave
89+
}
90+
}
91+
]
92+
},
93+
patch: {
94+
description: 'Update a save',
95+
params: {
96+
body: {
97+
name: 'A new name for the save',
98+
content: 'The new @type(SaveContent:savecontent) for the save',
99+
aliasId: 'The ID of the player\'s alias'
100+
},
101+
route: {
102+
id: 'The ID of the save'
103+
}
104+
},
105+
samples: [
106+
{
107+
title: 'Sample request',
108+
sample: {
109+
name: sampleSave.name,
110+
content: sampleSave.content,
111+
aliasId: 15
112+
}
113+
},
114+
{
115+
title: 'Sample response',
116+
sample: {
117+
save: sampleSave
118+
}
119+
}
120+
]
121+
}
122+
}
123+
124+
export default GameSaveAPIDocs

src/docs/game-stat-api.docs.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { RouteDocs } from 'koa-clay'
2+
3+
const GameStatAPIDocs: Record<string, RouteDocs> = {
4+
put: {
5+
description: 'Update a stat value',
6+
params: {
7+
body: {
8+
aliasId: 'The ID of the player\'s alias',
9+
change: 'The amount to add to the current value of the stat (can be negative)'
10+
},
11+
route: {
12+
internalName: 'The internal name of the stat'
13+
}
14+
},
15+
samples: [
16+
{
17+
title: 'Sample request',
18+
sample: {
19+
aliasId: 1,
20+
change: 47
21+
}
22+
},
23+
{
24+
title: 'Sample response',
25+
sample: {
26+
playerStat: {
27+
id: 15,
28+
stat: {
29+
id: 4,
30+
internalName: 'gold-collected',
31+
name: 'Gold collected',
32+
global: true,
33+
globalValue: 5839,
34+
defaultValue: 0,
35+
maxChange: Infinity,
36+
minValue: 0,
37+
maxValue: Infinity,
38+
minTimeBetweenUpdates: 5,
39+
createdAt: '2021-12-24 12:45:39',
40+
updatedAt: '2021-12-24 12:49:14'
41+
},
42+
value: 52,
43+
createdAt: '2022-01-01 06:18:11',
44+
updatedAt: '2022-01-03 08:32:46'
45+
}
46+
}
47+
}
48+
]
49+
}
50+
}
51+
52+
export default GameStatAPIDocs

src/docs/leaderboard-api.docs.ts

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import { RouteDocs } from 'koa-clay'
2+
3+
const LeaderboardAPIDocs: Record<string, RouteDocs> = {
4+
get: {
5+
description: 'Get a leaderboard\'s entries\n50 results are returned per page, in the sort order defined by the leaderboard',
6+
params: {
7+
route: {
8+
internalName: 'The internal name of the leaderboard'
9+
},
10+
query: {
11+
page: 'The current pagination index (starting at 0)'
12+
}
13+
},
14+
samples: [
15+
{
16+
title: 'Sample response',
17+
sample: {
18+
entries: [
19+
{
20+
id: 4,
21+
position: 0,
22+
score: 593.21,
23+
leaderboardName: 'Highscore',
24+
leaderboardInternalName: 'highscore',
25+
playerAlias: {
26+
id: 1,
27+
service: 'steam',
28+
identifier: '11133645',
29+
player: {
30+
id: '7a4e70ec-6ee6-418e-923d-b3a45051b7f9',
31+
props: [
32+
{ key: 'xPos', value: '13.29' },
33+
{ key: 'yPos', value: '26.44' }
34+
],
35+
aliases: [
36+
'/* [Circular] */'
37+
],
38+
devBuild: false,
39+
createdAt: '2022-01-15 13:20:32',
40+
lastSeenAt: '2022-04-12 15:09:43'
41+
}
42+
},
43+
hidden: false,
44+
createdAt: '2022-01-15 14:01:18',
45+
updatedAt: '2022-01-15 14:01:18'
46+
},
47+
{
48+
id: 29,
49+
position: 1,
50+
score: 400.06,
51+
leaderboardName: 'Highscore',
52+
leaderboardInternalName: 'highscore',
53+
playerAlias: {
54+
id: 1,
55+
service: 'epic',
56+
identifier: '44661821',
57+
player: {
58+
id: '1c4d8680-8865-4bfa-8212-f9a405e77897',
59+
props: [
60+
{ key: 'xPos', value: '117.33' },
61+
{ key: 'yPos', value: '-50.80' }
62+
],
63+
aliases: [
64+
'/* [Circular] */'
65+
],
66+
devBuild: false,
67+
createdAt: '2022-06-15 14:13:16',
68+
lastSeenAt: '2022-06-15 15:01:55'
69+
}
70+
},
71+
hidden: false,
72+
createdAt: '2022-06-15 14:48:11',
73+
updatedAt: '2022-06-15 14:48:11'
74+
},
75+
'/* ...48 more entries */'
76+
],
77+
count: 126,
78+
isLastPage: false
79+
}
80+
}
81+
]
82+
},
83+
post: {
84+
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)',
85+
params: {
86+
body: {
87+
aliasId: 'The ID of the player\'s alias',
88+
score: 'A numeric score for the entry'
89+
},
90+
route: {
91+
internalName: 'The internal name of the leaderboard'
92+
}
93+
},
94+
samples: [
95+
{
96+
title: 'Sample response',
97+
sample: {
98+
entry: {
99+
id: 4,
100+
position: 0,
101+
score: 593.21,
102+
leaderboardName: 'Highscore',
103+
leaderboardInternalName: 'highscore',
104+
playerAlias: {
105+
id: 1,
106+
service: 'steam',
107+
identifier: '11133645',
108+
player: {
109+
id: '7a4e70ec-6ee6-418e-923d-b3a45051b7f9',
110+
props: [
111+
{ key: 'xPos', value: '13.29' },
112+
{ key: 'yPos', value: '26.44' }
113+
],
114+
aliases: [
115+
'/* [Circular] */'
116+
],
117+
devBuild: false,
118+
createdAt: '2022-01-15 13:20:32',
119+
lastSeenAt: '2022-04-12 15:09:43'
120+
}
121+
},
122+
hidden: false,
123+
createdAt: '2022-01-15 14:01:18',
124+
updatedAt: '2022-02-16 16:03:53'
125+
},
126+
updated: true
127+
}
128+
}
129+
]
130+
}
131+
}
132+
133+
export default LeaderboardAPIDocs

0 commit comments

Comments
 (0)