mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-07 16:33:51 +00:00
17 lines
453 B
JavaScript
17 lines
453 B
JavaScript
// Create controller for GET request to '/ontime/download'
|
|
import { db, data } from '../app.js';
|
|
function getEventTitle() {
|
|
return data.event.title;
|
|
}
|
|
// Returns -
|
|
export const dbDownload = async (req, res) => {
|
|
const fileTitle = getEventTitle() || 'ontime events';
|
|
res.download('db.json', `${fileTitle}.json`, (err) => {
|
|
if (err) {
|
|
res.status(500).send({
|
|
message: 'Could not download the file. ' + err,
|
|
});
|
|
}
|
|
});
|
|
};
|