mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Update export CSV and Excel endpoints
Summary: The endpoints for exporting CSV and Excel are now under /api/docs/:docId/ and are forwarded to a doc worker for export. The Share Menu has been updated to use the new endpoints. Test Plan: No new tests. Existing tests that verify endpoints work correctly. Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D3007
This commit is contained in:
@@ -33,6 +33,7 @@ import { googleAuthTokenMiddleware } from "app/server/lib/GoogleAuth";
|
||||
import * as _ from "lodash";
|
||||
import {isRaisedException} from "app/common/gristTypes";
|
||||
import {localeFromRequest} from "app/server/lib/ServerLocale";
|
||||
import { generateCSV, generateXLSX } from "app/server/serverMethods";
|
||||
|
||||
// Cap on the number of requests that can be outstanding on a single document via the
|
||||
// rest doc api. When this limit is exceeded, incoming requests receive an immediate
|
||||
@@ -565,6 +566,10 @@ export class DocWorkerApi {
|
||||
res.json(result);
|
||||
}));
|
||||
|
||||
this._app.get('/api/docs/:docId/gen-csv', canView, withDoc(generateCSV));
|
||||
|
||||
this._app.get('/api/docs/:docId/gen-xlsx', canView, withDoc(generateXLSX));
|
||||
|
||||
this._app.get('/api/docs/:docId/send-to-drive', canView, decodeGoogleToken, withDoc(exportToDrive));
|
||||
|
||||
// Create a document. When an upload is included, it is imported as the initial
|
||||
|
||||
@@ -13,7 +13,6 @@ import {IDocStorageManager} from 'app/server/lib/IDocStorageManager';
|
||||
import * as log from 'app/server/lib/log';
|
||||
import {integerParam, optStringParam, stringParam} from 'app/server/lib/requestUtils';
|
||||
import {OpenMode, quoteIdent, SQLiteDB} from 'app/server/lib/SQLiteDB';
|
||||
import {generateCSV, generateXLSX} from 'app/server/serverMethods';
|
||||
import * as contentDisposition from 'content-disposition';
|
||||
import * as express from 'express';
|
||||
import * as fse from 'fs-extra';
|
||||
@@ -30,14 +29,6 @@ export class DocWorker {
|
||||
this._comm = comm;
|
||||
}
|
||||
|
||||
public async getCSV(req: express.Request, res: express.Response): Promise<void> {
|
||||
await generateCSV(req, res, this._comm);
|
||||
}
|
||||
|
||||
public async getXLSX(req: express.Request, res: express.Response): Promise<void> {
|
||||
await generateXLSX(req, res, this._comm);
|
||||
}
|
||||
|
||||
public async getAttachment(req: express.Request, res: express.Response): Promise<void> {
|
||||
try {
|
||||
const docSession = this._getDocSession(stringParam(req.query.clientId),
|
||||
|
||||
@@ -1266,14 +1266,6 @@ export class FlexServer implements GristServer {
|
||||
// This doesn't check for doc access permissions because the request isn't tied to a document.
|
||||
addUploadRoute(this, this.app, this._trustOriginsMiddleware, ...basicMiddleware);
|
||||
|
||||
this.app.get('/gen_csv', ...docAccessMiddleware, expressWrap(async (req, res) => {
|
||||
return this._docWorker.getCSV(req, res);
|
||||
}));
|
||||
|
||||
this.app.get('/gen_xlsx', ...docAccessMiddleware, expressWrap(async (req, res) => {
|
||||
return this._docWorker.getXLSX(req, res);
|
||||
}));
|
||||
|
||||
this.app.get('/attachment', ...docAccessMiddleware,
|
||||
expressWrap(async (req, res) => this._docWorker.getAttachment(req, res)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user