style: apply Biome formatting to enterprise files

This commit is contained in:
SnapOtter
2026-06-14 14:53:44 +08:00
parent 954cfb01a6
commit e7bef34918
23 changed files with 166 additions and 228 deletions
+5 -1
View File
@@ -86,7 +86,11 @@ export async function apiKeyRoutes(app: FastifyInstance): Promise<void> {
return reply.status(409).send({ error: "Failed to create API key" });
}
await auditFromRequest(request)("API_KEY_CREATED", { userId: user.id, keyId: id, keyName: name });
await auditFromRequest(request)("API_KEY_CREATED", {
userId: user.id,
keyId: id,
keyName: name,
});
// Return the raw key ONCE — it cannot be retrieved again
return reply.status(201).send({
+10 -11
View File
@@ -35,9 +35,9 @@ export async function registerSiemRoutes(app: FastifyInstance): Promise<void> {
// Enterprise package not available
}
if (!featureEnabled) {
return reply
.status(403)
.send({ error: "SIEM forwarding requires an enterprise license with the siem_forwarding feature" });
return reply.status(403).send({
error: "SIEM forwarding requires an enterprise license with the siem_forwarding feature",
});
}
const [row] = await db
@@ -65,10 +65,7 @@ export async function registerSiemRoutes(app: FastifyInstance): Promise<void> {
// PUT /api/v1/enterprise/siem/config
app.put(
"/api/v1/enterprise/siem/config",
async (
request: FastifyRequest<{ Body: unknown }>,
reply: FastifyReply,
) => {
async (request: FastifyRequest<{ Body: unknown }>, reply: FastifyReply) => {
const user = await requirePermission("webhooks:manage")(request, reply);
if (!user) return;
@@ -81,14 +78,16 @@ export async function registerSiemRoutes(app: FastifyInstance): Promise<void> {
// Enterprise package not available
}
if (!featureEnabled) {
return reply
.status(403)
.send({ error: "SIEM forwarding requires an enterprise license with the siem_forwarding feature" });
return reply.status(403).send({
error: "SIEM forwarding requires an enterprise license with the siem_forwarding feature",
});
}
const parsed = configSchema.safeParse(request.body);
if (!parsed.success) {
return reply.status(400).send({ error: "Invalid SIEM config", details: parsed.error.issues });
return reply
.status(400)
.send({ error: "Invalid SIEM config", details: parsed.error.issues });
}
const config = { ...parsed.data };
+7 -4
View File
@@ -9,10 +9,10 @@
import { eq } from "drizzle-orm";
import type { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
import { z } from "zod";
import { env } from "../config.js";
import { db, schema } from "../db/index.js";
import { auditFromRequest } from "../lib/audit.js";
import { env } from "../config.js";
import { encrypt, decrypt, isEncrypted } from "../lib/encryption.js";
import { decrypt, encrypt, isEncrypted } from "../lib/encryption.js";
import { requirePermission } from "../permissions.js";
import { requireAuth } from "../plugins/auth.js";
@@ -37,8 +37,11 @@ async function decryptIfNeeded(value: string): Promise<string> {
if (!isEncrypted(value)) return value;
if (!env.DATA_ENCRYPTION_KEY) return value;
return (
(await decrypt(value, env.DATA_ENCRYPTION_KEY, env.DATA_ENCRYPTION_KEY_PREVIOUS || undefined)) ??
value
(await decrypt(
value,
env.DATA_ENCRYPTION_KEY,
env.DATA_ENCRYPTION_KEY_PREVIOUS || undefined,
)) ?? value
);
}