feat(server): audit log streams services and api routes

This commit is contained in:
Akhil Mohan
2024-05-03 00:23:58 +05:30
parent 69aa20e35c
commit f2b1f3f0e7
14 changed files with 546 additions and 3 deletions
+22
View File
@@ -614,3 +614,25 @@ export const INTEGRATION = {
integrationId: "The ID of the integration object."
}
};
export const AUDIT_LOG_STREAMS = {
CREATE: {
projectSlug: "The slug of the project to create audit log stream.",
url: "The socket URL to push logs to.",
token: "Authentication token for the external provider used for identification."
},
UPDATE: {
id: "The ID of the audit log stream to update.",
url: "The socket URL to push logs to.",
token: "Authentication token for the external provider used for identification."
},
DELETE: {
id: "The ID of the audit log stream to delete."
},
LIST: {
projectSlug: "The slug of the project to list audit log streams."
},
GET_BY_ID: {
id: "The ID of the audit log stream to get details."
}
};
+1
View File
@@ -119,6 +119,7 @@ const envSchema = z
})
.transform((data) => ({
...data,
isCloud: Boolean(data.LICENSE_SERVER_KEY),
isSmtpConfigured: Boolean(data.SMTP_HOST),
isRedisConfigured: Boolean(data.REDIS_URL),
isDevelopmentMode: data.NODE_ENV === "development",
+1
View File
@@ -1 +1,2 @@
export { isDisposableEmail } from "./validate-email";
export { validateLocalIps } from "./validate-url";
+18
View File
@@ -0,0 +1,18 @@
import { getConfig } from "../config/env";
import { BadRequestError } from "../errors";
export const validateLocalIps = (url: string) => {
const validUrl = new URL(url);
const appCfg = getConfig();
// on cloud local ips are not allowed
if (
appCfg.isCloud &&
(validUrl.host === "host.docker.internal" ||
validUrl.host.match(/^10\.\d+\.\d+\.\d+/) ||
validUrl.host.match(/^192\.168\.\d+\.\d+/))
)
throw new BadRequestError({ message: "Local IPs not allowed as URL" });
if (validUrl.host === "localhost" || validUrl.host === "127.0.0.1")
throw new BadRequestError({ message: "Localhost not allowed" });
};