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