gristlabs_grist-core/stubs/app/server/server.ts
Paul Fitzpatrick 9b02d16bff (core) more grist-core cleanup
Summary:
 * Remove duplicate schema file
 * Move version file to a stub in grist-core
 * Simplify sandbox creation in grist-core (although not functional until sandbox code moved)
 * Add a minimal test for buildability

Test Plan: added test

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2560
2020-07-23 16:21:08 -04:00

30 lines
865 B
TypeScript

/**
* Main entrypoint for grist-core server.
*/
import {updateDb} from 'app/server/lib/dbUtils';
import {main as mergedServerMain} from 'app/server/mergedServerMain';
import * as fse from 'fs-extra';
const G = {
port: parseInt(process.env.PORT!, 10) || 8484,
};
export async function main() {
// Use a distinct cookie.
if (!process.env.GRIST_SESSION_COOKIE) {
process.env.GRIST_SESSION_COOKIE = 'grist_core';
}
// This is where documents are placed, for historic reasons.
await fse.mkdirp('samples');
// Make a blank db if needed.
await updateDb();
// Launch single-port, self-contained version of Grist.
// You probably want to have GRIST_DEFAULT_EMAIL set since there's no login system yet.
await mergedServerMain(G.port, ["home", "docs", "static"]);
}
if (require.main === module) {
main().catch((err) => console.error(err));
}