mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Adding events for auto reload on data updating.
This commit is contained in:
@@ -5,6 +5,7 @@ import {isUuidv4} from "@/utils/verify-uuid";
|
||||
import {uploadLocalPrivate} from "@/features/upload/private/upload.action";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import {Backup, Database} from "@prisma/client";
|
||||
import {eventEmitter} from "../../../events/route";
|
||||
|
||||
export async function POST(
|
||||
request: Request,
|
||||
@@ -118,6 +119,7 @@ export async function POST(
|
||||
status: "success",
|
||||
},
|
||||
});
|
||||
eventEmitter.emit('modification', { update: true });
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -130,6 +132,7 @@ export async function POST(
|
||||
where: { id: backup.id },
|
||||
data: { status: "failed" },
|
||||
});
|
||||
eventEmitter.emit('modification', { update: true });
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {NextResponse} from "next/server";
|
||||
import {isUuidv4} from "@/utils/verify-uuid";
|
||||
import {prisma} from "@/prisma";
|
||||
import {eventEmitter} from "../../../events/route";
|
||||
|
||||
|
||||
|
||||
@@ -72,6 +73,10 @@ export async function POST(
|
||||
message: true,
|
||||
details: "Restoration successfully updated"
|
||||
}
|
||||
|
||||
eventEmitter.emit('modification', { update: true });
|
||||
|
||||
|
||||
return Response.json(response , {status: 200})
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import {NextResponse} from "next/server";
|
||||
import {Dbms} from "@prisma/client";
|
||||
import {getFileUrlPresignedLocal} from "@/features/upload/private/upload.action";
|
||||
import {handleDatabases} from "./helpers";
|
||||
import {eventEmitter} from "../../../events/route";
|
||||
|
||||
|
||||
export type databaseAgent = {
|
||||
@@ -50,6 +51,8 @@ export async function POST(
|
||||
}
|
||||
})
|
||||
|
||||
eventEmitter.emit('modification', { update: true });
|
||||
|
||||
const response = {
|
||||
agent: {
|
||||
id: agentId,
|
||||
@@ -58,7 +61,6 @@ export async function POST(
|
||||
databases: databasesResponse
|
||||
}
|
||||
console.log(response)
|
||||
|
||||
return Response.json(response)
|
||||
} catch (error) {
|
||||
console.error('Error in POST handler:', error);
|
||||
|
||||
Reference in New Issue
Block a user