리다이렉트 경로 처리, 파일 정보 변환, 상태 표시 UI 등 중복된 코드를 통합하고 모듈 간 순환 의존성 및 계층 위반 해소

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
staticandClaude Opus 5.5 committed 2026-10-12 08:51:07 +09:00
1 parent 9119c21881
commit 5b8621e524
96 files changed
+452 -548

No files matched your search

+2 -1
View File
@@ -3,6 +3,7 @@ import { observable } from "@trpc/server/observable";
import superjson from "superjson";
import { goto } from "$app/navigation";
import { navigating } from "$app/state";
import { withRedirectPath } from "#lib/shared/redirect.ts";
import type { AppRouter } from "./router.server.ts";
// Procedures that report invalid credentials as UNAUTHORIZED, not an expired session
@@ -21,7 +22,7 @@ const sessionExpiryLink: TRPCLink<AppRouter> = () => {
!CREDENTIAL_PROCEDURES.has(op.path) &&
url.pathname !== "/auth/login"
) {
void goto(`/auth/login?redirect=${encodeURIComponent(url.pathname + url.search)}`);
void goto(withRedirectPath("/auth/login", url.pathname + url.search));
}
observer.error(err);
},
+5 -3
View File
@@ -1,6 +1,8 @@
import type { Category } from "#lib/server/db/repositories/category.ts";
import type { Directory } from "#lib/server/db/repositories/directory.ts";
import type { File } from "#lib/server/db/repositories/file.ts";
import type { CategoryRepo, DirectoryRepo, FileRepo } from "#lib/server/db/index.ts";
type Category = CategoryRepo.Category;
type Directory = DirectoryRepo.Directory;
type File = FileRepo.File;
// Shapes of filesystem entries exposed by the API
+3 -9
View File
@@ -30,15 +30,9 @@ export const publicProcedure = t.procedure.use(async ({ next }) => {
return result;
});
const authedProcedure = publicProcedure.use(async ({ ctx, next }) => {
if (!ctx.locals.session) {
throw new TRPCError({ code: "UNAUTHORIZED" });
}
return next();
});
// `authorize` also rejects unauthenticated requests
const sessionProcedure = (requiredPermission: "any" | "notClient") =>
authedProcedure.use(async ({ ctx, next }) => {
publicProcedure.use(async ({ ctx, next }) => {
const session: Session = await authorize(ctx.locals, requiredPermission);
return next({ ctx: { session } });
});
@@ -46,7 +40,7 @@ const sessionProcedure = (requiredPermission: "any" | "notClient") =>
const clientSessionProcedure = (
requiredPermission: "anyClient" | "pendingClient" | "activeClient",
) =>
authedProcedure.use(async ({ ctx, next }) => {
publicProcedure.use(async ({ ctx, next }) => {
const session: ClientSession = await authorize(ctx.locals, requiredPermission);
return next({ ctx: { session } });
});
+1 -1
View File
@@ -2,7 +2,7 @@ import { z } from "zod";
export const IdSchema = z.int().positive();
export const DirectoryIdSchema = z.union([z.literal("root"), IdSchema]);
export const CategoryIdSchema = z.union([z.literal("root"), IdSchema]);
export const CategoryIdSchema = DirectoryIdSchema;
export const Base64Schema = z.base64().nonempty();
export const EncryptedNameSchema = {