CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/hub/servers/database.ts
Views: 926
1
import { db } from "@cocalc/database";
2
import { enableDbAdminAlerts } from "@cocalc/server/messages/admin-alert";
3
4
// IMPORTANT: For typescript we make the default export have type PostgreSQL.
5
// In reality the default could be undefined until init gets called.
6
// We thus assume for convenience that init gets called before this default
7
// object gets used.
8
export let database: any = undefined;
9
10
export default function init(opts) {
11
if (database != null) {
12
throw Error("only call database init once");
13
}
14
database = db(opts);
15
16
enableDbAdminAlerts();
17
}
18
19