Feat: Natively support NETIFY environment variables and improve MongoDB detection based on URI presence

This commit is contained in:
ypratama committed 2026-08-28 16:43:00 +07:00
1 parent eedaa588b5
commit 2be8b08074
8 files changed
+16 -16

No files matched your search

+3 -3
View File
@@ -34,8 +34,8 @@ export async function getAgents(clientSiteUuid?: string): Promise<Agent[]> {
SITE_UUID = user.site_uuid;
}
// All agent data comes from MongoDB agent_registry (single source of truth)
if (API_KEY && API_KEY.startsWith("sk_db_")) {
// All agent data comes from MongoDB agent_registry if MONGODB_URI is provided or API key is sk_db_
if (process.env.MONGODB_URI || (API_KEY && API_KEY.startsWith("sk_db_"))) {
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://127.0.0.1:27017/backone_dpi';
try {
@@ -79,7 +79,7 @@ export async function getAgents(clientSiteUuid?: string): Promise<Agent[]> {
export async function getAgent(agentId: string): Promise<Agent | null> {
try {
const API_KEY = getApiKey();
if (API_KEY && API_KEY.startsWith("sk_db_")) {
if (process.env.MONGODB_URI || (API_KEY && API_KEY.startsWith("sk_db_"))) {
const agents = await getAgents();
return agents.find(a => a.uuid === agentId || String(a.id) === agentId) || null;
}
+4 -4
View File
@@ -1,11 +1,11 @@
import { revalidatePath } from "next/cache";
export const BASE_URL = process.env.BACKONE_BASE_URL || process.env.BACKONE_INFORMATICS_BASE_URL || "http://127.0.0.1:3011";
export const BASE_URL = process.env.BACKONE_BASE_URL || process.env.NETIFY_BASE_URL || process.env.BACKONE_INFORMATICS_BASE_URL || process.env.NETIFY_INFORMATICS_BASE_URL || "http://127.0.0.1:3011";
export const API_URL = `${BASE_URL}/assets/agents`;
export const getApiKey = () => process.env.BACKONE_API_KEY || process.env.BACKONE_DPI_API_KEY;
export const getJwtToken = () => process.env.BACKONE_JWT_TOKEN || process.env.BACKONE_TOKEN;
export const getSiteUuid = () => process.env.BACKONE_SITE_UUID;
export const getApiKey = () => process.env.BACKONE_API_KEY || process.env.NETIFY_API_KEY || process.env.BACKONE_DPI_API_KEY || process.env.NETIFY_DPI_API_KEY;
export const getJwtToken = () => process.env.BACKONE_JWT_TOKEN || process.env.NETIFY_JWT_TOKEN || process.env.BACKONE_TOKEN || process.env.NETIFY_TOKEN;
export const getSiteUuid = () => process.env.BACKONE_SITE_UUID || process.env.NETIFY_SITE_UUID;
export interface Agent {
id: number;