X-Git-Url: https://git.xangelo.ca/?p=sketchy-heroes.git;a=blobdiff_plain;f=src%2Froutes%2Fplayer%2Finfo.ts;fp=src%2Froutes%2Fplayer%2Finfo.ts;h=06e1ddcde19325d06f0d0bf1a1d1abe92b35bd1b;hp=0000000000000000000000000000000000000000;hb=7aa7248bc4f3f59a002beb98fa889a9da3c25866;hpb=9cec2c639563092ed050716db1e7e4657f937bf5 diff --git a/src/routes/player/info.ts b/src/routes/player/info.ts new file mode 100644 index 0000000..06e1ddc --- /dev/null +++ b/src/routes/player/info.ts @@ -0,0 +1,30 @@ +import { server } from '../../lib/server'; +import { Static, Type } from '@sinclair/typebox'; +import { prisma } from '../../lib/db'; +import { ForbiddenError } from '../../lib/http-errors'; +import {Player} from '@prisma/client'; + +const PlayerInput = Type.Object({ + params: Type.Object({ + playerId: Type.String() + }) +}); + +type PlayerInputType = Static; + +export const playerInfo = server.get('/v1/accounts/:playerId', { + schema: PlayerInput, + authenicated: true +}, async req => { + const player = await prisma.player.findUnique({ + where: { + id: req.params.playerId + } + }); + + if(!player) { + throw new ForbiddenError('Not allowed'); + } + + return player; +});