doing more trpc, still working on preloading

This commit is contained in:
2024-11-08 16:28:14 -07:00
parent 026ca3846f
commit c47d7405c2
28 changed files with 175 additions and 230 deletions

View File

@@ -9,7 +9,10 @@ import {
parseLecture,
} from "./utils/lectureUtils";
import { Lecture } from "@/models/local/lecture";
import { getDayOfWeek, LocalCourseSettings } from "@/models/local/localCourse";
import {
getDayOfWeek,
LocalCourseSettings,
} from "@/models/local/localCourseSettings";
import { getWeekNumber } from "@/app/course/[courseName]/calendar/calendarMonthUtils";
import { getDateFromStringOrThrow } from "@/models/local/timeUtils";

View File

@@ -1,7 +1,7 @@
import {
LocalCourseSettings,
localCourseYamlUtils,
} from "@/models/local/localCourse";
} from "@/models/local/localCourseSettings";
import { promises as fs } from "fs";
import path from "path";
import {

View File

@@ -1,6 +1,9 @@
import { describe, it, expect, beforeEach } from "vitest";
import { promises as fs } from "fs";
import { DayOfWeek, LocalCourseSettings } from "@/models/local/localCourse";
import {
DayOfWeek,
LocalCourseSettings,
} from "@/models/local/localCourseSettings";
import { fileStorageService } from "../fileStorage/fileStorageService";
describe("FileStorageTests", () => {

View File

@@ -2,6 +2,7 @@ import publicProcedure from "../procedures/public";
import { z } from "zod";
import { router } from "../trpc";
import { fileStorageService } from "@/services/fileStorage/fileStorageService";
import { zodLocalCourseSettings } from "@/models/local/localCourseSettings";
export const settingsRouter = router({
allCoursesSettings: publicProcedure.query(async () => {
@@ -23,4 +24,29 @@ export const settingsRouter = router({
}
return s;
}),
createCourse: publicProcedure
.input(
z.object({
settings: zodLocalCourseSettings,
})
)
.mutation(async ({ input: { settings } }) => {
await fileStorageService.settings.updateCourseSettings(
settings.name,
settings
);
}),
updateSettings: publicProcedure
.input(
z.object({
settings: zodLocalCourseSettings,
})
)
.mutation(async ({ input: { settings } }) => {
await fileStorageService.settings.updateCourseSettings(
settings.name,
settings
);
}),
});

View File

@@ -1,50 +1,4 @@
import { createTRPCReact, httpBatchLink } from "@trpc/react-query";
import { createTRPCNext } from "@trpc/next";
import { ssrPrepass } from '@trpc/next/ssrPrepass';
import { AppRouter } from "./router/app";
import superjson from "superjson";
export const trpc = createTRPCReact<AppRouter>();
// export const trpc = createTRPCNext<AppRouter>({
// ssr: true,
// ssrPrepass,
// transformer: superjson,
// config(opts) {
// const { ctx } = opts;
// if (typeof window !== "undefined") {
// // during client requests
// return {
// links: [
// httpBatchLink({
// url: "/api/trpc",
// transformer: superjson,
// }),
// ],
// };
// }
// return {
// links: [
// httpBatchLink({
// transformer: superjson,
// // The server needs to know your app's full url
// url: `http://localhost:3000/api/trpc`,
// /**
// * Set custom request headers on every request from tRPC
// * @see https://trpc.io/docs/v10/header
// */
// headers() {
// if (!ctx?.req?.headers) {
// return {};
// }
// // To use SSR properly, you need to forward client headers to the server
// // This is so you can pass through things like cookies when we're server-side rendering
// return {
// cookie: ctx.req.headers.cookie,
// };
// },
// }),
// ],
// };
// },
// });
// export const trpcClient = trpc.createClient({ links: [] }); //server only?