Files
ontime/apps/server/src/api-data/sheets/sheets.router.ts
T
2026-04-06 21:19:23 +02:00

36 lines
1.0 KiB
TypeScript

/**
* This is a feature specific router for integration with google sheets
*/
import express from 'express';
import {
getWorksheetMetadataFromSheet,
getWorksheetNamesFromSheet,
readFromSheet,
requestConnection,
revokeAuthentication,
verifyAuthentication,
writeToSheet,
} from './sheets.controller.js';
import { uploadClientSecret } from './sheets.middleware.js';
import {
validateRequestConnection,
validateSheetId,
validateSheetOptions,
validateWorksheetMetadata,
} from './sheets.validation.js';
export const router = express.Router();
router.get('/connect', verifyAuthentication);
router.post('/:sheetId/connect', uploadClientSecret, validateRequestConnection, requestConnection);
router.post('/revoke', revokeAuthentication);
router.post('/:sheetId/worksheets', validateSheetId, getWorksheetNamesFromSheet);
router.post('/:sheetId/metadata', validateWorksheetMetadata, getWorksheetMetadataFromSheet);
router.post('/:sheetId/read', validateSheetOptions, readFromSheet);
router.post('/:sheetId/write', validateSheetOptions, writeToSheet);