Skip to content

Commit

Permalink
feat: add type to import statements in server
Browse files Browse the repository at this point in the history
  • Loading branch information
agrattan0820 committed Jun 28, 2024
1 parent c0e3b4c commit dee4691
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions apps/server/src/handlers/connection.handler.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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<ClientToServerEvents, ServerToClientEvents>,
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/handlers/game.handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Server, Socket } from "socket.io";
import type { Server, Socket } from "socket.io";

import {
createGame,
Expand All @@ -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";

Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/handlers/generation.handler.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/handlers/room.handler.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/handlers/vote.handler.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/middleware/auth.middleware.ts
Original file line number Diff line number Diff line change
@@ -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<ClientToServerEvents, ServerToClientEvents>
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/services/generation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/services/user.service.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/services/vote.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
votes,
questionsToGames,
} from "database";
import { UserVote } from "../types";
import type { UserVote } from "../types";

export async function createVote({
userId,
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/tests/generation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/tests/question.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/tests/room.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/tests/vote.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Generation, Question, RoomInfo, User, Vote } from "database";
import type { Generation, Question, RoomInfo, User, Vote } from "database";

type StateMachineEvent =
| {
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/utils.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down

0 comments on commit dee4691

Please sign in to comment.