2025-04-06 16:06:50 -04:00
|
|
|
import "./extendZod.ts";
|
|
|
|
|
2025-01-01 17:50:12 -05:00
|
|
|
import { runSetupFunctions } from "./setup";
|
2024-12-07 22:07:13 -05:00
|
|
|
import { createApiServer } from "./apiServer";
|
|
|
|
import { createNextServer } from "./nextServer";
|
|
|
|
import { createInternalServer } from "./internalServer";
|
2025-04-28 21:14:09 -04:00
|
|
|
import { ApiKey, ApiKeyOrg, Session, User, UserOrg } from "./db/schemas";
|
|
|
|
import { createIntegrationApiServer } from "./integrationApiServer";
|
2025-05-13 11:09:38 -04:00
|
|
|
import config from "@server/lib/config";
|
2024-12-07 22:07:13 -05:00
|
|
|
|
|
|
|
async function startServers() {
|
2024-12-22 12:33:49 -05:00
|
|
|
await runSetupFunctions();
|
2024-12-07 22:07:13 -05:00
|
|
|
|
2024-12-12 22:46:58 -05:00
|
|
|
// Start all servers
|
|
|
|
const apiServer = createApiServer();
|
|
|
|
const internalServer = createInternalServer();
|
2024-12-25 15:49:35 -05:00
|
|
|
const nextServer = await createNextServer();
|
2024-12-12 22:46:58 -05:00
|
|
|
|
2025-04-28 21:14:09 -04:00
|
|
|
let integrationServer;
|
2025-05-13 11:09:38 -04:00
|
|
|
if (config.getRawConfig().flags?.enable_integration_api) {
|
2025-04-28 21:14:09 -04:00
|
|
|
integrationServer = createIntegrationApiServer();
|
|
|
|
}
|
|
|
|
|
2024-12-12 22:46:58 -05:00
|
|
|
return {
|
|
|
|
apiServer,
|
|
|
|
nextServer,
|
|
|
|
internalServer,
|
2025-04-28 21:14:09 -04:00
|
|
|
integrationServer
|
2024-12-12 22:46:58 -05:00
|
|
|
};
|
2024-12-07 22:07:13 -05:00
|
|
|
}
|
2024-10-03 20:55:54 -04:00
|
|
|
|
2024-12-07 22:07:13 -05:00
|
|
|
// Types
|
2024-10-26 17:19:10 -04:00
|
|
|
declare global {
|
2024-12-12 22:46:58 -05:00
|
|
|
namespace Express {
|
|
|
|
interface Request {
|
2025-04-28 21:14:09 -04:00
|
|
|
apiKey?: ApiKey;
|
2024-12-12 22:46:58 -05:00
|
|
|
user?: User;
|
2025-01-26 14:42:02 -05:00
|
|
|
session?: Session;
|
2024-12-12 22:46:58 -05:00
|
|
|
userOrg?: UserOrg;
|
2025-04-28 21:14:09 -04:00
|
|
|
apiKeyOrg?: ApiKeyOrg;
|
2024-12-12 22:46:58 -05:00
|
|
|
userOrgRoleId?: number;
|
|
|
|
userOrgId?: string;
|
|
|
|
userOrgIds?: string[];
|
|
|
|
}
|
2024-10-03 20:55:54 -04:00
|
|
|
}
|
2024-10-26 17:19:10 -04:00
|
|
|
}
|
2024-12-07 22:07:13 -05:00
|
|
|
|
|
|
|
startServers().catch(console.error);
|