Initial commit

This commit is contained in:
2023-06-19 00:32:51 +02:00
parent db849fd21f
commit 89612f02b6
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);
};