Dashboard with YAML
This commit is contained in:
23
server/api/reorder.post.ts
Normal file
23
server/api/reorder.post.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { readDb, writeDb } from '../utils/yamlDb';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event);
|
||||
|
||||
if (!body.items || !Array.isArray(body.items)) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'Invalid items array' });
|
||||
}
|
||||
|
||||
const items = readDb();
|
||||
|
||||
// Expecting body.items: { id: string, type: 'folder' | 'link', order: number }[]
|
||||
for (const updateItem of body.items) {
|
||||
const existing = items.find(i => i.id === updateItem.id);
|
||||
if (existing) {
|
||||
existing.order = updateItem.order;
|
||||
}
|
||||
}
|
||||
|
||||
writeDb(items);
|
||||
|
||||
return { success: true };
|
||||
});
|
||||
Reference in New Issue
Block a user