diff --git a/nextjs/src/app/api/trpc/[trpc]/route.ts b/nextjs/src/app/api/trpc/[trpc]/route.ts index ab28aca..84c8004 100644 --- a/nextjs/src/app/api/trpc/[trpc]/route.ts +++ b/nextjs/src/app/api/trpc/[trpc]/route.ts @@ -1,5 +1,5 @@ -import { createTrpcContext } from "@/services/trpc/context"; -import { trpcAppRouter } from "@/services/trpc/router/app"; +import { createTrpcContext } from "@/services/serverFunctions/context"; +import { trpcAppRouter } from "@/services/serverFunctions/router/app"; import { fetchRequestHandler } from "@trpc/server/adapters/fetch"; const handler = async (request: Request) => { diff --git a/nextjs/src/app/course/[courseName]/context/CalendarItemsContextProvider.tsx b/nextjs/src/app/course/[courseName]/context/CalendarItemsContextProvider.tsx index 014ff7c..42c47e5 100644 --- a/nextjs/src/app/course/[courseName]/context/CalendarItemsContextProvider.tsx +++ b/nextjs/src/app/course/[courseName]/context/CalendarItemsContextProvider.tsx @@ -8,7 +8,7 @@ import { getDateOnlyMarkdownString, } from "@/models/local/timeUtils"; import { useAllCourseDataQuery } from "@/hooks/localCourse/localCourseModuleHooks"; -import { trpc } from "@/services/trpc/utils"; +import { trpc } from "@/services/serverFunctions/trpcClient"; export default function CalendarItemsContextProvider({ children, diff --git a/nextjs/src/app/course/[courseName]/context/drag/useItemDropOnDay.ts b/nextjs/src/app/course/[courseName]/context/drag/useItemDropOnDay.ts index 442259c..b213c10 100644 --- a/nextjs/src/app/course/[courseName]/context/drag/useItemDropOnDay.ts +++ b/nextjs/src/app/course/[courseName]/context/drag/useItemDropOnDay.ts @@ -19,7 +19,7 @@ import { import { Dispatch, SetStateAction, useCallback, DragEvent } from "react"; import { DraggableItem } from "./draggingContext"; import { getNewLockDate } from "./getNewLockDate"; -import { trpc } from "@/services/trpc/utils"; +import { trpc } from "@/services/serverFunctions/trpcClient"; import { useUpdateQuizMutation } from "@/hooks/localCourse/quizHooks"; import { useCourseContext } from "../courseContext"; diff --git a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/LecturePreviewPage.tsx b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/LecturePreviewPage.tsx index f9a2871..dd206e9 100644 --- a/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/LecturePreviewPage.tsx +++ b/nextjs/src/app/course/[courseName]/lecture/[lectureDay]/preview/LecturePreviewPage.tsx @@ -4,7 +4,7 @@ import LecturePreview from "../LecturePreview"; import { getCourseUrl, getLectureUrl } from "@/services/urlUtils"; import { useCourseContext } from "../../../context/courseContext"; import Link from "next/link"; -import { trpc } from "@/services/trpc/utils"; +import { trpc } from "@/services/serverFunctions/trpcClient"; import { useLecturesSuspenseQuery } from "@/hooks/localCourse/lectureHooks"; export default function LecturePreviewPage({ diff --git a/nextjs/src/app/course/[courseName]/modules/ExpandableModule.tsx b/nextjs/src/app/course/[courseName]/modules/ExpandableModule.tsx index 3a08863..92d8e2e 100644 --- a/nextjs/src/app/course/[courseName]/modules/ExpandableModule.tsx +++ b/nextjs/src/app/course/[courseName]/modules/ExpandableModule.tsx @@ -23,7 +23,7 @@ import { Expandable } from "../../../../components/Expandable"; import { useDragStyleContext } from "../context/drag/dragStyleContext"; import { useQuizzesQueries } from "@/hooks/localCourse/quizHooks"; import { useAssignmentNamesQuery } from "@/hooks/localCourse/assignmentHooks"; -import { trpc } from "@/services/trpc/utils"; +import { trpc } from "@/services/serverFunctions/trpcClient"; export default function ExpandableModule({ moduleName, @@ -33,7 +33,7 @@ export default function ExpandableModule({ const { itemDropOnModule } = useDraggingContext(); const { courseName } = useCourseContext(); const [assignmentNames] = useAssignmentNamesQuery(moduleName); - + const [assignments] = trpc.useSuspenseQueries((t) => assignmentNames.map((assignmentName) => t.assignment.getAssignment({ courseName, moduleName, assignmentName }) diff --git a/nextjs/src/app/layout.tsx b/nextjs/src/app/layout.tsx index e6e59cb..36d01d5 100644 --- a/nextjs/src/app/layout.tsx +++ b/nextjs/src/app/layout.tsx @@ -5,11 +5,11 @@ import { Suspense } from "react"; import { dehydrate, HydrationBoundary } from "@tanstack/react-query"; import { MyToaster } from "./MyToaster"; import { createServerSideHelpers } from "@trpc/react-query/server"; -import { trpcAppRouter } from "@/services/trpc/router/app"; -import { createTrpcContext } from "@/services/trpc/context"; +import { trpcAppRouter } from "@/services/serverFunctions/router/app"; +import { createTrpcContext } from "@/services/serverFunctions/context"; import superjson from "superjson"; import { fileStorageService } from "@/services/fileStorage/fileStorageService"; -import { ClientCacheInvalidation } from "./realtime/ClientCacheInvalidation"; +import { ClientCacheInvalidation } from "../components/realtime/ClientCacheInvalidation"; export const dynamic = "force-dynamic"; export const metadata: Metadata = { @@ -32,7 +32,7 @@ export default async function RootLayout({ {children} - + diff --git a/nextjs/src/app/providers.tsx b/nextjs/src/app/providers.tsx index 2ef622e..f51ae02 100644 --- a/nextjs/src/app/providers.tsx +++ b/nextjs/src/app/providers.tsx @@ -1,15 +1,11 @@ "use client"; -import { QueryClientProvider } from "@tanstack/react-query"; +import { QueryClientProvider } from "@tanstack/react-query"; import { ReactNode } from "react"; import { getQueryClient } from "./providersQueryClientUtils"; import { SuspenseAndErrorHandling } from "@/components/SuspenseAndErrorHandling"; -import TrpcProvider from "@/services/trpc/TrpcProvider"; +import TrpcProvider from "@/services/serverFunctions/TrpcProvider"; -export default function Providers({ - children, -}: { - children: ReactNode; -}) { +export default function Providers({ children }: { children: ReactNode }) { // NOTE: Avoid useState when initializing the query client if you don't // have a suspense boundary between this and the code that may // suspend because React will throw away the client on the initial diff --git a/nextjs/src/app/realtime/ClientCacheInvalidation.tsx b/nextjs/src/components/realtime/ClientCacheInvalidation.tsx similarity index 98% rename from nextjs/src/app/realtime/ClientCacheInvalidation.tsx rename to nextjs/src/components/realtime/ClientCacheInvalidation.tsx index 68ffc8b..ced3d7e 100644 --- a/nextjs/src/app/realtime/ClientCacheInvalidation.tsx +++ b/nextjs/src/components/realtime/ClientCacheInvalidation.tsx @@ -1,6 +1,6 @@ "use client"; -import { trpc } from "@/services/trpc/utils"; +import { trpc } from "@/services/serverFunctions/trpcClient"; import React, { useCallback, useEffect, useState } from "react"; import { io, Socket } from "socket.io-client"; diff --git a/nextjs/src/hooks/canvas/canvasCourseHooks.ts b/nextjs/src/hooks/canvas/canvasCourseHooks.ts index 8f7baa9..0dc96ca 100644 --- a/nextjs/src/hooks/canvas/canvasCourseHooks.ts +++ b/nextjs/src/hooks/canvas/canvasCourseHooks.ts @@ -7,7 +7,7 @@ import { } from "@/models/local/localCourseSettings"; import { canvasAssignmentGroupService } from "@/services/canvas/canvasAssignmentGroupService"; import { canvasService } from "@/services/canvas/canvasService"; -import { trpc } from "@/services/trpc/utils"; +import { trpc } from "@/services/serverFunctions/trpcClient"; import { useMutation, useQuery } from "@tanstack/react-query"; import { useUpdateLocalCourseSettingsMutation } from "../localCourse/localCoursesHooks"; import { useCourseContext } from "@/app/course/[courseName]/context/courseContext"; diff --git a/nextjs/src/hooks/localCourse/assignmentHooks.ts b/nextjs/src/hooks/localCourse/assignmentHooks.ts index e7894f8..ff018c1 100644 --- a/nextjs/src/hooks/localCourse/assignmentHooks.ts +++ b/nextjs/src/hooks/localCourse/assignmentHooks.ts @@ -1,5 +1,5 @@ "use client"; -import { trpc } from "@/services/trpc/utils"; +import { trpc } from "@/services/serverFunctions/trpcClient"; import { useCourseContext } from "@/app/course/[courseName]/context/courseContext"; export const useAssignmentQuery = ( diff --git a/nextjs/src/hooks/localCourse/lectureHooks.ts b/nextjs/src/hooks/localCourse/lectureHooks.ts index f2d2cc0..3b8fc74 100644 --- a/nextjs/src/hooks/localCourse/lectureHooks.ts +++ b/nextjs/src/hooks/localCourse/lectureHooks.ts @@ -1,5 +1,5 @@ import { useCourseContext } from "@/app/course/[courseName]/context/courseContext"; -import { trpc } from "@/services/trpc/utils"; +import { trpc } from "@/services/serverFunctions/trpcClient"; export const useLecturesSuspenseQuery = () => { const { courseName } = useCourseContext(); diff --git a/nextjs/src/hooks/localCourse/localCourseModuleHooks.ts b/nextjs/src/hooks/localCourse/localCourseModuleHooks.ts index 615d393..8f2ec49 100644 --- a/nextjs/src/hooks/localCourse/localCourseModuleHooks.ts +++ b/nextjs/src/hooks/localCourse/localCourseModuleHooks.ts @@ -1,5 +1,5 @@ import { useCourseContext } from "@/app/course/[courseName]/context/courseContext"; -import { trpc } from "@/services/trpc/utils"; +import { trpc } from "@/services/serverFunctions/trpcClient"; import { LocalAssignment } from "@/models/local/assignment/localAssignment"; export const useModuleNamesQuery = () => { diff --git a/nextjs/src/hooks/localCourse/localCoursesHooks.ts b/nextjs/src/hooks/localCourse/localCoursesHooks.ts index 9cf2c3d..42b79ce 100644 --- a/nextjs/src/hooks/localCourse/localCoursesHooks.ts +++ b/nextjs/src/hooks/localCourse/localCoursesHooks.ts @@ -1,6 +1,6 @@ "use client"; import { useCourseContext } from "@/app/course/[courseName]/context/courseContext"; -import { trpc } from "@/services/trpc/utils"; +import { trpc } from "@/services/serverFunctions/trpcClient"; export const useLocalCoursesSettingsQuery = () => trpc.settings.allCoursesSettings.useSuspenseQuery(); diff --git a/nextjs/src/hooks/localCourse/pageHooks.ts b/nextjs/src/hooks/localCourse/pageHooks.ts index 1621f11..14ddcce 100644 --- a/nextjs/src/hooks/localCourse/pageHooks.ts +++ b/nextjs/src/hooks/localCourse/pageHooks.ts @@ -1,7 +1,7 @@ "use client"; import { useCourseContext } from "@/app/course/[courseName]/context/courseContext"; -import { trpc } from "@/services/trpc/utils"; +import { trpc } from "@/services/serverFunctions/trpcClient"; export const usePageQuery = (moduleName: string, pageName: string) => { const { courseName } = useCourseContext(); diff --git a/nextjs/src/hooks/localCourse/quizHooks.ts b/nextjs/src/hooks/localCourse/quizHooks.ts index 847fe2a..1ab2d08 100644 --- a/nextjs/src/hooks/localCourse/quizHooks.ts +++ b/nextjs/src/hooks/localCourse/quizHooks.ts @@ -1,7 +1,7 @@ "use client"; import { useCourseContext } from "@/app/course/[courseName]/context/courseContext"; -import { trpc } from "@/services/trpc/utils"; +import { trpc } from "@/services/serverFunctions/trpcClient"; export const useQuizQuery = (moduleName: string, quizName: string) => { const { courseName } = useCourseContext(); diff --git a/nextjs/src/hooks/localCourse/storageDirectoryHooks.ts b/nextjs/src/hooks/localCourse/storageDirectoryHooks.ts index 0ce8b9c..7b89d44 100644 --- a/nextjs/src/hooks/localCourse/storageDirectoryHooks.ts +++ b/nextjs/src/hooks/localCourse/storageDirectoryHooks.ts @@ -1,4 +1,4 @@ -import { trpc } from "@/services/trpc/utils"; +import { trpc } from "@/services/serverFunctions/trpcClient"; export const directoryKeys = { emptyFolders: ["empty folders"] as const, diff --git a/nextjs/src/services/trpc/TrpcProvider.tsx b/nextjs/src/services/serverFunctions/TrpcProvider.tsx similarity index 93% rename from nextjs/src/services/trpc/TrpcProvider.tsx rename to nextjs/src/services/serverFunctions/TrpcProvider.tsx index 0551e2e..315e180 100644 --- a/nextjs/src/services/trpc/TrpcProvider.tsx +++ b/nextjs/src/services/serverFunctions/TrpcProvider.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import superjson from "superjson"; import { httpBatchLink, httpLink } from "@trpc/client"; -import { trpc } from "./utils"; +import { trpc } from "./trpcClient"; import { getQueryClient } from "@/app/providersQueryClientUtils"; import { isServer } from "@tanstack/react-query"; @@ -11,7 +11,7 @@ export default function TrpcProvider({ }: { children: React.ReactNode; }) { - const url = isServer ? "http://localhost:3000/api/trpc/" : "/api/trpc" + const url = isServer ? "http://localhost:3000/api/trpc/" : "/api/trpc"; const [trpcClient] = useState(() => trpc.createClient({ diff --git a/nextjs/src/services/trpc/context.ts b/nextjs/src/services/serverFunctions/context.ts similarity index 100% rename from nextjs/src/services/trpc/context.ts rename to nextjs/src/services/serverFunctions/context.ts diff --git a/nextjs/src/services/serverFunctions/procedures/public.ts b/nextjs/src/services/serverFunctions/procedures/public.ts new file mode 100644 index 0000000..dccb037 --- /dev/null +++ b/nextjs/src/services/serverFunctions/procedures/public.ts @@ -0,0 +1,5 @@ +import { procedure } from "../trpcSetup"; + +const publicProcedure = procedure; + +export default publicProcedure; diff --git a/nextjs/src/services/trpc/router/app.ts b/nextjs/src/services/serverFunctions/router/app.ts similarity index 93% rename from nextjs/src/services/trpc/router/app.ts rename to nextjs/src/services/serverFunctions/router/app.ts index cfe4287..d0dd62a 100644 --- a/nextjs/src/services/trpc/router/app.ts +++ b/nextjs/src/services/serverFunctions/router/app.ts @@ -1,5 +1,5 @@ import { createTrpcContext } from "../context"; -import { createCallerFactory, router } from "../trpc"; +import { createCallerFactory, router } from "../trpcSetup"; import { assignmentRouter } from "./assignmentRouter"; import { directoriesRouter } from "./directoriesRouter"; import { lectureRouter } from "./lectureRouter"; @@ -8,7 +8,6 @@ import { pageRouter } from "./pageRouter"; import { quizRouter } from "./quizRouter"; import { settingsRouter } from "./settingsRouter"; - export const trpcAppRouter = router({ assignment: assignmentRouter, lectures: lectureRouter, diff --git a/nextjs/src/services/trpc/router/assignmentRouter.ts b/nextjs/src/services/serverFunctions/router/assignmentRouter.ts similarity index 98% rename from nextjs/src/services/trpc/router/assignmentRouter.ts rename to nextjs/src/services/serverFunctions/router/assignmentRouter.ts index a9fa2c8..6e58891 100644 --- a/nextjs/src/services/trpc/router/assignmentRouter.ts +++ b/nextjs/src/services/serverFunctions/router/assignmentRouter.ts @@ -1,6 +1,6 @@ import publicProcedure from "../procedures/public"; import { z } from "zod"; -import { router } from "../trpc"; +import { router } from "../trpcSetup"; import { fileStorageService } from "@/services/fileStorage/fileStorageService"; import { zodLocalAssignment } from "@/models/local/assignment/localAssignment"; diff --git a/nextjs/src/services/trpc/router/directoriesRouter.ts b/nextjs/src/services/serverFunctions/router/directoriesRouter.ts similarity index 75% rename from nextjs/src/services/trpc/router/directoriesRouter.ts rename to nextjs/src/services/serverFunctions/router/directoriesRouter.ts index 10f111a..3298364 100644 --- a/nextjs/src/services/trpc/router/directoriesRouter.ts +++ b/nextjs/src/services/serverFunctions/router/directoriesRouter.ts @@ -1,11 +1,11 @@ import publicProcedure from "../procedures/public"; import { z } from "zod"; -import { router } from "../trpc"; +import { router } from "../trpcSetup"; import { fileStorageService } from "@/services/fileStorage/fileStorageService"; import { zodLocalAssignment } from "@/models/local/assignment/localAssignment"; export const directoriesRouter = router({ getEmptyDirectories: publicProcedure.query(async () => { - return await fileStorageService.getEmptyDirectories() - }) -}) \ No newline at end of file + return await fileStorageService.getEmptyDirectories(); + }), +}); diff --git a/nextjs/src/services/trpc/router/lectureRouter.ts b/nextjs/src/services/serverFunctions/router/lectureRouter.ts similarity index 97% rename from nextjs/src/services/trpc/router/lectureRouter.ts rename to nextjs/src/services/serverFunctions/router/lectureRouter.ts index 892581a..a18dfda 100644 --- a/nextjs/src/services/trpc/router/lectureRouter.ts +++ b/nextjs/src/services/serverFunctions/router/lectureRouter.ts @@ -1,6 +1,6 @@ import { z } from "zod"; import publicProcedure from "../procedures/public"; -import { router } from "../trpc"; +import { router } from "../trpcSetup"; import { deleteLecture, getLectures, diff --git a/nextjs/src/services/trpc/router/moduleRouter.ts b/nextjs/src/services/serverFunctions/router/moduleRouter.ts similarity index 94% rename from nextjs/src/services/trpc/router/moduleRouter.ts rename to nextjs/src/services/serverFunctions/router/moduleRouter.ts index 544ef6d..01bcbbe 100644 --- a/nextjs/src/services/trpc/router/moduleRouter.ts +++ b/nextjs/src/services/serverFunctions/router/moduleRouter.ts @@ -1,6 +1,6 @@ import { z } from "zod"; import publicProcedure from "../procedures/public"; -import { router } from "../trpc"; +import { router } from "../trpcSetup"; import { fileStorageService } from "@/services/fileStorage/fileStorageService"; export const moduleRouter = router({ diff --git a/nextjs/src/services/trpc/router/pageRouter.ts b/nextjs/src/services/serverFunctions/router/pageRouter.ts similarity index 98% rename from nextjs/src/services/trpc/router/pageRouter.ts rename to nextjs/src/services/serverFunctions/router/pageRouter.ts index a8fdac3..8d1cded 100644 --- a/nextjs/src/services/trpc/router/pageRouter.ts +++ b/nextjs/src/services/serverFunctions/router/pageRouter.ts @@ -1,6 +1,6 @@ import publicProcedure from "../procedures/public"; import { z } from "zod"; -import { router } from "../trpc"; +import { router } from "../trpcSetup"; import { fileStorageService } from "@/services/fileStorage/fileStorageService"; import { zodLocalCoursePage } from "@/models/local/page/localCoursePage"; diff --git a/nextjs/src/services/trpc/router/quizRouter.ts b/nextjs/src/services/serverFunctions/router/quizRouter.ts similarity index 98% rename from nextjs/src/services/trpc/router/quizRouter.ts rename to nextjs/src/services/serverFunctions/router/quizRouter.ts index 963c9c9..46b801a 100644 --- a/nextjs/src/services/trpc/router/quizRouter.ts +++ b/nextjs/src/services/serverFunctions/router/quizRouter.ts @@ -1,6 +1,6 @@ import publicProcedure from "../procedures/public"; import { z } from "zod"; -import { router } from "../trpc"; +import { router } from "../trpcSetup"; import { fileStorageService } from "@/services/fileStorage/fileStorageService"; import { zodLocalQuiz } from "@/models/local/quiz/localQuiz"; diff --git a/nextjs/src/services/trpc/router/settingsRouter.ts b/nextjs/src/services/serverFunctions/router/settingsRouter.ts similarity index 98% rename from nextjs/src/services/trpc/router/settingsRouter.ts rename to nextjs/src/services/serverFunctions/router/settingsRouter.ts index 0b3de5a..8cf7a7b 100644 --- a/nextjs/src/services/trpc/router/settingsRouter.ts +++ b/nextjs/src/services/serverFunctions/router/settingsRouter.ts @@ -1,9 +1,9 @@ import publicProcedure from "../procedures/public"; import { z } from "zod"; -import { router } from "../trpc"; +import { router } from "../trpcSetup"; import { fileStorageService } from "@/services/fileStorage/fileStorageService"; import { zodLocalCourseSettings } from "@/models/local/localCourseSettings"; -import { trpc } from "../utils"; +import { trpc } from "../trpcClient"; import { getLectures, updateLecture, diff --git a/nextjs/src/services/trpc/utils.ts b/nextjs/src/services/serverFunctions/trpcClient.ts similarity index 57% rename from nextjs/src/services/trpc/utils.ts rename to nextjs/src/services/serverFunctions/trpcClient.ts index 590adc1..90cb11d 100644 --- a/nextjs/src/services/trpc/utils.ts +++ b/nextjs/src/services/serverFunctions/trpcClient.ts @@ -1,4 +1,4 @@ -import { createTRPCReact, httpBatchLink } from "@trpc/react-query"; +import { createTRPCReact } from "@trpc/react-query"; import { AppRouter } from "./router/app"; export const trpc = createTRPCReact(); diff --git a/nextjs/src/services/trpc/trpc.ts b/nextjs/src/services/serverFunctions/trpcSetup.ts similarity index 100% rename from nextjs/src/services/trpc/trpc.ts rename to nextjs/src/services/serverFunctions/trpcSetup.ts diff --git a/nextjs/src/services/trpc/procedures/public.ts b/nextjs/src/services/trpc/procedures/public.ts deleted file mode 100644 index c7acb35..0000000 --- a/nextjs/src/services/trpc/procedures/public.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { procedure } from "../trpc"; - -const publicProcedure = procedure; - -export default publicProcedure; \ No newline at end of file