mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-10 08:39:34 +00:00
fix: db path
This commit is contained in:
+1
-2
@@ -4,7 +4,6 @@ import { config } from './config/config.js';
|
|||||||
// init database
|
// init database
|
||||||
import { Low, JSONFile } from 'lowdb';
|
import { Low, JSONFile } from 'lowdb';
|
||||||
|
|
||||||
import { join } from 'path';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
@@ -12,7 +11,7 @@ const __dirname = path.dirname(__filename);
|
|||||||
|
|
||||||
const env = process.env.NODE_ENV || 'prod';
|
const env = process.env.NODE_ENV || 'prod';
|
||||||
|
|
||||||
const file = join(__dirname, 'data/', config.database.filename);
|
const file = path.join(__dirname, 'data/', config.database.filename);
|
||||||
const adapter = new JSONFile(file);
|
const adapter = new JSONFile(file);
|
||||||
export const db = new Low(adapter);
|
export const db = new Low(adapter);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
// get database
|
// get database
|
||||||
import { db, data } from '../app.js';
|
import { db, data } from '../app.js';
|
||||||
import fs from 'fs';
|
|
||||||
import {
|
import {
|
||||||
event as eventDef,
|
event as eventDef,
|
||||||
delay as delayDef,
|
delay as delayDef,
|
||||||
@@ -8,6 +11,9 @@ import {
|
|||||||
} from '../data/eventsDefinition.js';
|
} from '../data/eventsDefinition.js';
|
||||||
import { dbModel } from '../data/dataModel.js';
|
import { dbModel } from '../data/dataModel.js';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
function getEventTitle() {
|
function getEventTitle() {
|
||||||
return data.event.title;
|
return data.event.title;
|
||||||
}
|
}
|
||||||
@@ -82,7 +88,9 @@ async function parsev1(jsonData) {
|
|||||||
// Returns -
|
// Returns -
|
||||||
export const dbDownload = async (req, res) => {
|
export const dbDownload = async (req, res) => {
|
||||||
const fileTitle = getEventTitle() || 'ontime events';
|
const fileTitle = getEventTitle() || 'ontime events';
|
||||||
res.download('db.json', `${fileTitle}.json`, (err) => {
|
const dbFile = path.resolve(__dirname, '../', 'data/db.json');
|
||||||
|
|
||||||
|
res.download(dbFile, `${fileTitle}.json`, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
res.status(500).send({
|
res.status(500).send({
|
||||||
message: 'Could not download the file. ' + err,
|
message: 'Could not download the file. ' + err,
|
||||||
|
|||||||
Reference in New Issue
Block a user