From dee4691867aab7a4b6ba255346f2d638d7016d26 Mon Sep 17 00:00:00 2001 From: GameDog9988 Date: Fri, 28 Jun 2024 15:44:41 -0400 Subject: [PATCH] feat: add type to import statements in server --- apps/server/src/handlers/connection.handler.ts | 4 ++-- apps/server/src/handlers/game.handler.ts | 4 ++-- apps/server/src/handlers/generation.handler.ts | 4 ++-- apps/server/src/handlers/room.handler.ts | 4 ++-- apps/server/src/handlers/vote.handler.ts | 4 ++-- apps/server/src/middleware/auth.middleware.ts | 4 ++-- apps/server/src/server.ts | 2 +- apps/server/src/services/generation.service.ts | 2 +- apps/server/src/services/user.service.ts | 2 +- apps/server/src/services/vote.service.ts | 2 +- apps/server/src/tests/generation.test.ts | 2 +- apps/server/src/tests/question.test.ts | 2 +- apps/server/src/tests/room.test.ts | 2 +- apps/server/src/tests/vote.test.ts | 2 +- apps/server/src/types.ts | 2 +- apps/server/src/utils.ts | 4 ++-- 16 files changed, 23 insertions(+), 23 deletions(-) diff --git a/apps/server/src/handlers/connection.handler.ts b/apps/server/src/handlers/connection.handler.ts index a4bb2e17..a83a7e5d 100644 --- a/apps/server/src/handlers/connection.handler.ts +++ b/apps/server/src/handlers/connection.handler.ts @@ -1,6 +1,5 @@ -import { Server, Socket } from "socket.io"; +import type { Server, Socket } from "socket.io"; -import { ClientToServerEvents, ServerToClientEvents } from "../types"; import { checkRoomForUserAndAdd, findNextHost, @@ -10,6 +9,7 @@ import { } from "../services/room.service"; import { handleSocketError } from "../utils"; import redis from "../redis"; +import type { ClientToServerEvents, ServerToClientEvents } from "../types"; export async function checkIfExistingUser( io: Server, diff --git a/apps/server/src/handlers/game.handler.ts b/apps/server/src/handlers/game.handler.ts index f13a18cf..f1f25a69 100644 --- a/apps/server/src/handlers/game.handler.ts +++ b/apps/server/src/handlers/game.handler.ts @@ -1,4 +1,4 @@ -import { Server, Socket } from "socket.io"; +import type { Server, Socket } from "socket.io"; import { createGame, @@ -7,7 +7,7 @@ import { } from "../services/game.service"; import { assignQuestionsToPlayers } from "../services/question.service"; import { getRoom } from "../services/room.service"; -import { ClientToServerEvents, ServerToClientEvents } from "../types"; +import type { ClientToServerEvents, ServerToClientEvents } from "../types"; import { handleSocketError } from "../utils"; import redis from "../redis"; diff --git a/apps/server/src/handlers/generation.handler.ts b/apps/server/src/handlers/generation.handler.ts index 7ef2984a..5c4b8bf7 100644 --- a/apps/server/src/handlers/generation.handler.ts +++ b/apps/server/src/handlers/generation.handler.ts @@ -1,6 +1,6 @@ -import { Server, Socket } from "socket.io"; +import type { Server, Socket } from "socket.io"; -import { ClientToServerEvents, ServerToClientEvents } from "../types"; +import type { ClientToServerEvents, ServerToClientEvents } from "../types"; import { handleSocketError } from "../utils"; import { getFaceOffGenerations, diff --git a/apps/server/src/handlers/room.handler.ts b/apps/server/src/handlers/room.handler.ts index c0446281..55bf68a2 100644 --- a/apps/server/src/handlers/room.handler.ts +++ b/apps/server/src/handlers/room.handler.ts @@ -1,6 +1,6 @@ -import { Server, Socket } from "socket.io"; +import type { Server, Socket } from "socket.io"; -import { ClientToServerEvents, ServerToClientEvents } from "../types"; +import type { ClientToServerEvents, ServerToClientEvents } from "../types"; import { findNextHost, getRoom, diff --git a/apps/server/src/handlers/vote.handler.ts b/apps/server/src/handlers/vote.handler.ts index 2fa711c0..9f8d6367 100644 --- a/apps/server/src/handlers/vote.handler.ts +++ b/apps/server/src/handlers/vote.handler.ts @@ -1,6 +1,6 @@ -import { Server, Socket } from "socket.io"; +import type { Server, Socket } from "socket.io"; -import { ClientToServerEvents, ServerToClientEvents } from "../types"; +import type { ClientToServerEvents, ServerToClientEvents } from "../types"; import { handleSocketError } from "../utils"; import { getGameInfo } from "../services/game.service"; import { diff --git a/apps/server/src/middleware/auth.middleware.ts b/apps/server/src/middleware/auth.middleware.ts index d20ff691..0cd77c22 100644 --- a/apps/server/src/middleware/auth.middleware.ts +++ b/apps/server/src/middleware/auth.middleware.ts @@ -1,7 +1,7 @@ -import { Server } from "socket.io"; -import { ClientToServerEvents, ServerToClientEvents } from "../types"; +import type { Server } from "socket.io"; import { parseCookie } from "../utils"; import { checkUserSession } from "../services/user.service"; +import type { ClientToServerEvents, ServerToClientEvents } from "../types"; export function authSocketMiddleware( io: Server diff --git a/apps/server/src/server.ts b/apps/server/src/server.ts index be503bd5..799b315f 100644 --- a/apps/server/src/server.ts +++ b/apps/server/src/server.ts @@ -15,7 +15,7 @@ import * as Sentry from "@sentry/node"; import { userRoutes } from "./routes/user.route"; import { roomRoutes } from "./routes/room.route"; -import { ClientToServerEvents, ServerToClientEvents } from "./types"; +import type { ClientToServerEvents, ServerToClientEvents } from "./types"; import { gameRoutes } from "./routes/game.route"; import { generationRoutes } from "./routes/generation.route"; import { diff --git a/apps/server/src/services/generation.service.ts b/apps/server/src/services/generation.service.ts index 7be49b3d..49a3f108 100644 --- a/apps/server/src/services/generation.service.ts +++ b/apps/server/src/services/generation.service.ts @@ -8,8 +8,8 @@ import { questionsToGames, users, } from "database"; -import { GameRoundGeneration, QuestionGenerations } from "../types"; import { replicate } from "../replicate"; +import type { GameRoundGeneration, QuestionGenerations } from "../types"; export async function getGameRoundGenerations({ gameId, diff --git a/apps/server/src/services/user.service.ts b/apps/server/src/services/user.service.ts index 29623c49..23d61f09 100644 --- a/apps/server/src/services/user.service.ts +++ b/apps/server/src/services/user.service.ts @@ -1,6 +1,6 @@ -import { db, sessions, users } from "database"; import crypto from "crypto"; import { and, eq, gt } from "drizzle-orm"; +import { db, sessions, users } from "database"; export async function createUser({ nickname }: { nickname: string }) { const newUser = await db diff --git a/apps/server/src/services/vote.service.ts b/apps/server/src/services/vote.service.ts index bba45b0d..8120528e 100644 --- a/apps/server/src/services/vote.service.ts +++ b/apps/server/src/services/vote.service.ts @@ -9,7 +9,7 @@ import { votes, questionsToGames, } from "database"; -import { UserVote } from "../types"; +import type { UserVote } from "../types"; export async function createVote({ userId, diff --git a/apps/server/src/tests/generation.test.ts b/apps/server/src/tests/generation.test.ts index c99c1528..92d51f70 100644 --- a/apps/server/src/tests/generation.test.ts +++ b/apps/server/src/tests/generation.test.ts @@ -2,7 +2,7 @@ import crypto from "crypto"; import { describe, expect, test } from "@jest/globals"; import { filterFaceOffGenerationsByQuestionId } from "../services/generation.service"; -import { GameRoundGeneration } from "../types"; +import type { GameRoundGeneration } from "../types"; describe("filterGameRoundGenerationsByQuestionId", () => { test("expects the filtered array to not have any generations from other questions", () => { diff --git a/apps/server/src/tests/question.test.ts b/apps/server/src/tests/question.test.ts index 829df902..04f66c0b 100644 --- a/apps/server/src/tests/question.test.ts +++ b/apps/server/src/tests/question.test.ts @@ -1,5 +1,5 @@ import crypto from "crypto"; -import { User } from "database"; +import type { User } from "database"; import { describe, expect, test } from "@jest/globals"; import { prepareQuestionsForGame } from "../services/question.service"; diff --git a/apps/server/src/tests/room.test.ts b/apps/server/src/tests/room.test.ts index c3774387..857d474e 100644 --- a/apps/server/src/tests/room.test.ts +++ b/apps/server/src/tests/room.test.ts @@ -1,5 +1,5 @@ import crypto from "crypto"; -import { User } from "database"; +import type { User } from "database"; import { describe, expect, test } from "@jest/globals"; import { findNextHost } from "../services/room.service"; diff --git a/apps/server/src/tests/vote.test.ts b/apps/server/src/tests/vote.test.ts index 2ab01cc4..3b28d9cf 100644 --- a/apps/server/src/tests/vote.test.ts +++ b/apps/server/src/tests/vote.test.ts @@ -1,6 +1,6 @@ import crypto from "crypto"; import { describe, expect, test } from "@jest/globals"; -import { Generation } from "database"; +import type { Generation } from "database"; import { calculateVotePoints, createVoteMap } from "../services/vote.service"; import { UserVote } from "../types"; diff --git a/apps/server/src/types.ts b/apps/server/src/types.ts index bc13bb02..285fc1e1 100644 --- a/apps/server/src/types.ts +++ b/apps/server/src/types.ts @@ -1,4 +1,4 @@ -import { Generation, Question, RoomInfo, User, Vote } from "database"; +import type { Generation, Question, RoomInfo, User, Vote } from "database"; type StateMachineEvent = | { diff --git a/apps/server/src/utils.ts b/apps/server/src/utils.ts index 116e3703..06767d63 100644 --- a/apps/server/src/utils.ts +++ b/apps/server/src/utils.ts @@ -1,6 +1,6 @@ -import { Socket } from "socket.io"; import * as Sentry from "@sentry/node"; -import { ClientToServerEvents, ServerToClientEvents } from "./types"; +import type { Socket } from "socket.io"; +import type { ClientToServerEvents, ServerToClientEvents } from "./types"; export function getRandomInt(min: number, max: number) { min = Math.ceil(min);