Refactor app management to use Drizzle ORM
- Replaced Sequelize models with Drizzle ORM for app and app list management. - Updated routes in app-manager to utilize new database queries. - Removed obsolete Sequelize model files for app, app list, and app domain. - Introduced new helper functions for app and app domain management. - Enhanced user app management with improved file handling and user migration. - Adjusted public API routes to align with new database structure. - Implemented caching mechanisms for domain management.
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import { app } from '@/app.ts';
|
||||
import { AppModel } from '../module/index.ts';
|
||||
import { AppListModel } from '../module/index.ts';
|
||||
import { app, db, schema } from '@/app.ts';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { oss } from '@/app.ts';
|
||||
import { User } from '@/models/user.ts';
|
||||
import { permission } from 'process';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
@@ -65,7 +63,8 @@ app
|
||||
path: urlPath,
|
||||
},
|
||||
];
|
||||
const appModel = await AppModel.create({
|
||||
const appModels = await db.insert(schema.kvApp).values({
|
||||
id: randomUUID(),
|
||||
title,
|
||||
description,
|
||||
version,
|
||||
@@ -80,15 +79,18 @@ app
|
||||
},
|
||||
files: files,
|
||||
},
|
||||
});
|
||||
const appVersionModel = await AppListModel.create({
|
||||
}).returning();
|
||||
const appModel = appModels[0];
|
||||
const appVersionModels = await db.insert(schema.kvAppList).values({
|
||||
id: randomUUID(),
|
||||
data: {
|
||||
files: files,
|
||||
},
|
||||
version: appModel.version,
|
||||
key: appModel.key,
|
||||
uid: appModel.uid,
|
||||
});
|
||||
}).returning();
|
||||
const appVersionModel = appVersionModels[0];
|
||||
|
||||
ctx.body = {
|
||||
url: `/${username}/${key}/`,
|
||||
|
||||
Reference in New Issue
Block a user