mirror of
https://github.com/ZeroCatDev/ClassworksKV.git
synced 2025-07-02 21:09:23 +00:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f1dba22f75 | ||
![]() |
6cfa20fe76 | ||
![]() |
2b077553f7 | ||
![]() |
0b4fe90c94 | ||
![]() |
05ece2514b | ||
![]() |
d6ab4895d5 |
@ -2,6 +2,11 @@
|
||||
[Classworks](https://cs.houlangs.com)用于班级大屏的作业板小工具
|
||||
|
||||
|
||||
ClassworksKV 是 Classworks 的后端实现,这是一个KV存储服务,用于存储和查询数据信息,如作业、花名册等,也可以用于其他用途。
|
||||
|
||||
|
||||
此项目由[厚浪云](https://houlangs.com)提供,访问公开实例零配置使用 [Classworks](https://cs.houlangs.com)
|
||||
|
||||
[](https://app.rainyun.com/apps/rca/store/6229/wuyuan_)
|
||||
|
||||
## 文档
|
||||
|
4
bin/www
4
bin/www
@ -24,7 +24,7 @@ var server = createServer(app);
|
||||
* Listen on provided port, on all network interfaces.
|
||||
*/
|
||||
|
||||
server.listen(port);
|
||||
server.listen(port, '0.0.0.0');
|
||||
server.on('error', onError);
|
||||
server.on('listening', onListening);
|
||||
|
||||
@ -82,5 +82,5 @@ function onError(error) {
|
||||
|
||||
function onListening() {
|
||||
var addr = server.address();
|
||||
console.log("可以在 http://localhost:"+addr.port+" 访问");
|
||||
console.log(`Server running at http://0.0.0.0:${addr.port}`);
|
||||
}
|
||||
|
@ -13,6 +13,18 @@ const DATABASE_URL =
|
||||
? "file:/data/db.sqlite"
|
||||
: process.env.DATABASE_URL;
|
||||
|
||||
// 🔄 执行数据库迁移函数
|
||||
function runDatabaseMigration() {
|
||||
try {
|
||||
console.log("🔄 执行数据库迁移...");
|
||||
execSync("npx prisma migrate deploy", { stdio: "inherit" });
|
||||
console.log("✅ 数据库迁移完成");
|
||||
} catch (error) {
|
||||
console.error("❌ 数据库迁移失败:", error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// 🧱 数据库初始化函数
|
||||
function setupDatabase() {
|
||||
try {
|
||||
@ -58,11 +70,8 @@ function setupDatabase() {
|
||||
}
|
||||
console.log(`✅ 已复制 ${DATABASE_TYPE} 数据库配置文件和目录`);
|
||||
|
||||
// 设置 Prisma 的 DATABASE_URL
|
||||
process.env.DATABASE_URL = DATABASE_URL;
|
||||
|
||||
// 检查数据库表并执行必要的迁移
|
||||
execSync("npx prisma migrate deploy", { stdio: "inherit" });
|
||||
// 执行数据库迁移
|
||||
runDatabaseMigration();
|
||||
} catch (error) {
|
||||
console.error("❌ 数据库初始化失败:", error.message);
|
||||
process.exit(1);
|
||||
@ -72,6 +81,8 @@ function setupDatabase() {
|
||||
// 🔨 本地构建函数
|
||||
function buildLocal() {
|
||||
try {
|
||||
// 确保数据库迁移已执行
|
||||
runDatabaseMigration();
|
||||
execSync("npm install", { stdio: "inherit" }); // 安装依赖
|
||||
execSync("npx prisma generate", { stdio: "inherit" }); // 生成 Prisma 客户端
|
||||
console.log("✅ 构建完成");
|
||||
|
16
package.json
16
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ClassworksKV",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.5",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node ./bin/www",
|
||||
@ -11,19 +11,19 @@
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@opentelemetry/auto-instrumentations-node": "^0.58.1",
|
||||
"@opentelemetry/exporter-trace-otlp-proto": "^0.200.0",
|
||||
"@opentelemetry/resources": "^2.0.0",
|
||||
"@opentelemetry/sdk-node": "^0.200.0",
|
||||
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
||||
"@opentelemetry/semantic-conventions": "^1.33.0",
|
||||
"@opentelemetry/auto-instrumentations-node": "^0.59.0",
|
||||
"@opentelemetry/exporter-trace-otlp-proto": "^0.201.1",
|
||||
"@opentelemetry/resources": "^2.0.1",
|
||||
"@opentelemetry/sdk-node": "^0.201.1",
|
||||
"@opentelemetry/sdk-trace-base": "^2.0.1",
|
||||
"@opentelemetry/semantic-conventions": "^1.34.0",
|
||||
"@prisma/client": "6.8.2",
|
||||
"axios": "^1.9.0",
|
||||
"bcrypt": "^6.0.0",
|
||||
"body-parser": "^2.2.0",
|
||||
"cookie-parser": "~1.4.4",
|
||||
"cors": "^2.8.5",
|
||||
"debug": "~4.4.0",
|
||||
"debug": "~4.4.1",
|
||||
"dotenv": "^16.5.0",
|
||||
"ejs": "^3.1.10",
|
||||
"express": "~5.1.0",
|
||||
|
1478
pnpm-lock.yaml
generated
1478
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user