mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-07 11:24:42 +02:00
In NixOS, we wrap these files in a bash script to allow users to just run them as normal executables, instead of calling them as arguments to Node.JS. In our build scripts, we just add the shebang after the files have been compiled, but adding it upstream will allow all Pangolin users to just run ./server.mjs to start their Pangolin instances. Signed-off-by: Fernando Rodrigues <alpha@sigmasquadron.net>
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
#! /usr/bin/env node
|
|
import "./extendZod.ts";
|
|
|
|
import { runSetupFunctions } from "./setup";
|
|
import { createApiServer } from "./apiServer";
|
|
import { createNextServer } from "./nextServer";
|
|
import { createInternalServer } from "./internalServer";
|
|
import { ApiKey, ApiKeyOrg, Session, User, UserOrg } from "@server/db";
|
|
import { createIntegrationApiServer } from "./integrationApiServer";
|
|
import config from "@server/lib/config";
|
|
|
|
async function startServers() {
|
|
await config.initServer();
|
|
await runSetupFunctions();
|
|
|
|
// Start all servers
|
|
const apiServer = createApiServer();
|
|
const internalServer = createInternalServer();
|
|
const nextServer = await createNextServer();
|
|
|
|
let integrationServer;
|
|
if (config.getRawConfig().flags?.enable_integration_api) {
|
|
integrationServer = createIntegrationApiServer();
|
|
}
|
|
|
|
return {
|
|
apiServer,
|
|
nextServer,
|
|
internalServer,
|
|
integrationServer
|
|
};
|
|
}
|
|
|
|
// Types
|
|
declare global {
|
|
namespace Express {
|
|
interface Request {
|
|
apiKey?: ApiKey;
|
|
user?: User;
|
|
session: Session;
|
|
userOrg?: UserOrg;
|
|
apiKeyOrg?: ApiKeyOrg;
|
|
userOrgRoleId?: number;
|
|
userOrgId?: string;
|
|
userOrgIds?: string[];
|
|
}
|
|
}
|
|
}
|
|
|
|
startServers().catch(console.error);
|