`);
- }));
+ })
+ );
}
- this.app.get('/logout', ...this._logoutMiddleware(), expressWrap(async (req, resp) => {
- const signedOutUrl = new URL(getOrgUrl(req) + 'signed-out');
- const redirectUrl = await this._getLogoutRedirectUrl(req, signedOutUrl);
- resp.redirect(redirectUrl);
- }));
+ this.app.get(
+ "/logout",
+ ...this._logoutMiddleware(),
+ expressWrap(async (req, resp) => {
+ const signedOutUrl = new URL(getOrgUrl(req) + "signed-out");
+ const redirectUrl = await this._getLogoutRedirectUrl(req, signedOutUrl);
+ resp.redirect(redirectUrl);
+ })
+ );
// Add a static "signed-out" page. This is where logout typically lands (e.g. after redirecting
// through SAML).
- this.app.get('/signed-out', expressWrap((req, resp) =>
- this._sendAppPage(req, resp, {path: 'error.html', status: 200, config: {errPage: 'signed-out'}})));
+ this.app.get(
+ "/signed-out",
+ expressWrap((req, resp) =>
+ this._sendAppPage(req, resp, {
+ path: "error.html",
+ status: 200,
+ config: { errPage: "signed-out" },
+ })
+ )
+ );
const comment = await this._loginMiddleware.addEndpoints(this.app);
- this.info.push(['loginMiddlewareComment', comment]);
+ this.info.push(["loginMiddlewareComment", comment]);
addDiscourseConnectEndpoints(this.app, {
userIdMiddleware: this._userIdMiddleware,
@@ -1442,10 +1917,15 @@ export class FlexServer implements GristServer {
}
public async addTestingHooks(workerServers?: FlexServer[]) {
- this._check('testinghooks', 'comm');
+ this._check("testinghooks", "comm");
if (process.env.GRIST_TESTING_SOCKET) {
- await startTestingHooks(process.env.GRIST_TESTING_SOCKET, this.port, this._comm, this,
- workerServers || []);
+ await startTestingHooks(
+ process.env.GRIST_TESTING_SOCKET,
+ this.port,
+ this._comm,
+ this,
+ workerServers || []
+ );
this._hasTestingHooks = true;
}
}
@@ -1462,10 +1942,20 @@ export class FlexServer implements GristServer {
// Add document-related endpoints and related support.
public async addDoc() {
- this._check('doc', 'start', 'tag', 'json', isSingleUserMode() ?
- null : 'homedb', 'api-mw', 'map', 'telemetry');
+ this._check(
+ "doc",
+ "start",
+ "tag",
+ "json",
+ isSingleUserMode() ? null : "homedb",
+ "api-mw",
+ "map",
+ "telemetry"
+ );
// add handlers for cleanup, if we are in charge of the doc manager.
- if (!this._docManager) { this.addCleanup(); }
+ if (!this._docManager) {
+ this.addCleanup();
+ }
await this.addLoginMiddleware();
this.addComm();
// Check SQLite mode so it shows up in initial configuration readout
@@ -1475,52 +1965,80 @@ export class FlexServer implements GristServer {
await this.create.configure?.();
if (!isSingleUserMode()) {
- const externalStorage = appSettings.section('externalStorage');
- const haveExternalStorage = Object.values(externalStorage.nested)
- .some(storage => storage.flag('active').getAsBool());
- const disabled = externalStorage.flag('disable')
- .read({ envVar: 'GRIST_DISABLE_S3' }).getAsBool();
+ const externalStorage = appSettings.section("externalStorage");
+ const haveExternalStorage = Object.values(externalStorage.nested).some(
+ (storage) => storage.flag("active").getAsBool()
+ );
+ const disabled = externalStorage
+ .flag("disable")
+ .read({ envVar: "GRIST_DISABLE_S3" })
+ .getAsBool();
if (disabled || !haveExternalStorage) {
this._disableExternalStorage = true;
- externalStorage.flag('active').set(false);
+ externalStorage.flag("active").set(false);
}
await this.create.checkBackend?.();
const workers = this._docWorkerMap;
const docWorkerId = await this._addSelfAsWorker(workers);
const storageManager = await this.create.createHostedDocStorageManager(
- this, this.docsRoot, docWorkerId, this._disableExternalStorage, workers, this._dbManager,
+ this,
+ this.docsRoot,
+ docWorkerId,
+ this._disableExternalStorage,
+ workers,
+ this._dbManager,
this.create.ExternalStorage.bind(this.create)
);
this._storageManager = storageManager;
} else {
- const samples = getAppPathTo(this.appRoot, 'public_samples');
+ const samples = getAppPathTo(this.appRoot, "public_samples");
const storageManager = await this.create.createLocalDocStorageManager(
- this.docsRoot, samples, this._comm, undefined, this);
+ this.docsRoot,
+ samples,
+ this._comm,
+ undefined,
+ this
+ );
this._storageManager = storageManager;
}
const pluginManager = await this._addPluginManager();
- const allStoreOptions = Object.values(this.create.getAttachmentStoreOptions());
- const checkedStoreOptions = await checkAvailabilityAttachmentStoreOptions(allStoreOptions);
+ const allStoreOptions = Object.values(
+ this.create.getAttachmentStoreOptions()
+ );
+ const checkedStoreOptions = await checkAvailabilityAttachmentStoreOptions(
+ allStoreOptions
+ );
log.info("Attachment store backend availability", {
- available: checkedStoreOptions.available.map(option => option.name),
- unavailable: checkedStoreOptions.unavailable.map(option => option.name),
+ available: checkedStoreOptions.available.map((option) => option.name),
+ unavailable: checkedStoreOptions.unavailable.map((option) => option.name),
});
- this._attachmentStoreProvider = this._attachmentStoreProvider || new AttachmentStoreProvider(
- await getConfiguredAttachmentStoreConfigs(),
- (await this.getActivations().current()).id,
- );
- this._docManager = this._docManager || new DocManager(this._storageManager,
- pluginManager,
- this._dbManager,
- this._attachmentStoreProvider,
- this);
+ this._attachmentStoreProvider =
+ this._attachmentStoreProvider ||
+ new AttachmentStoreProvider(
+ await getConfiguredAttachmentStoreConfigs(),
+ (await this.getActivations().current()).id
+ );
+ this._docManager =
+ this._docManager ||
+ new DocManager(
+ this._storageManager,
+ pluginManager,
+ this._dbManager,
+ this._attachmentStoreProvider,
+ this
+ );
const docManager = this._docManager;
- shutdown.addCleanupHandler(null, this._shutdown.bind(this), 25000, 'FlexServer._shutdown');
+ shutdown.addCleanupHandler(
+ null,
+ this._shutdown.bind(this),
+ 25000,
+ "FlexServer._shutdown"
+ );
if (!isSingleUserMode()) {
this._docWorkerLoadTracker = getDocWorkerLoadTracker(
@@ -1537,13 +2055,16 @@ export class FlexServer implements GristServer {
this._docWorkerLoadTracker.start();
}
this._comm.registerMethods({
- openDoc: docManager.openDoc.bind(docManager),
+ openDoc: docManager.openDoc.bind(docManager),
});
this._serveDocPage();
}
// Attach docWorker endpoints and Comm methods.
- const docWorker = new DocWorker(this._dbManager, {comm: this._comm, gristServer: this});
+ const docWorker = new DocWorker(this._dbManager, {
+ comm: this._comm,
+ gristServer: this,
+ });
this._docWorker = docWorker;
// Register the websocket comm functions associated with the docworker.
@@ -1554,50 +2075,61 @@ export class FlexServer implements GristServer {
const docAccessMiddleware = [
this._userIdMiddleware,
this._docPermissionsMiddleware,
- this.tagChecker.requireTag
+ this.tagChecker.requireTag,
];
this._addSupportPaths(docAccessMiddleware);
if (!isSingleUserMode()) {
- addDocApiRoutes(this.app, docWorker, this._docWorkerMap, docManager, this._dbManager,
- this._attachmentStoreProvider, this);
+ addDocApiRoutes(
+ this.app,
+ docWorker,
+ this._docWorkerMap,
+ docManager,
+ this._dbManager,
+ this._attachmentStoreProvider,
+ this
+ );
}
}
public async getSandboxInfo(): Promise