Zbavení se Food API, zahrnutí do serveru
This commit is contained in:
@@ -6,8 +6,9 @@ import cors from 'cors';
|
||||
import { addPizzaOrder, createPizzaDay, deletePizzaDay, finishPizzaDelivery, finishPizzaOrder, getData, lockPizzaDay, removePizzaOrder, unlockPizzaDay, updateChoice, updateNote } from "./service";
|
||||
import dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
import { fetchMenus } from "./restaurants";
|
||||
import { getMenuSladovnicka, getMenuTechTower, getMenuUMotliku } from "./restaurants";
|
||||
import { getQr } from "./qr";
|
||||
import { Restaurants } from "./types";
|
||||
|
||||
const ENVIRONMENT = process.env.NODE_ENV || 'production'
|
||||
dotenv.config({ path: path.resolve(__dirname, `../.env.${ENVIRONMENT}`) });
|
||||
@@ -34,10 +35,15 @@ app.get("/api/data", (req, res) => {
|
||||
});
|
||||
|
||||
/** Vrátí obědové menu pro dostupné podniky. */
|
||||
app.get("/api/food", (req, res) => {
|
||||
fetchMenus().then(food => {
|
||||
res.status(200).json(food);
|
||||
})
|
||||
app.get("/api/food", async (req, res) => {
|
||||
const mock = !!req.query?.mock;
|
||||
const date = new Date();
|
||||
const data = {
|
||||
[Restaurants.SLADOVNICKA]: await getMenuSladovnicka(date, mock),
|
||||
[Restaurants.UMOTLIKU]: await getMenuUMotliku(date, mock),
|
||||
[Restaurants.TECHTOWER]: await getMenuTechTower(date, mock),
|
||||
}
|
||||
res.status(200).json(data);
|
||||
});
|
||||
|
||||
/** Vrátí seznam dostupných pizz. */
|
||||
|
||||
Reference in New Issue
Block a user