fosrl.pangolin/server/index.ts
Fernando Rodrigues 9e87c42d0c
add shebangs to migration and server scripts
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>
2025-07-27 13:10:18 +10:00

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);