(core) simplify starting grist-core and add some more usage information

Summary:
I worked through the README for grist-core, and the instructions
for setting it up and starting it.  This change includes a small
simplification, and a few more instructions for getting started.

Test Plan: manual

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2619
pull/4/head
Paul Fitzpatrick 4 years ago
parent a15187362c
commit cff02cd3d0

@ -45,12 +45,20 @@ For building from source, you can start with this:
npm install
npm run build:prod
npm run install:python
GRIST_DEFAULT_EMAIL=you@example.com npm start
npm start
# unauthenticated grist api available at http://localhost:8484/api/
Stay tuned for more instructions to come at release.
Then you can use the Grist API locally to work on a document. Currently you need
to "upload" a document to work with it. This makes a copy of it that the server
controls - you can find it in the `data` directory:
For using pre-built Grist, just head on over to <https://www.getgrist.com>.
curl -F 'upload=@YourDocument.grist' http://localhost:8484/api/docs
# Note the document ID that is returned.
The [Data-Tables endpoints](https://support.getgrist.com/api/#tag/Data-Tables) are
particularly useful.
For using hosted Grist, just head on over to <https://www.getgrist.com>.
# License

@ -1,5 +1,7 @@
/**
* Main entrypoint for grist-core server.
*
* By default, starts up on port 8484.
*/
import {updateDb} from 'app/server/lib/dbUtils';
@ -10,20 +12,28 @@ const G = {
port: parseInt(process.env.PORT!, 10) || 8484,
};
// Set a default for an environment variable.
function setDefaultEnv(name: string, value: string) {
if (process.env[name] === undefined) {
process.env[name] = value;
}
}
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');
setDefaultEnv('GRIST_SESSION_COOKIE', 'grist_core');
// There's no login system released yet, so set a default email address.
setDefaultEnv('GRIST_DEFAULT_EMAIL', 'support@getgrist.com');
// Set directory for uploaded documents.
setDefaultEnv('GRIST_DATA_DIR', 'data');
await fse.mkdirp(process.env.GRIST_DATA_DIR!);
// 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) {
// tslint:disable-next-line:no-console
main().catch((err) => console.error(err));
}

Loading…
Cancel
Save