From fa1322f305a3f488689dee29b70afae2d67cab0b Mon Sep 17 00:00:00 2001 From: alikia2x Date: Wed, 5 Nov 2025 19:22:54 +0800 Subject: [PATCH] update: dependencies --- bun.lock | 14 +-- package.json | 3 +- packages/core/drizzle/index.ts | 2 +- packages/core/drizzle/main/schema.ts | 2 + packages/core/package.json | 1 - packages/elysia/lib/auth.ts | 1 + packages/elysia/package.json | 1 + packages/elysia/routes/song/info.ts | 181 +++++++++++++-------------- packages/elysia/routes/user/login.ts | 24 ++++ packages/elysia/src/index.ts | 6 +- packages/solid/package.json | 1 - packages/tracker/package.json | 1 - 12 files changed, 126 insertions(+), 111 deletions(-) create mode 100644 packages/elysia/lib/auth.ts create mode 100644 packages/elysia/routes/user/login.ts diff --git a/bun.lock b/bun.lock index bddb281..3666004 100644 --- a/bun.lock +++ b/bun.lock @@ -6,6 +6,7 @@ "dependencies": { "arg": "^5.0.2", "dotenv": "^17.2.3", + "drizzle-orm": "^0.44.7", "postgres": "^3.4.7", }, "devDependencies": { @@ -49,7 +50,6 @@ "@koshnic/ratelimit": "^1.0.3", "@types/luxon": "^3.7.1", "chalk": "^5.4.1", - "drizzle-orm": "^0.44.4", "ioredis": "^5.6.1", "logform": "^2.7.0", "luxon": "^3.7.2", @@ -87,6 +87,7 @@ "@elysiajs/cors": "^1.4.0", "@elysiajs/openapi": "^1.4.0", "@elysiajs/server-timing": "^1.4.0", + "@rabbit-company/argon2id": "^2.1.0", "chalk": "^5.6.2", "elysia": "^1.4.0", "zod": "^4.1.11", @@ -168,7 +169,6 @@ "animejs": "^4.1.2", "axios": "^1.11.0", "dotenv": "^16.6.1", - "drizzle-orm": "^0.44.4", "luxon": "^3.7.1", "minimatch": "^10.0.3", "postgres": "^3.4.7", @@ -1266,7 +1266,7 @@ "bullmq": ["bullmq@5.58.7", "", { "dependencies": { "cron-parser": "^4.9.0", "ioredis": "^5.4.1", "msgpackr": "^1.11.2", "node-abort-controller": "^3.1.1", "semver": "^7.5.4", "tslib": "^2.0.0", "uuid": "^11.1.0" } }, "sha512-rqsKV/ip76wU90q7Cxpr1vS/6PYIVbhuzqr3wgILgjS6XbsnJtWyYrK23jqWHs9+m6/NXM4+62hyf8CSBpufAw=="], - "bun-types": ["bun-types@1.2.23", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-R9f0hKAZXgFU3mlrA0YpE/fiDvwV0FT9rORApt2aQVWSuJDzZOyB5QLc0N/4HF57CS8IXJ6+L5E4W1bW6NS2Aw=="], + "bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="], "bytes": ["bytes@3.1.2", "", {}, "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg=="], @@ -1496,7 +1496,7 @@ "drizzle-kit": ["drizzle-kit@0.31.4", "", { "dependencies": { "@drizzle-team/brocli": "^0.10.2", "@esbuild-kit/esm-loader": "^2.5.5", "esbuild": "^0.25.4", "esbuild-register": "^3.5.0" }, "bin": { "drizzle-kit": "bin.cjs" } }, "sha512-tCPWVZWZqWVx2XUsVpJRnH9Mx0ClVOf5YUHerZ5so1OKSlqww4zy1R5ksEdGRcO3tM3zj0PYN6V48TbQCL1RfA=="], - "drizzle-orm": ["drizzle-orm@0.44.5", "", { "peerDependencies": { "@aws-sdk/client-rds-data": ">=3", "@cloudflare/workers-types": ">=4", "@electric-sql/pglite": ">=0.2.0", "@libsql/client": ">=0.10.0", "@libsql/client-wasm": ">=0.10.0", "@neondatabase/serverless": ">=0.10.0", "@op-engineering/op-sqlite": ">=2", "@opentelemetry/api": "^1.4.1", "@planetscale/database": ">=1.13", "@prisma/client": "*", "@tidbcloud/serverless": "*", "@types/better-sqlite3": "*", "@types/pg": "*", "@types/sql.js": "*", "@upstash/redis": ">=1.34.7", "@vercel/postgres": ">=0.8.0", "@xata.io/client": "*", "better-sqlite3": ">=7", "bun-types": "*", "expo-sqlite": ">=14.0.0", "gel": ">=2", "knex": "*", "kysely": "*", "mysql2": ">=2", "pg": ">=8", "postgres": ">=3", "sql.js": ">=1", "sqlite3": ">=5" }, "optionalPeers": ["@aws-sdk/client-rds-data", "@cloudflare/workers-types", "@electric-sql/pglite", "@libsql/client", "@libsql/client-wasm", "@neondatabase/serverless", "@op-engineering/op-sqlite", "@opentelemetry/api", "@planetscale/database", "@prisma/client", "@tidbcloud/serverless", "@types/better-sqlite3", "@types/pg", "@types/sql.js", "@upstash/redis", "@vercel/postgres", "@xata.io/client", "better-sqlite3", "bun-types", "expo-sqlite", "gel", "knex", "kysely", "mysql2", "pg", "postgres", "sql.js", "sqlite3"] }, "sha512-jBe37K7d8ZSKptdKfakQFdeljtu3P2Cbo7tJoJSVZADzIKOBo9IAJPOmMsH2bZl90bZgh8FQlD8BjxXA/zuBkQ=="], + "drizzle-orm": ["drizzle-orm@0.44.7", "", { "peerDependencies": { "@aws-sdk/client-rds-data": ">=3", "@cloudflare/workers-types": ">=4", "@electric-sql/pglite": ">=0.2.0", "@libsql/client": ">=0.10.0", "@libsql/client-wasm": ">=0.10.0", "@neondatabase/serverless": ">=0.10.0", "@op-engineering/op-sqlite": ">=2", "@opentelemetry/api": "^1.4.1", "@planetscale/database": ">=1.13", "@prisma/client": "*", "@tidbcloud/serverless": "*", "@types/better-sqlite3": "*", "@types/pg": "*", "@types/sql.js": "*", "@upstash/redis": ">=1.34.7", "@vercel/postgres": ">=0.8.0", "@xata.io/client": "*", "better-sqlite3": ">=7", "bun-types": "*", "expo-sqlite": ">=14.0.0", "gel": ">=2", "knex": "*", "kysely": "*", "mysql2": ">=2", "pg": ">=8", "postgres": ">=3", "sql.js": ">=1", "sqlite3": ">=5" }, "optionalPeers": ["@aws-sdk/client-rds-data", "@cloudflare/workers-types", "@electric-sql/pglite", "@libsql/client", "@libsql/client-wasm", "@neondatabase/serverless", "@op-engineering/op-sqlite", "@opentelemetry/api", "@planetscale/database", "@prisma/client", "@tidbcloud/serverless", "@types/better-sqlite3", "@types/pg", "@types/sql.js", "@upstash/redis", "@vercel/postgres", "@xata.io/client", "better-sqlite3", "bun-types", "expo-sqlite", "gel", "knex", "kysely", "mysql2", "pg", "postgres", "sql.js", "sqlite3"] }, "sha512-quIpnYznjU9lHshEOAYLoZ9s3jweleHlZIAWR/jX9gAWNg/JhQ1wj0KGRf7/Zm+obRrYd9GjPVJg790QY9N5AQ=="], "dset": ["dset@3.1.4", "", {}, "sha512-2QF/g9/zTaPDc3BjNcVTGoBbXBgYfMTTceLaYcFJ/W9kggFUkhxD/hMEeuLKbugyef9SqAx8cpgwlIP/jinUTA=="], @@ -3006,8 +3006,6 @@ "@tanstack/server-functions-plugin/@babel/code-frame": ["@babel/code-frame@7.26.2", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.25.9", "js-tokens": "^4.0.0", "picocolors": "^1.0.0" } }, "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ=="], - "@types/bun/bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="], - "@types/d3-scale/@types/d3-time": ["@types/d3-time@3.0.4", "", {}, "sha512-yuzZug1nkAAaBlBBikKZTgzCeA+k1uy4ZFwWANOfKw5z5LRhV0gNA7gNkKm7HoK+HRN0wX3EkxGk0fpbWhmB7g=="], "@types/xml2js/@types/node": ["@types/node@24.6.2", "", { "dependencies": { "undici-types": "~7.13.0" } }, "sha512-d2L25Y4j+W3ZlNAeMKcy7yDsK425ibcAOO2t7aPTz6gNMH0z2GThtwENCDc0d/Pw9wgyRqE5Px1wkV7naz8ang=="], @@ -3356,8 +3354,6 @@ "@tanstack/server-functions-plugin/@babel/code-frame/js-tokens": ["js-tokens@4.0.0", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="], - "@types/bun/bun-types/@types/node": ["@types/node@24.6.2", "", { "dependencies": { "undici-types": "~7.13.0" } }, "sha512-d2L25Y4j+W3ZlNAeMKcy7yDsK425ibcAOO2t7aPTz6gNMH0z2GThtwENCDc0d/Pw9wgyRqE5Px1wkV7naz8ang=="], - "@types/xml2js/@types/node/undici-types": ["undici-types@7.13.0", "", {}, "sha512-Ov2Rr9Sx+fRgagJ5AX0qvItZG/JKKoBRAVITs1zk7IqZGTJUwgUr7qoYBpWwakpWilTZFM98rG/AFRocu10iIQ=="], "@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.2", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ=="], @@ -3472,8 +3468,6 @@ "@solidjs/start/shiki/@shikijs/engine-javascript/oniguruma-to-es": ["oniguruma-to-es@2.3.0", "", { "dependencies": { "emoji-regex-xs": "^1.0.0", "regex": "^5.1.1", "regex-recursion": "^5.1.1" } }, "sha512-bwALDxriqfKGfUufKGGepCzu9x7nJQuoRoAFp4AnwehhC2crqrDIAP/uN2qdlsAvSMpeRC3+Yzhqc7hLmle5+g=="], - "@types/bun/bun-types/@types/node/undici-types": ["undici-types@7.13.0", "", {}, "sha512-Ov2Rr9Sx+fRgagJ5AX0qvItZG/JKKoBRAVITs1zk7IqZGTJUwgUr7qoYBpWwakpWilTZFM98rG/AFRocu10iIQ=="], - "@unocss/cli/chokidar/readdirp/picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="], "@unocss/vite/chokidar/readdirp/picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="], diff --git a/package.json b/package.json index 426bf9f..f5b6da0 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "dependencies": { "arg": "^5.0.2", "dotenv": "^17.2.3", - "postgres": "^3.4.7" + "postgres": "^3.4.7", + "drizzle-orm": "^0.44.7" }, "devDependencies": { "@types/bun": "^1.3.1", diff --git a/packages/core/drizzle/index.ts b/packages/core/drizzle/index.ts index 73dd076..d5370c4 100644 --- a/packages/core/drizzle/index.ts +++ b/packages/core/drizzle/index.ts @@ -1,7 +1,7 @@ "use server"; import { drizzle } from "drizzle-orm/postgres-js"; -import { sqlCred, sql } from "@cvsa/core"; +import { sqlCred, sql } from "@core/db/dbNew"; export const dbMain = drizzle(sql); export const dbCred = drizzle(sqlCred); diff --git a/packages/core/drizzle/main/schema.ts b/packages/core/drizzle/main/schema.ts index 66d95a5..97651cc 100644 --- a/packages/core/drizzle/main/schema.ts +++ b/packages/core/drizzle/main/schema.ts @@ -181,8 +181,10 @@ export const snapshotSchedule = pgTable("snapshot_schedule", { status: text().default('pending').notNull(), }, (table) => [ index("idx_snapshot_schedule_aid").using("btree", table.aid.asc().nullsLast().op("int8_ops")), + index("idx_snapshot_schedule_started-at_status_type").using("btree", table.startedAt.asc().nullsLast().op("text_ops"), table.status.asc().nullsLast().op("timestamptz_ops"), table.type.asc().nullsLast().op("timestamptz_ops")), index("idx_snapshot_schedule_started_at").using("btree", table.startedAt.asc().nullsLast().op("timestamptz_ops")), index("idx_snapshot_schedule_status").using("btree", table.status.asc().nullsLast().op("text_ops")), + index("idx_snapshot_schedule_status_type_aid").using("btree", table.status.asc().nullsLast().op("int8_ops"), table.type.asc().nullsLast().op("int8_ops"), table.aid.asc().nullsLast().op("text_ops")), index("idx_snapshot_schedule_type").using("btree", table.type.asc().nullsLast().op("text_ops")), uniqueIndex("snapshot_schedule_pkey").using("btree", table.id.asc().nullsLast().op("int8_ops")), ]); diff --git a/packages/core/package.json b/packages/core/package.json index ca50a02..c10d93c 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -15,7 +15,6 @@ "@koshnic/ratelimit": "^1.0.3", "@types/luxon": "^3.7.1", "chalk": "^5.4.1", - "drizzle-orm": "^0.44.4", "ioredis": "^5.6.1", "logform": "^2.7.0", "luxon": "^3.7.2", diff --git a/packages/elysia/lib/auth.ts b/packages/elysia/lib/auth.ts new file mode 100644 index 0000000..a1dc9f3 --- /dev/null +++ b/packages/elysia/lib/auth.ts @@ -0,0 +1 @@ +import Argon2id from "@rabbit-company/argon2id"; \ No newline at end of file diff --git a/packages/elysia/package.json b/packages/elysia/package.json index 8354600..eb89517 100644 --- a/packages/elysia/package.json +++ b/packages/elysia/package.json @@ -10,6 +10,7 @@ "@elysiajs/cors": "^1.4.0", "@elysiajs/openapi": "^1.4.0", "@elysiajs/server-timing": "^1.4.0", + "@rabbit-company/argon2id": "^2.1.0", "chalk": "^5.6.2", "elysia": "^1.4.0", "zod": "^4.1.11" diff --git a/packages/elysia/routes/song/info.ts b/packages/elysia/routes/song/info.ts index 2be240d..2eb42a8 100644 --- a/packages/elysia/routes/song/info.ts +++ b/packages/elysia/routes/song/info.ts @@ -58,102 +58,99 @@ async function getSingers(id: number) { return singers.map((singer) => singer.singers); } -export const getSongInfoHandler = new Elysia({ prefix: "/song" }).get( - "/:id/info", - async ({ params, status }) => { - const id = params.id; - const songID = await getSongID(id); - if (!songID) { - return status(404, { - message: "song not found" - }); - } - const info = await getSongInfo(songID); - if (!info) { - return status(404, { - message: "song not found" - }); - } - const singers = await getSingers(info.id); - return { - name: info.name, - aid: info.aid, - producer: info.producer, - duration: info.duration, - singers: singers, - cover: info.image || undefined - }; - }, - { - response: { - 200: t.Object({ - name: t.Union([t.String(), t.Null()]), - aid: t.Union([t.Number(), t.Null()]), - producer: t.Union([t.String(), t.Null()]), - duration: t.Union([t.Number(), t.Null()]), - singers: t.Array(t.String()), - cover: t.Optional(t.String()) - }), - 404: t.Object({ - message: t.String() - }) +export const songInfoHandler = new Elysia({ prefix: "/song" }) + .get( + "/:id/info", + async ({ params, status }) => { + const id = params.id; + const songID = await getSongID(id); + if (!songID) { + return status(404, { + message: "song not found" + }); + } + const info = await getSongInfo(songID); + if (!info) { + return status(404, { + message: "song not found" + }); + } + const singers = await getSingers(info.id); + return { + name: info.name, + aid: info.aid, + producer: info.producer, + duration: info.duration, + singers: singers, + cover: info.image || undefined + }; }, - detail: { - summary: "Get information of a song", - description: - "This endpoint retrieves detailed information about a song using its unique ID, \ + { + response: { + 200: t.Object({ + name: t.Union([t.String(), t.Null()]), + aid: t.Union([t.Number(), t.Null()]), + producer: t.Union([t.String(), t.Null()]), + duration: t.Union([t.Number(), t.Null()]), + singers: t.Array(t.String()), + cover: t.Optional(t.String()) + }), + 404: t.Object({ + message: t.String() + }) + }, + detail: { + summary: "Get information of a song", + description: + "This endpoint retrieves detailed information about a song using its unique ID, \ which can be provided in several formats. \ The endpoint accepts a song ID in either a numerical format as the internal ID in our database\ or as a bilibili video ID (either av or BV format). \ It responds with the song's name, bilibili ID (av), producer, duration, and associated singers." + } } - } -); - -export const patchInfoHandler = new Elysia({ prefix: "/song" }).patch( - "/:id/info", - async ({ params, status, body }) => { - const id = params.id; - const songID = await getSongID(id); - if (!songID) { - return status(404, { - message: "song not found" - }); - } - const info = await getSongInfo(songID); - if (!info) { - return status(404, { - message: "song not found" - }); - } - if (body.name) { - await dbMain - .update(songs) - .set({ name: body.name }) - .where(eq(songs.id, songID)); - } - if (body.producer) { - await dbMain - .update(songs) - .set({ producer: body.producer }) - .where(eq(songs.id, songID)); - } - return { - message: "success" - }; - }, - { - response: { - 200: t.Object({ - message: t.String() - }), - 404: t.Object({ - message: t.String() - }) + ) + .patch( + "/:id/info", + async ({ params, status, body }) => { + const id = params.id; + const songID = await getSongID(id); + if (!songID) { + return status(404, { + message: "song not found" + }); + } + const info = await getSongInfo(songID); + if (!info) { + return status(404, { + message: "song not found" + }); + } + if (body.name) { + await dbMain.update(songs).set({ name: body.name }).where(eq(songs.id, songID)); + } + if (body.producer) { + await dbMain + .update(songs) + .set({ producer: body.producer }) + .where(eq(songs.id, songID)); + } + return { + message: "success" + }; }, - body: t.Object({ - name: t.Optional(t.String()), - producer: t.Optional(t.String()) - }) - } -); + { + response: { + 200: t.Object({ + message: t.String() + }), + 404: t.Object({ + message: t.String() + }) + }, + body: t.Object({ + name: t.Optional(t.String()), + producer: t.Optional(t.String()) + }) + } + ); diff --git a/packages/elysia/routes/user/login.ts b/packages/elysia/routes/user/login.ts new file mode 100644 index 0000000..85f8add --- /dev/null +++ b/packages/elysia/routes/user/login.ts @@ -0,0 +1,24 @@ +import { dbCred } from "@core/drizzle"; +import { users } from "@core/drizzle/cred/schema"; +import { Elysia, t } from "elysia"; + +export const loginHandler = new Elysia({ prefix: "/login" }).post( + "/session", + async ({ params, status, body }) => { + const { username, password } = body; + + return {}; + }, + { + response: { + 200: t.Object({}), + 404: t.Object({ + message: t.String() + }) + }, + body: t.Object({ + username: t.String(), + password: t.String() + }) + } +); diff --git a/packages/elysia/src/index.ts b/packages/elysia/src/index.ts index 022a366..536f293 100644 --- a/packages/elysia/src/index.ts +++ b/packages/elysia/src/index.ts @@ -3,11 +3,10 @@ import { getBindingInfo, logStartup } from "./startMessage"; import { pingHandler } from "@elysia/routes/ping"; import openapi from "@elysiajs/openapi"; import { cors } from "@elysiajs/cors"; -import { getSongInfoHandler, patchInfoHandler } from "@elysia/routes/song/info"; +import { songInfoHandler } from "@elysia/routes/song/info"; import { rootHandler } from "@elysia/routes/root"; import { getVideoMetadataHandler } from "@elysia/routes/video/metadata"; import { closeMileStoneHandler } from "@elysia/routes/song/milestone"; -import serverTiming from "@elysia/middlewares/timing"; const [host, port] = getBindingInfo(); logStartup(host, port); @@ -65,9 +64,8 @@ const app = new Elysia({ .use(rootHandler) .use(pingHandler) .use(getVideoMetadataHandler) - .use(getSongInfoHandler) + .use(songInfoHandler) .use(closeMileStoneHandler) - .use(patchInfoHandler) .listen(15412); export const VERSION = "0.7.0"; diff --git a/packages/solid/package.json b/packages/solid/package.json index 83df1d2..f1993aa 100644 --- a/packages/solid/package.json +++ b/packages/solid/package.json @@ -18,7 +18,6 @@ "animejs": "^4.1.2", "axios": "^1.11.0", "dotenv": "^16.6.1", - "drizzle-orm": "^0.44.4", "luxon": "^3.7.1", "minimatch": "^10.0.3", "postgres": "^3.4.7", diff --git a/packages/tracker/package.json b/packages/tracker/package.json index dd365a2..baea05c 100644 --- a/packages/tracker/package.json +++ b/packages/tracker/package.json @@ -30,7 +30,6 @@ "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "date-fns": "^4.1.0", - "drizzle-orm": "^0.44.6", "isbot": "^5.1.31", "lucide-react": "^0.545.0", "next-themes": "^0.4.6",