mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) move home server into core
Summary: This moves enough server material into core to run a home server. The data engine is not yet incorporated (though in manual testing it works when ported). Test Plan: existing tests pass Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2552
This commit is contained in:
25
stubs/app/server/lib/LoginSession.ts
Normal file
25
stubs/app/server/lib/LoginSession.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {UserProfile} from 'app/common/LoginSessionAPI';
|
||||
import {Client} from 'app/server/lib/Client';
|
||||
import {ILoginSession} from 'app/server/lib/ILoginSession';
|
||||
|
||||
export class LoginSession implements ILoginSession {
|
||||
public clients: Set<Client> = new Set();
|
||||
public async getEmail() {
|
||||
return 'anon@getgrist.com';
|
||||
}
|
||||
public async clearSession(): Promise<void> {
|
||||
// do nothing
|
||||
}
|
||||
public async testSetProfile(profile: UserProfile|null): Promise<void> {
|
||||
// do nothing
|
||||
}
|
||||
public async updateTokenForTesting(idToken: string): Promise<void> {
|
||||
// do nothing
|
||||
}
|
||||
public async getCurrentTokenForTesting(): Promise<string|null> {
|
||||
return null;
|
||||
}
|
||||
public async useTestToken(idToken: string): Promise<void> {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
4
stubs/app/server/lib/StandaloneExtras.ts
Normal file
4
stubs/app/server/lib/StandaloneExtras.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export function addStandaloneMethods(...args: any[]) {
|
||||
console.log("Not adding any standalone methods");
|
||||
return {} as any;
|
||||
}
|
||||
65
stubs/app/server/lib/create.ts
Normal file
65
stubs/app/server/lib/create.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { HomeDBManager } from 'app/gen-server/lib/HomeDBManager';
|
||||
import { ActiveDoc } from 'app/server/lib/ActiveDoc';
|
||||
import { DocManager } from 'app/server/lib/DocManager';
|
||||
import { ICreate } from 'app/server/lib/ICreate';
|
||||
import { LoginSession } from 'app/server/lib/LoginSession';
|
||||
import { NSandbox } from 'app/server/lib/NSandbox';
|
||||
|
||||
export const create: ICreate = {
|
||||
LoginSession() {
|
||||
return new LoginSession();
|
||||
},
|
||||
Billing(dbManager: HomeDBManager) {
|
||||
return {
|
||||
addEndpoints(app: any) { /* do nothing */ },
|
||||
addEventHandlers() { /* do nothing */ },
|
||||
addWebhooks(app: any) { /* do nothing */ }
|
||||
};
|
||||
},
|
||||
Notifier(dbManager: HomeDBManager, homeUrl: string) {
|
||||
return {
|
||||
get testPending() { return false; }
|
||||
};
|
||||
},
|
||||
Shell() {
|
||||
return {
|
||||
moveItemToTrash() { throw new Error('moveToTrash unavailable'); },
|
||||
showItemInFolder() { throw new Error('showItemInFolder unavailable'); }
|
||||
};
|
||||
},
|
||||
ExternalStorage() { return undefined; },
|
||||
ActiveDoc(docManager, docName) { return new ActiveDoc(docManager, docName); },
|
||||
DocManager(storageManager, pluginManager, homeDBManager, gristServer) {
|
||||
return new DocManager(storageManager, pluginManager, homeDBManager, gristServer);
|
||||
},
|
||||
NSandbox(options) {
|
||||
const args = [options.entryPoint || 'grist/main.pyc'];
|
||||
if (!options.entryPoint && options.comment) {
|
||||
// Note that docName isn't used by main.py, but it makes it possible to tell in `ps` output
|
||||
// which sandbox process is for which document.
|
||||
args.push(options.comment);
|
||||
}
|
||||
const selLdrArgs: string[] = [];
|
||||
if (options.sandboxMount) {
|
||||
selLdrArgs.push(
|
||||
// TODO: Only modules that we share with plugins should be mounted. They could be gathered in
|
||||
// a "$APPROOT/sandbox/plugin" folder, only which get mounted.
|
||||
'-E', 'PYTHONPATH=grist:thirdparty',
|
||||
'-m', `${options.sandboxMount}:/sandbox:ro`);
|
||||
}
|
||||
if (options.importMount) {
|
||||
selLdrArgs.push('-m', `${options.importMount}:/importdir:ro`);
|
||||
}
|
||||
return new NSandbox({
|
||||
args,
|
||||
logCalls: options.logCalls,
|
||||
logMeta: options.logMeta,
|
||||
logTimes: options.logTimes,
|
||||
selLdrArgs,
|
||||
});
|
||||
},
|
||||
sessionSecret() {
|
||||
return process.env.GRIST_SESSION_SECRET ||
|
||||
'Phoo2ag1jaiz6Moo2Iese2xoaphahbai3oNg7diemohlah0ohtae9iengafieS2Hae7quungoCi9iaPh';
|
||||
}
|
||||
};
|
||||
12
stubs/app/server/lib/logins.ts
Normal file
12
stubs/app/server/lib/logins.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import {GristLoginMiddleware} from 'app/server/lib/GristServer';
|
||||
|
||||
export async function getLoginMiddleware(): Promise<GristLoginMiddleware> {
|
||||
return {
|
||||
async getLoginRedirectUrl(target: URL) { throw new Error('logins not implemented'); },
|
||||
async getLogoutRedirectUrl(target: URL) { throw new Error('logins not implemented'); },
|
||||
async getSignUpRedirectUrl(target: URL) { throw new Error('logins not implemented'); },
|
||||
addEndpoints(...args: any[]) {
|
||||
return "no-logins";
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user