mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
implementing snapshots
This commit is contained in:
19
dashboard/server/api/project/snapshots.ts
Normal file
19
dashboard/server/api/project/snapshots.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
import { ProjectSnapshotModel, TProjectSnapshot } from "@schema/ProjectSnapshot";
|
||||
import { UserSettingsModel } from "@schema/UserSettings";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
const userData = getRequestUser(event);
|
||||
if (!userData?.logged) return setResponseStatus(event, 400, 'NotLogged');
|
||||
|
||||
const currentActiveProject = await UserSettingsModel.findOne({ user_id: userData.id });
|
||||
if (!currentActiveProject) return setResponseStatus(event, 400, 'You need to select a project');
|
||||
|
||||
const project_id = currentActiveProject.active_project_id;
|
||||
|
||||
const snapshots = await ProjectSnapshotModel.find({ project_id });
|
||||
|
||||
return snapshots.map(e => e.toJSON()) as TProjectSnapshot[];
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user