-
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.
- Loading branch information
Showing
17 changed files
with
173 additions
and
12 deletions.
There are no files selected for viewing
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,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
11 changes: 11 additions & 0 deletions
11
prisma/migrations/20240716180540_added_game_records/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,11 @@ | ||
/* | ||
Warnings: | ||
- Added the required column `addedByUserId` to the `GameRecord` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE `GameRecord` ADD COLUMN `addedByUserId` INTEGER NOT NULL; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE `GameRecord` ADD CONSTRAINT `GameRecord_addedByUserId_fkey` FOREIGN KEY (`addedByUserId`) REFERENCES `User`(`userId`) ON DELETE RESTRICT ON UPDATE CASCADE; |
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,2 @@ | ||
-- AlterTable | ||
ALTER TABLE `GameRecord` MODIFY `gameType` ENUM('P4_TOUPUUSEN', 'P3_TOUPUUSEN', 'P4_HANCHAN', 'P3_HANCHAN', 'P3_TABOO') NOT NULL; |
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20240716185547_user_last_game_at/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,2 @@ | ||
-- AlterTable | ||
ALTER TABLE `User` ADD COLUMN `lastGameAt` DATETIME(3) 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { RequestHandler } from "express"; | ||
import { gameTypes } from "src/model/gameType/general"; | ||
import { toGameTypeDetailsResponse } from "src/model/gameType/types"; | ||
|
||
const handler: RequestHandler = (req, res) => { | ||
res.send( | ||
Object.entries(gameTypes) | ||
.sort((a, b) => { | ||
return a[1].index - b[1].index; | ||
}) | ||
.map(([k, v]) => toGameTypeDetailsResponse(k, v)) | ||
); | ||
}; | ||
|
||
export default handler; |
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 @@ | ||
import { Router } from "express"; | ||
import $get from "./$get"; | ||
|
||
const router = Router(); | ||
|
||
router.get("/", $get); | ||
|
||
export default router; |
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,10 @@ | ||
import { Router } from "express"; | ||
import game_types from "./game_types"; | ||
import jyanshis from "./jyanshis"; | ||
|
||
const router = Router(); | ||
|
||
router.use("/game_types", game_types); | ||
router.use("/jyanshis", jyanshis); | ||
|
||
export default router; |
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,18 @@ | ||
import { RequestHandler } from "express"; | ||
import db from "src/database/db"; | ||
import { toUserResponse } from "src/model/user/types"; | ||
|
||
const handler: RequestHandler = async (req, res) => { | ||
const users = await db.user.findMany({ | ||
orderBy: { | ||
lastGameAt: { | ||
sort: "desc", | ||
nulls: "last", | ||
}, | ||
}, | ||
}); | ||
|
||
res.send(users.map((u) => toUserResponse(u))); | ||
}; | ||
|
||
export default handler; |
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,9 @@ | ||
import { Router } from "express"; | ||
import { wrap } from "src/utils/asyncWrapper"; | ||
import $get from "./$get"; | ||
|
||
const router = Router(); | ||
|
||
router.get("/", wrap($get)); | ||
|
||
export default router; |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { GameTypeDetails } from "./general"; | ||
|
||
export const toGameTypeDetailsResponse = ( | ||
type: string, | ||
{ players, totalScore, scoreType, winds, displayName }: GameTypeDetails | ||
) => { | ||
return { | ||
type, | ||
players, | ||
totalScore, | ||
scoreType, | ||
winds, | ||
displayName, | ||
}; | ||
}; |
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