-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upload image to create a question game (#77)
* Upload image for create endpoint * Upload image to create question game
- Loading branch information
1 parent
e68fa92
commit 45e105d
Showing
10 changed files
with
292 additions
and
175 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
prisma/migrations/20241021170629_question_game_image/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
Warnings: | ||
- Added the required column `imageUrl` to the `QuestionGame` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "QuestionGame" ADD COLUMN "imageUrl" TEXT NOT NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,28 @@ | ||
import { z } from "zod"; | ||
import { adminProcedure, Controller } from '~/server/api/trpc'; | ||
import { assertHasCreateQuestionGameControl } from "../../middleware"; | ||
import { adminProcedure, Controller } from "~/server/api/trpc"; | ||
import { InputSchema, OutputSchema } from "../schema/create"; | ||
import { db } from "~/server/db"; | ||
|
||
|
||
const handler: Controller< | ||
z.infer<typeof InputSchema>, | ||
z.infer<typeof OutputSchema> | ||
> = async ({input, ctx}) => { | ||
await assertHasCreateQuestionGameControl({ctx}); | ||
z.infer<typeof InputSchema>, | ||
z.infer<typeof OutputSchema> | ||
> = async ({ input, ctx }) => { | ||
const game = await db.questionGame.create({ | ||
data: { | ||
title: input.title, | ||
imageUrl: input.imageUrl, | ||
}, | ||
select: { | ||
id: true, | ||
}, | ||
}); | ||
|
||
const game = await db.questionGame.create({ | ||
data: { | ||
title: input.title, | ||
}, | ||
select: { | ||
id: true | ||
} | ||
}); | ||
|
||
return { | ||
questionGameId: game.id | ||
} | ||
} | ||
return { | ||
questionGameId: game.id, | ||
}; | ||
}; | ||
|
||
export default adminProcedure | ||
.input(InputSchema) | ||
.output(OutputSchema) | ||
.mutation(handler); | ||
|
||
|
||
.input(InputSchema) | ||
.output(OutputSchema) | ||
.mutation(handler); |
Oops, something went wrong.