feat: allow download of current project

This commit is contained in:
Carlos Valente
2024-10-03 22:26:59 +02:00
committed by Carlos Valente
parent cfb76153a0
commit f1cac8d1c4
3 changed files with 22 additions and 0 deletions
@@ -58,6 +58,19 @@ export async function createProjectFile(req: Request, res: Response<{ filename:
}
}
/**
* Allows downloading of current project file
*/
export async function currentProjectDownload(_req: Request, res: Response) {
const { filename, pathToFile } = await projectService.getCurrentProject();
res.download(pathToFile, filename, (error) => {
if (error) {
const message = getErrorMessage(error);
res.status(500).send({ message });
}
});
}
/**
* Allows downloading of project files
*/
+2
View File
@@ -2,6 +2,7 @@ import express from 'express';
import {
createProjectFile,
currentProjectDownload,
deleteProjectFile,
duplicateProjectFile,
getInfo,
@@ -23,6 +24,7 @@ import {
export const router = express.Router();
router.get('/', currentProjectDownload);
router.post('/download', validateFilenameBody, projectDownload);
router.post('/upload', uploadProjectFile, postProjectFile);