mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 06:58:46 +00:00
오타 수정
This commit is contained in:
@@ -2,11 +2,11 @@ import { and, eq, isNull } from "drizzle-orm";
|
||||
import db from "./drizzle";
|
||||
import { directory, file, mek } from "./schema";
|
||||
|
||||
type DirectroyId = "root" | number;
|
||||
type DirectoryId = "root" | number;
|
||||
|
||||
export interface NewDirectroyParams {
|
||||
export interface NewDirectoryParams {
|
||||
userId: number;
|
||||
parentId: DirectroyId;
|
||||
parentId: DirectoryId;
|
||||
mekVersion: number;
|
||||
encDek: string;
|
||||
encName: string;
|
||||
@@ -15,7 +15,7 @@ export interface NewDirectroyParams {
|
||||
|
||||
export interface NewFileParams {
|
||||
path: string;
|
||||
parentId: DirectroyId;
|
||||
parentId: DirectoryId;
|
||||
userId: number;
|
||||
mekVersion: number;
|
||||
encDek: string;
|
||||
@@ -24,7 +24,7 @@ export interface NewFileParams {
|
||||
encNameIv: string;
|
||||
}
|
||||
|
||||
export const registerNewDirectory = async (params: NewDirectroyParams) => {
|
||||
export const registerNewDirectory = async (params: NewDirectoryParams) => {
|
||||
return await db.transaction(async (tx) => {
|
||||
const meks = await tx
|
||||
.select()
|
||||
@@ -47,7 +47,7 @@ export const registerNewDirectory = async (params: NewDirectroyParams) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getAllDirectoriesByParent = async (userId: number, directoryId: DirectroyId) => {
|
||||
export const getAllDirectoriesByParent = async (userId: number, directoryId: DirectoryId) => {
|
||||
return await db
|
||||
.select()
|
||||
.from(directory)
|
||||
@@ -135,7 +135,7 @@ export const registerNewFile = async (params: NewFileParams) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getAllFilesByParent = async (userId: number, parentId: DirectroyId) => {
|
||||
export const getAllFilesByParent = async (userId: number, parentId: DirectoryId) => {
|
||||
return await db
|
||||
.select()
|
||||
.from(file)
|
||||
|
||||
@@ -6,7 +6,7 @@ export const directoryRenameRequest = z.object({
|
||||
});
|
||||
export type DirectoryRenameRequest = z.infer<typeof directoryRenameRequest>;
|
||||
|
||||
export const directroyInfoResponse = z.object({
|
||||
export const directoryInfoResponse = z.object({
|
||||
metadata: z
|
||||
.object({
|
||||
createdAt: z.date(),
|
||||
@@ -19,7 +19,7 @@ export const directroyInfoResponse = z.object({
|
||||
subDirectories: z.number().int().positive().array(),
|
||||
files: z.number().int().positive().array(),
|
||||
});
|
||||
export type DirectroyInfoResponse = z.infer<typeof directroyInfoResponse>;
|
||||
export type DirectoryInfoResponse = z.infer<typeof directoryInfoResponse>;
|
||||
|
||||
export const directoryCreateRequest = z.object({
|
||||
parentId: z.union([z.enum(["root"]), z.number().int().positive()]),
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
setDirectoryEncName,
|
||||
unregisterDirectory,
|
||||
getAllFilesByParent,
|
||||
type NewDirectroyParams,
|
||||
type NewDirectoryParams,
|
||||
} from "$lib/server/db/file";
|
||||
import { getActiveMekVersion } from "$lib/server/db/mek";
|
||||
|
||||
@@ -35,14 +35,14 @@ export const renameDirectory = async (
|
||||
await setDirectoryEncName(userId, directoryId, newEncName, newEncNameIv);
|
||||
};
|
||||
|
||||
export const getDirectroyInformation = async (userId: number, directroyId: "root" | number) => {
|
||||
const directory = directroyId !== "root" ? await getDirectory(userId, directroyId) : undefined;
|
||||
export const getDirectoryInformation = async (userId: number, directoryId: "root" | number) => {
|
||||
const directory = directoryId !== "root" ? await getDirectory(userId, directoryId) : undefined;
|
||||
if (directory === null) {
|
||||
error(404, "Invalid directory id");
|
||||
}
|
||||
|
||||
const directories = await getAllDirectoriesByParent(userId, directroyId);
|
||||
const files = await getAllFilesByParent(userId, directroyId);
|
||||
const directories = await getAllDirectoriesByParent(userId, directoryId);
|
||||
const files = await getAllFilesByParent(userId, directoryId);
|
||||
|
||||
return {
|
||||
metadata: directory && {
|
||||
@@ -56,7 +56,7 @@ export const getDirectroyInformation = async (userId: number, directroyId: "root
|
||||
};
|
||||
};
|
||||
|
||||
export const createDirectory = async (params: NewDirectroyParams) => {
|
||||
export const createDirectory = async (params: NewDirectoryParams) => {
|
||||
const activeMekVersion = await getActiveMekVersion(params.userId);
|
||||
if (activeMekVersion === null) {
|
||||
error(500, "Invalid MEK version");
|
||||
|
||||
Reference in New Issue
Block a user