Skip to content

Commit 3f50e2d

Browse files
authored
Merge pull request #23 from x-team/develop
Mergin HotFix
2 parents c9cbc17 + bd8fb0f commit 3f50e2d

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/api-utils/responseSchemas/gamedev.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import Joi from 'joi';
22

33
const gameItemSchema = Joi.object({
44
// Pending due to new table design
5-
}).required(); //.options({ stripUnknown: true });
5+
id: Joi.string(),
6+
clientSecret: Joi.string(),
7+
signingSecret: Joi.string(),
8+
_createdById: Joi.number(),
9+
}).optional(); //.options({ stripUnknown: true });
610

711
export const sigleGameItemSchema = Joi.object({ game: gameItemSchema }).required(); //.options({ stripUnknown: true });
812

src/api-utils/utils.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { Model } from 'sequelize-typescript';
2+
3+
export const arrayToJSON = <T extends Model>(entities: Array<T>) => {
4+
return entities.map((entity) => entity.toJSON());
5+
};

src/modules/gameDevs/gameDevHandlers.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Boom from '@hapi/boom';
22
import { Lifecycle, Request, ResponseToolkit } from '@hapi/hapi';
33
import { CustomRequestThis } from '../../api-utils/interfaceAndTypes';
4+
import { arrayToJSON } from '../../api-utils/utils';
45

56
import {
67
createOrUpdateGameType,
@@ -17,7 +18,7 @@ export const getGameTypeHandler: Lifecycle.Method = async (request, h) => {
1718
if (authUser.id !== game?._createdById) {
1819
throw Boom.forbidden('User is not the owner of the game');
1920
}
20-
return h.response({ game }).code(200);
21+
return h.response({ game: game?.toJSON() }).code(200);
2122
};
2223

2324
export async function getGameTypesHandler(
@@ -27,7 +28,7 @@ export async function getGameTypesHandler(
2728
) {
2829
const authUser = request.pre.getAuthUser;
2930
const games = await findAllGameTypesByCreator(authUser.id);
30-
return h.response({ games }).code(200);
31+
return h.response({ games: arrayToJSON(games) }).code(200);
3132
}
3233

3334
export const upsertGameTypeHandler: Lifecycle.Method = async (request, h) => {

0 commit comments

Comments
 (0)