handle client secret upload

This commit is contained in:
arc-alex
2023-11-18 17:24:29 +01:00
parent 38cf3a7b63
commit 31b46bbb34
4 changed files with 33 additions and 4 deletions
@@ -415,18 +415,19 @@ export async function previewSheet(req, res) {
* @returns parsed result
*/
export async function sheetClientFile(req, res) {
if (!req.file) {
if (!req.file.path) {
res.status(400).send({ message: 'File not found' });
return;
}
try {
const clientSecret = JSON.parse(req.body.options);
await Sheet.saveClientSecrets(clientSecret);
const client = JSON.parse( fs.readFileSync(req.file.path as string, 'utf-8'));
await Sheet.saveClientSecrets(client);
res.status(200).send('OK');
} catch (error) {
res.status(500).send({ message: error.toString() });
}
fs.unlink(req.file.path, (err) => {if(err) (logger.error(LogOrigin.Server, err.message))});
}
/**
+3
View File
@@ -103,3 +103,6 @@ router.post('/osc-subscriptions', validateOscSubscription, postOscSubscriptions)
// create route between controller and '/ontime/new' endpoint
router.post('/new', projectSanitiser, postNew);
// create route between controller and '/ontime/sheet-client' endpoint
router.post('/sheet-clientsecrect', uploadFile, sheetClientFile);