refactor: project data (#523)

This commit is contained in:
Carlos Valente
2023-09-15 17:33:30 +02:00
committed by GitHub
parent 9708f0bfc6
commit a0c5375376
43 changed files with 207 additions and 193 deletions
@@ -1,4 +1,4 @@
import { Alias, EventData, LogOrigin } from 'ontime-types';
import { Alias, LogOrigin, ProjectData } from 'ontime-types';
import { RequestHandler } from 'express';
import fs from 'fs';
@@ -31,7 +31,7 @@ export const poll = async (req, res) => {
// Create controller for GET request to '/ontime/db'
// Returns -
export const dbDownload = async (req, res) => {
const { title } = DataProvider.getEventData();
const { title } = DataProvider.getProjectData();
const fileTitle = title || 'ontime data';
res.download(resolveDbPath, `${fileTitle}.json`, (err) => {
@@ -334,7 +334,7 @@ export const dbUpload = async (req, res) => {
// Create controller for POST request to '/ontime/new'
export const postNew: RequestHandler = async (req, res) => {
try {
const newEventData: EventData = {
const newProjectData: ProjectData = {
title: req.body?.title ?? '',
description: req.body?.description ?? '',
publicUrl: req.body?.publicUrl ?? '',
@@ -342,7 +342,7 @@ export const postNew: RequestHandler = async (req, res) => {
backstageUrl: req.body?.backstageUrl ?? '',
backstageInfo: req.body?.backstageInfo ?? '',
};
const newData = await DataProvider.setEventData(newEventData);
const newData = await DataProvider.setProjectData(newProjectData);
await deleteAllEvents();
res.status(201).send(newData);
} catch (error) {