b6167bcb-7363-4695-9481-addd81de4367
This commit is contained in:
1 parent
fdc3b82d10
commit
d226dabba3
136 files changed
+13904
-2
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { db } from '@/lib/db'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
// GET /api/aos/modules — module registry
|
||||
export async function GET() {
|
||||
const modules = await db.module.findMany({ orderBy: { id: 'asc' } })
|
||||
const settings = await db.setting.findMany()
|
||||
return NextResponse.json({
|
||||
modules,
|
||||
settings: Object.fromEntries(settings.map((s) => [s.key, s.value])),
|
||||
})
|
||||
}
|
||||
|
||||
// PATCH /api/aos/modules — toggle a module on/off
|
||||
export async function PATCH(req: Request) {
|
||||
const { id, enabled } = (await req.json()) as { id: string; enabled: boolean }
|
||||
const mod = await db.module.update({ where: { id }, data: { enabled } })
|
||||
await db.auditLog.create({
|
||||
data: {
|
||||
actor: 'max@nordlicht.digital',
|
||||
action: 'module.' + (enabled ? 'enable' : 'disable'),
|
||||
entity: 'Module',
|
||||
entityId: id,
|
||||
after: JSON.stringify({ enabled }),
|
||||
hash: 'sha256:' + Math.random().toString(36).slice(2),
|
||||
},
|
||||
})
|
||||
return NextResponse.json({ module: mod })
|
||||
}
|
||||
Reference in new issue
Block a user