mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-11-04 00:00:28 +09:00
사소한 리팩토링
This commit is contained in:
1 parent
d986493431
commit
48bf9c1165
62 files changed
+31
-39
No files matched your search
+1
-1
@@ -32,4 +32,4 @@ vite.config.js.timestamp-*
|
||||
vite.config.ts.timestamp-*
|
||||
|
||||
# E2E tests
|
||||
/tests/e2e/results
|
||||
/test/e2e/results
|
||||
+1
-1
@@ -30,4 +30,4 @@ vite.config.js.timestamp-*
|
||||
vite.config.ts.timestamp-*
|
||||
|
||||
# E2E tests
|
||||
/tests/e2e/results
|
||||
/test/e2e/results
|
||||
+2
-2
@@ -8,13 +8,13 @@
|
||||
"dev:remote": "__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=.ts.net vite dev --host 0.0.0.0",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json && tsc --noEmit -p ./src/service-worker",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json && tsc --noEmit --project ./src/service-worker",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"format": "prettier --write .",
|
||||
"lint": "prettier --check . && eslint .",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"test:e2e": "bash tests/e2e/run.sh",
|
||||
"test:e2e": "bash test/e2e/run.sh",
|
||||
"db:up": "docker compose -f docker-compose.dev.yaml -p arkvault-dev up -d",
|
||||
"db:down": "docker compose -f docker-compose.dev.yaml -p arkvault-dev down",
|
||||
"db:migrate": "kysely migrate"
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
allowBuilds:
|
||||
argon2: true
|
||||
cpu-features: false
|
||||
esbuild: true
|
||||
exifreader: true
|
||||
exifreader: false
|
||||
protobufjs: false
|
||||
ssh2: false
|
||||
@@ -15,14 +15,15 @@ const cacheIndex = new Dexie("cacheIndex") as Dexie & {
|
||||
fileCache: EntityTable<FileCacheIndex, "fileId">;
|
||||
};
|
||||
|
||||
cacheIndex.version(1).stores({
|
||||
fileCache: "fileId",
|
||||
});
|
||||
|
||||
// Files were cached as single files before version 2
|
||||
cacheIndex.version(2).upgrade(async (trx) => {
|
||||
await trx.table("fileCache").clear();
|
||||
});
|
||||
cacheIndex
|
||||
.version(2)
|
||||
.stores({
|
||||
fileCache: "fileId",
|
||||
})
|
||||
.upgrade(async (trx) => {
|
||||
await trx.table("fileCache").clear();
|
||||
});
|
||||
|
||||
export const getFileCacheIndex = async () => {
|
||||
return await cacheIndex.fileCache.toArray();
|
||||
|
||||
+9
-6
@@ -1,10 +1,13 @@
|
||||
import { defineParams } from "@sveltejs/kit/params";
|
||||
import { z } from "zod";
|
||||
|
||||
export const params = defineParams({
|
||||
// Positive integers such as the ids of files, directories, and categories
|
||||
int: (param) => {
|
||||
const value = Number(param);
|
||||
return /^[1-9]\d*$/.test(param) && Number.isSafeInteger(value) ? value : undefined;
|
||||
},
|
||||
thumbnail: (param) => (param === "thumbnail" ? param : undefined),
|
||||
// Natural numbers starting from 1, such as the ids of files, directories, and categories
|
||||
natural: z
|
||||
.string()
|
||||
.regex(/^[1-9]\d*$/)
|
||||
.transform(Number)
|
||||
.pipe(z.int()),
|
||||
uuid: z.uuidv4(),
|
||||
thumbnail: z.literal("thumbnail"),
|
||||
});
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-9
@@ -1,7 +1,6 @@
|
||||
import { error } from "@sveltejs/kit";
|
||||
import { Readable } from "stream";
|
||||
import type { ReadableStream } from "stream/web";
|
||||
import { z } from "zod";
|
||||
import { authorize } from "#lib/server/auth.ts";
|
||||
import { handleAppErrors } from "#lib/server/http.ts";
|
||||
import { UploadService } from "#lib/server/services/index.ts";
|
||||
@@ -10,14 +9,7 @@ import type { RequestHandler } from "./$types";
|
||||
export const POST: RequestHandler = handleAppErrors(async ({ locals, params, request }) => {
|
||||
const { userId } = await authorize(locals, "activeClient");
|
||||
|
||||
const zodRes = z
|
||||
.object({
|
||||
id: z.uuidv4(),
|
||||
index: z.coerce.number().int().positive(),
|
||||
})
|
||||
.safeParse(params);
|
||||
if (!zodRes.success) error(400, "Invalid path parameters");
|
||||
const { id: sessionId, index: chunkIndex } = zodRes.data;
|
||||
const { id: sessionId, index: chunkIndex } = params;
|
||||
|
||||
if (!request.body) {
|
||||
error(400, "Invalid request body");
|
||||
@@ -1,8 +1,6 @@
|
||||
{
|
||||
"extends": "$app/tsconfig/service-worker",
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"noUncheckedIndexedAccess": true
|
||||
},
|
||||
"include": ["."]
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -49,6 +49,6 @@ services:
|
||||
- ../..:/work
|
||||
# Accessed by the tests to manipulate the stored files
|
||||
- ${E2E_DATA_DIR:?}:/data
|
||||
command: npx playwright test -c tests/e2e/playwright.config.ts ${E2E_ARGS:-}
|
||||
command: npx playwright test -c test/e2e/playwright.config.ts ${E2E_ARGS:-}
|
||||
depends_on:
|
||||
- app
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-2
@@ -2,9 +2,8 @@
|
||||
"extends": "$app/tsconfig",
|
||||
"compilerOptions": {
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"noUncheckedIndexedAccess": true
|
||||
},
|
||||
"include": ["src", "vite.config.ts", "tests"],
|
||||
"include": ["src", "test", "*.ts"],
|
||||
"exclude": ["src/service-worker"]
|
||||
}
|
||||
+5
-5
@@ -10,17 +10,17 @@ export default defineConfig({
|
||||
extends: true,
|
||||
test: {
|
||||
name: "unit",
|
||||
include: ["tests/unit/**/*.test.ts"],
|
||||
setupFiles: ["tests/setup/polyfills.ts"],
|
||||
include: ["test/unit/**/*.test.ts"],
|
||||
setupFiles: ["test/setup/polyfills.ts"],
|
||||
},
|
||||
},
|
||||
{
|
||||
extends: true,
|
||||
test: {
|
||||
name: "server",
|
||||
include: ["tests/server/**/*.test.ts"],
|
||||
globalSetup: ["tests/setup/database.ts"],
|
||||
setupFiles: ["tests/setup/server.ts"],
|
||||
include: ["test/server/**/*.test.ts"],
|
||||
globalSetup: ["test/setup/database.ts"],
|
||||
setupFiles: ["test/setup/server.ts"],
|
||||
// Test files share a single database
|
||||
fileParallelism: false,
|
||||
hookTimeout: 60_000,
|
||||
|
||||
Reference in new issue
Block a user