Initial commit

This commit is contained in:
2023-06-19 00:32:51 +02:00
parent c226daf9a0
commit be19e63970
281 changed files with 2199 additions and 0 deletions

View File

@ -0,0 +1,13 @@
import { json, type RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../utils/db';
import type {RecipeModelType} from '../../../../types/types';
export const GET: RequestHandler = async ({params}) => {
await dbConnect();
let recipe = (await Recipe.findOne({ short_name: params.name}).lean()) as RecipeModelType[];
await dbDisconnect();
recipe = JSON.parse(JSON.stringify(recipe));
return json(recipe);
};

View File

@ -0,0 +1,13 @@
import { json, type RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../../models/Recipe'
import { dbConnect, dbDisconnect } from '../../../../utils/db';
export const GET: RequestHandler = async ({params}) => {
let current_month = 6;
await dbConnect();
let found_brief = (await Recipe.find({}, 'name short_name images tags category icon description season').lean());
await dbDisconnect();
console.log(found_brief)
let recipes = JSON.parse(JSON.stringify(found_brief));
return json(recipes);
};

View File

@ -0,0 +1,12 @@
import { json, type RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../../models/Recipe'
import { dbConnect, dbDisconnect } from '../../../../utils/db';
export const GET: RequestHandler = async ({params}) => {
let current_month = 6;
await dbConnect();
let found_in_season = (await Recipe.find({season: current_month}, 'name short_name images tags category icon description season').lean());
await dbDisconnect();
found_in_season = JSON.parse(JSON.stringify(found_in_season));
return json(found_in_season);
};

View File

@ -0,0 +1,13 @@
import { json, type RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../../utils/db';
import type {BriefRecipeType} from '../../../../../types/types';
export const GET: RequestHandler = async ({params}) => {
await dbConnect();
let recipes = (await Recipe.find({tags: params.tag}, 'name short_name images tags category icon description season').lean()) as BriefRecipeType[];
await dbDisconnect();
recipes = JSON.parse(JSON.stringify(recipes));
return json(recipes);
};

View File

@ -0,0 +1,147 @@
import { json } from '@sveltejs/kit';
import { Recipe } from '../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../utils/db';
const test_json = [
{ short_name: "rhabarberkonfi",
name: "Rharbarberkonfi",
category: "Aufstrich",
icon: "☀️",
datecreated: 20230610,
datemodified: 20230611,
images:
[ {
mediapath: "rharbarberkonfi.webp",
alt: "Ein Brot mit Marmelade darauf.",
caption: ""
}
],
description: "Saure Marmelade",
tags:["marmelade", "schweiz", "sauer", "rhabarber", "zucker", "aufstrich", "marmelade" , "ein weteres langes tag", "und noch eins", "und ein weiteres", "und nochmal"],
season: [4,5,6],
baking: {
temperature: "160",
length: "4 Stunden",
mode: "Ober-/Unterhitze"
},
preparation: "20 Minuten",
fermentation: {
bulk: "2.5 Stunden",
final: "2 Stunden"
},
portions: "4 Pizzen",
total_time: "1 Tag",
ingredients: [ {
name: "Teig",
list: [
{name: "Mehl",
unit: "g",
amount: 500
} ,
{
name: "Salz",
unit: "g",
amount: 6
}
]},
{
name: "Füllung",
list: [
{
name: "Aprikose",
unit: "Stück",
amount: 10
},
{
name: "Zuckerwürfel",
unit: "Stück",
amount: 10
}
] }
],
instructions: [
{name: "",
steps: [
"Den Rhabarber schälen und in ca. 1 cm große Stücke schneiden",
"Have fun"
]
}
]
},
{ short_name: "osterfladen",
name: "Osterfladen",
category: "Aufstrich",
icon: "🐇",
datecreated: 20230610,
datemodified: 20230611,
images:
[ {
mediapath: "osterfladen.webp",
alt: "Ein Brot mit Marmelade darauf.",
caption: ""
}
],
description: "Saure Marmelade",
tags:["marmelade", "schweiz", "sauer", "rhabarber", "zucker", "aufstrich", "marmelade"],
season: [2,3,4],
baking: {
temperature: "160",
length: "4 Stunden",
mode: "Ober-/Unterhitze"
},
preparation: "20 Minuten",
fermentation: {
bulk: "2.5 Stunden",
final: "2 Stunden"
},
portions: "4 Pizzen",
total_time: "1 Tag",
ingredients: [ {
name: "Teig",
list: [
{name: "Mehl",
unit: "g",
amount: 500
} ,
{
name: "Salz",
unit: "g",
amount: 6
}
]},
{
name: "Füllung",
list: [
{
name: "Aprikose",
unit: "Stück",
amount: 10
},
{
name: "Zuckerwürfel",
unit: "Stück",
amount: 10
}
] }
],
instructions: [
{name: "",
steps: [
"Den Rhabarber schälen und in ca. 1 cm große Stücke schneiden",
"Have fun"
]
}
]
},
];
// seed data
export const GET = async () => {
await dbConnect();
await Recipe.deleteMany();
await Recipe.insertMany(test_json);
await dbDisconnect();
return json({
message: 'seeded',
});
}