@@ -2,6 +2,12 @@ import type { ServerRoute } from '@hapi/hapi';
2
2
3
3
import { getAuthUser } from '../../api-utils/getAuthUser' ;
4
4
import { CAPABILITIES } from '../../api-utils/interfaceAndTypes' ;
5
+ import {
6
+ getAcheivementByIdResponseSchema ,
7
+ getAcheivementsResponseSchema ,
8
+ postAcheivementRequestSchema ,
9
+ postAcheivementResponseSchema ,
10
+ } from '../../api-utils/schemas/gameDev/acheivementsSchemas' ;
5
11
import {
6
12
gamedevGenericSchema ,
7
13
multipleGamesSchema ,
@@ -21,6 +27,9 @@ import {
21
27
getLeaderboardHandler ,
22
28
upsertLeaderboardHandler ,
23
29
deleteLeaderboardHandler ,
30
+ getAcheivementsHandler ,
31
+ upsertAcheivementHandler ,
32
+ deleteAcheivementHandler ,
24
33
} from './gameDevHandlers' ;
25
34
26
35
declare module '@hapi/hapi' {
@@ -211,6 +220,98 @@ export const upsertLeaderboardRoute: ServerRoute = {
211
220
handler : upsertLeaderboardHandler ,
212
221
} ;
213
222
223
+ //Acheivements
224
+ export const getAcheivementsRoute : ServerRoute = {
225
+ method : 'GET' ,
226
+ path : '/dashboard/game-dev/games/{gameTypeId}/acheivements' ,
227
+ options : {
228
+ description : `Get game's acheivements` ,
229
+ tags : [ 'api' ] ,
230
+ bind : {
231
+ requiredCapabilities : [ CAPABILITIES . GAMEDEV_ACTIONS ] ,
232
+ } ,
233
+ pre : [
234
+ {
235
+ method : getAuthUser ,
236
+ assign : 'getAuthUser' ,
237
+ } ,
238
+ ] ,
239
+ response : {
240
+ schema : getAcheivementsResponseSchema ,
241
+ } ,
242
+ } ,
243
+ handler : getAcheivementsHandler ,
244
+ } ;
245
+
246
+ export const getAcheivementsByIdRoute : ServerRoute = {
247
+ method : 'GET' ,
248
+ path : '/dashboard/game-dev/games/{gameTypeId}/acheivements/{acheivementId}' ,
249
+ options : {
250
+ description : `Get game's acheivements` ,
251
+ tags : [ 'api' ] ,
252
+ bind : {
253
+ requiredCapabilities : [ CAPABILITIES . GAMEDEV_ACTIONS ] ,
254
+ } ,
255
+ pre : [
256
+ {
257
+ method : getAuthUser ,
258
+ assign : 'getAuthUser' ,
259
+ } ,
260
+ ] ,
261
+ response : {
262
+ schema : getAcheivementByIdResponseSchema ,
263
+ } ,
264
+ } ,
265
+ handler : getAcheivementsHandler ,
266
+ } ;
267
+
268
+ export const upsertAcheivementsRoute : ServerRoute = {
269
+ method : 'POST' ,
270
+ path : '/dashboard/game-dev/games/{gameTypeId}/acheivements' ,
271
+ options : {
272
+ description : `Add or update a game's acheivement` ,
273
+ tags : [ 'api' ] ,
274
+ bind : {
275
+ requiredCapabilities : [ CAPABILITIES . GAMEDEV_ACTIONS ] ,
276
+ } ,
277
+ pre : [
278
+ {
279
+ method : getAuthUser ,
280
+ assign : 'getAuthUser' ,
281
+ } ,
282
+ ] ,
283
+ validate : {
284
+ payload : postAcheivementRequestSchema ,
285
+ } ,
286
+ response : {
287
+ schema : postAcheivementResponseSchema ,
288
+ } ,
289
+ } ,
290
+ handler : upsertAcheivementHandler ,
291
+ } ;
292
+
293
+ export const deleteAcheivementsRoute : ServerRoute = {
294
+ method : 'DELETE' ,
295
+ path : '/dashboard/game-dev/games/{gameTypeId}/acheivements/{acheivementId}' ,
296
+ options : {
297
+ description : `Delete a game's acheivement` ,
298
+ tags : [ 'api' ] ,
299
+ bind : {
300
+ requiredCapabilities : [ CAPABILITIES . GAMEDEV_ACTIONS ] ,
301
+ } ,
302
+ pre : [
303
+ {
304
+ method : getAuthUser ,
305
+ assign : 'getAuthUser' ,
306
+ } ,
307
+ ] ,
308
+ response : {
309
+ schema : gamedevGenericSchema ,
310
+ } ,
311
+ } ,
312
+ handler : deleteAcheivementHandler ,
313
+ } ;
314
+
214
315
export const gameDevRoutes : ServerRoute [ ] = [
215
316
// 🎮 Games
216
317
getGameTypesRoute ,
@@ -221,4 +322,8 @@ export const gameDevRoutes: ServerRoute[] = [
221
322
getLeaderboardByIdRoute ,
222
323
upsertLeaderboardRoute ,
223
324
deleteLeaderboardRoute ,
325
+ getAcheivementsRoute ,
326
+ getAcheivementsByIdRoute ,
327
+ upsertAcheivementsRoute ,
328
+ deleteAcheivementsRoute ,
224
329
] ;
0 commit comments