fosrl.pangolin/server/index.ts

49 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-04-06 16:06:50 -04:00
import "./extendZod.ts";
import { runSetupFunctions } from "./setup";
2024-12-07 22:07:13 -05:00
import { createApiServer } from "./apiServer";
import { createNextServer } from "./nextServer";
import { createInternalServer } from "./internalServer";
import { ApiKey, ApiKeyOrg, Session, User, UserOrg } from "./db/schemas";
import { createIntegrationApiServer } from "./integrationApiServer";
import license from "./license/license.js";
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
// Start all servers
const apiServer = createApiServer();
const internalServer = createInternalServer();
2024-12-25 15:49:35 -05:00
const nextServer = await createNextServer();
let integrationServer;
if (await license.isUnlocked()) {
integrationServer = createIntegrationApiServer();
}
return {
apiServer,
nextServer,
internalServer,
integrationServer
};
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 {
namespace Express {
interface Request {
apiKey?: ApiKey;
user?: User;
session?: Session;
userOrg?: UserOrg;
apiKeyOrg?: ApiKeyOrg;
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);