mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 08:06:56 +00:00
사소한 리팩토링 3
This commit is contained in:
@@ -1,11 +0,0 @@
|
|||||||
export const callGetApi = async (input: RequestInfo, fetchInternal = fetch) => {
|
|
||||||
return await fetchInternal(input);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const callPostApi = async <T>(input: RequestInfo, payload?: T, fetchInternal = fetch) => {
|
|
||||||
return await fetchInternal(input, {
|
|
||||||
method: "POST",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: payload ? JSON.stringify(payload) : undefined,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -27,7 +27,6 @@ export const requestCategoryCreation = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const requestFileRemovalFromCategory = async (fileId: number, categoryId: number) => {
|
export const requestFileRemovalFromCategory = async (fileId: number, categoryId: number) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await trpc().category.removeFile.mutate({ id: categoryId, file: fileId });
|
await trpc().category.removeFile.mutate({ id: categoryId, file: fileId });
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { callGetApi } from "$lib/hooks";
|
|
||||||
import { getAllFileInfos } from "$lib/indexedDB/filesystem";
|
import { getAllFileInfos } from "$lib/indexedDB/filesystem";
|
||||||
import { decryptData } from "$lib/modules/crypto";
|
import { decryptData } from "$lib/modules/crypto";
|
||||||
import {
|
import {
|
||||||
@@ -58,7 +57,7 @@ export const requestFileThumbnailDownload = async (fileId: number, dataKey?: Cry
|
|||||||
}
|
}
|
||||||
const { contentIv: thumbnailEncryptedIv } = thumbnailInfo;
|
const { contentIv: thumbnailEncryptedIv } = thumbnailInfo;
|
||||||
|
|
||||||
const res = await callGetApi(`/api/file/${fileId}/thumbnail/download`);
|
const res = await fetch(`/api/file/${fileId}/thumbnail/download`);
|
||||||
if (!res.ok) return null;
|
if (!res.ok) return null;
|
||||||
|
|
||||||
const thumbnailEncrypted = await res.arrayBuffer();
|
const thumbnailEncrypted = await res.arrayBuffer();
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
export * from "./callApi";
|
|
||||||
export * from "./gotoStateful";
|
export * from "./gotoStateful";
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { error } from "@sveltejs/kit";
|
import { error } from "@sveltejs/kit";
|
||||||
import { keyExportState } from "$lib/hooks/gotoStateful";
|
import { keyExportState } from "$lib/utils/gotoStateful";
|
||||||
import type { PageLoad } from "./$types";
|
import type { PageLoad } from "./$types";
|
||||||
|
|
||||||
export const load: PageLoad = async () => {
|
export const load: PageLoad = async () => {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
import { BottomDiv, Button, FullscreenDiv, TextButton } from "$lib/components/atoms";
|
import { BottomDiv, Button, FullscreenDiv, TextButton } from "$lib/components/atoms";
|
||||||
import { TitledDiv } from "$lib/components/molecules";
|
import { TitledDiv } from "$lib/components/molecules";
|
||||||
import { ForceLoginModal } from "$lib/components/organisms";
|
import { ForceLoginModal } from "$lib/components/organisms";
|
||||||
import { gotoStateful } from "$lib/hooks";
|
|
||||||
import { storeClientKeys } from "$lib/modules/key";
|
import { storeClientKeys } from "$lib/modules/key";
|
||||||
import { clientKeyStore } from "$lib/stores";
|
import { clientKeyStore } from "$lib/stores";
|
||||||
|
import { gotoStateful } from "$lib/utils";
|
||||||
import Order from "./Order.svelte";
|
import Order from "./Order.svelte";
|
||||||
import {
|
import {
|
||||||
generateClientKeys,
|
generateClientKeys,
|
||||||
|
|||||||
@@ -3,11 +3,10 @@ import { initTRPC, TRPCError } from "@trpc/server";
|
|||||||
import superjson from "superjson";
|
import superjson from "superjson";
|
||||||
import { authorizeMiddleware, authorizeClientMiddleware } from "./middlewares/authorize";
|
import { authorizeMiddleware, authorizeClientMiddleware } from "./middlewares/authorize";
|
||||||
|
|
||||||
|
export const createContext = (event: RequestEvent) => event;
|
||||||
export type Context = Awaited<ReturnType<typeof createContext>>;
|
export type Context = Awaited<ReturnType<typeof createContext>>;
|
||||||
|
|
||||||
export const createContext = (event: RequestEvent) => event;
|
|
||||||
export const t = initTRPC.context<Context>().create({ transformer: superjson });
|
export const t = initTRPC.context<Context>().create({ transformer: superjson });
|
||||||
|
|
||||||
export const router = t.router;
|
export const router = t.router;
|
||||||
export const publicProcedure = t.procedure;
|
export const publicProcedure = t.procedure;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user