Compare commits

...

3 Commits

Author SHA1 Message Date
516ce43025
remove old api routes; 2023-07-22 13:09:28 +02:00
04827b1a39
move API routes as cleanup 2023-07-22 13:09:06 +02:00
9c1002bc5e
section scales, not anchor 2023-07-22 12:58:29 +02:00
41 changed files with 130 additions and 680 deletions

View File

@ -55,15 +55,12 @@ a{
color: var(--nord0);
transition: 200ms;
}
a:hover{
section:hover{
scale: 1.02;
}
section:has(a:hover){
box-shadow: 1em 1em 1em 1em rgba(0,0,0, 0.3);
}
section:has(a:hover) + section{
box-shadow: 1em 1em 1em 1em rgba(0,0,0, 0.3);
}
</style>
<section>

View File

@ -1,10 +1 @@
<script lang="ts">
import Header from "$lib/components/Header.svelte";
</script>
<Header>
<ul class=site_header slot=links>
<li><a href="/">Home</a></li>
</ul>
</Header>
<h1>WIP</h1>

View File

@ -11,7 +11,7 @@ export const load: PageServerLoad = async ({ locals }) => {
export const actions: Actions = {
login: async (event) => {
const data = await event.request.formData()
const res = await event.fetch('/api/login',
const res = await event.fetch('/api/user/login',
{method: 'POST',
body: JSON.stringify({
username: data.get('username'),

View File

@ -10,7 +10,7 @@ export const load: PageServerLoad = async ({ locals }) => {
export const actions: Actions = {
register: async (event) => {
const data = await event.request.formData();
const res = await event.fetch('/api/register',
const res = await event.fetch('/api/user/register',
{method: 'POST',
body: JSON.stringify({

View File

@ -15,7 +15,7 @@ export const actions: Actions = {
},
login: async (event) => {
const data = await event.request.formData()
const res = await event.fetch('/api/login',
const res = await event.fetch('/api/user/login',
{method: 'POST',
body: JSON.stringify({
username: data.get('username'),

View File

@ -2,8 +2,8 @@ import type { PageServerLoad } from "./$types";
export async function load({ fetch }) {
let current_month = new Date().getMonth() + 1
const res_season = await fetch(`/api/items/in_season/` + current_month);
const res_all_brief = await fetch(`/api/items/all_brief`);
const res_season = await fetch(`/api/rezepte/items/in_season/` + current_month);
const res_all_brief = await fetch(`/api/rezepte/items/all_brief`);
const item_season = await res_season.json();
const item_all_brief = await res_all_brief.json();
return {

View File

@ -1,7 +1,7 @@
import { error } from "@sveltejs/kit";
export async function load({ fetch, params}) {
const res = await fetch(`/api/items/${params.name}`);
const res = await fetch(`/api/rezepte/items/${params.name}`);
let item = await res.json();
if(!res.ok){
throw error(res.status, item.message)

View File

@ -86,7 +86,7 @@
image: img_local,
name: short_name,
}
await fetch(`/api/img/add`, {
await fetch(`/api/rezepte/img/add`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@ -101,7 +101,7 @@
upload_img()
console.log(add_info.total_time)
const res = await fetch('/api/add', {
const res = await fetch('/api/rezepte/add', {
method: 'POST',
body: JSON.stringify({
recipe: {

View File

@ -1,7 +1,7 @@
import type { PageLoad } from "./$types";
export async function load({ fetch}) {
const res = await fetch(`/api/items/category`);
const res = await fetch(`/api/rezepte/items/category`);
const categories= await res.json();
return {categories}
};

View File

@ -1,7 +1,7 @@
import type { PageLoad } from "./$types";
export async function load({ fetch, params }) {
const res = await fetch(`/api/items/category/${params.category}`);
const res = await fetch(`/api/rezepte/items/category/${params.category}`);
const items = await res.json();
return {
category: params.category,

View File

@ -2,7 +2,7 @@ import type { PageLoad } from "./$types";
export async function load({ fetch, params, locals}) {
let current_month = new Date().getMonth() + 1
const res = await fetch(`/api/items/${params.name}`);
const res = await fetch(`/api/rezepte/items/${params.name}`);
const recipe = await res.json();
return {recipe: recipe,
user: locals.user

View File

@ -96,7 +96,7 @@
if(!response){
return
}
const res_img = await fetch('/api/img/delete', {
const res_img = await fetch('/api/rezepte/img/delete', {
method: 'POST',
body: JSON.stringify({
name: old_short_name,
@ -112,7 +112,7 @@
return
}
return
const res = await fetch('/api/delete', {
const res = await fetch('/api/rezepte/delete', {
method: 'POST',
body: JSON.stringify({
old_short_name,
@ -141,7 +141,7 @@
console.log("img_local", img_local)
if(img_local != ""){
async function delete_img(){
const res = await fetch('/api/img/delete', {
const res = await fetch('/api/rezepte/img/delete', {
method: 'POST',
body: JSON.stringify({
name: old_short_name,
@ -161,7 +161,7 @@
image: img_local,
name: short_name,
}
const res = await fetch(`/api/img/add`, {
const res = await fetch(`/api/rezepte/img/add`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@ -181,7 +181,7 @@
// case new short_name:
else if(short_name != old_short_name){
console.log("MOVING")
const res_img = await fetch('/api/img/mv', {
const res_img = await fetch('/api/rezepte/img/mv', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@ -199,7 +199,7 @@
return
}
}
const res = await fetch('/api/edit', {
const res = await fetch('/api/rezepte/edit', {
method: 'POST',
body: JSON.stringify({
recipe: {

View File

@ -2,7 +2,7 @@ import type { PageLoad } from "./$types";
export async function load({ fetch }) {
let current_month = new Date().getMonth() + 1
const res_icons = await fetch(`/api/items/icon`);
const res_icons = await fetch(`/api/rezepte/items/icon`);
const item = await res_icons.json();
return {
icons: item,

View File

@ -1,8 +1,8 @@
import type { PageLoad } from "./$types";
export async function load({ fetch, params }) {
const res_season = await fetch(`/api/items/icon/` + params.icon);
const res_icons = await fetch(`/api/items/icon`);
const res_season = await fetch(`/api/rezepte/items/icon/` + params.icon);
const res_icons = await fetch(`/api/rezepte/items/icon`);
const icons = await res_icons.json();
const item_season = await res_season.json();
return {

View File

@ -2,7 +2,7 @@ import type { PageLoad } from "./$types";
export async function load({ fetch }) {
let current_month = new Date().getMonth() + 1
const res_season = await fetch(`/api/items/in_season/` + current_month);
const res_season = await fetch(`/api/rezepte/items/in_season/` + current_month);
const item_season = await res_season.json();
return {
season: item_season,

View File

@ -1,8 +1,8 @@
import type { PageLoad } from "./$types";
export async function load({ fetch, params }) {
const res_season = await fetch(`/api/items/in_season/` + params.month);
const res_all_brief = await fetch(`/api/items/all_brief`);
const res_season = await fetch(`/api/rezepte/items/in_season/` + params.month);
const res_all_brief = await fetch(`/api/rezepte/items/all_brief`);
const item_season = await res_season.json();
const item_all_brief = await res_all_brief.json();
return {

View File

@ -1,7 +1,7 @@
import type { PageLoad } from "./$types";
export async function load({ fetch}) {
const res = await fetch(`/api/items/tag`);
const res = await fetch(`/api/rezepte/items/tag`);
const tags = await res.json();
return {tags}
};

View File

@ -1,7 +1,7 @@
import type { PageLoad } from "./$types";
export async function load({ fetch, params }) {
const res_tag = await fetch(`/api/items/tag/${params.tag}`);
const res_tag = await fetch(`/api/rezepte/items/tag/${params.tag}`);
const items_tag = await res_tag.json();
return {
tag: params.tag,

View File

@ -1,6 +1,6 @@
import type { RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../utils/db';
import { Recipe } from '../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../utils/db';
import { error } from '@sveltejs/kit';
import { authenticateUser } from '$lib/js/authenticate';;
// header: use for bearer token for now

View File

@ -1,7 +1,7 @@
import type { RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../utils/db';
import type {RecipeModelType} from '../../../types/types';
import { Recipe } from '../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../utils/db';
import type {RecipeModelType} from '../../../../types/types';
import { error } from '@sveltejs/kit';
import { authenticateUser } from '$lib/js/authenticate';
// header: use for bearer token for now

View File

@ -1,7 +1,7 @@
import type { RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../utils/db';
import type {RecipeModelType} from '../../../types/types';
import { Recipe } from '../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../utils/db';
import type {RecipeModelType} from '../../../../types/types';
import { error } from '@sveltejs/kit';
import { authenticateUser } from '$lib/js/authenticate';
// header: use for bearer token for now

View File

@ -1,7 +1,7 @@
import { json, type RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../utils/db';
import type {RecipeModelType} from '../../../../types/types';
import { Recipe } from '../../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../../utils/db';
import type {RecipeModelType} from '../../../../../types/types';
import { error } from '@sveltejs/kit';
export const GET: RequestHandler = async ({params}) => {

View File

@ -1,7 +1,7 @@
import { json, type RequestHandler } from '@sveltejs/kit';
import type { BriefRecipeType } from '../../../../types/types';
import { Recipe } from '../../../../models/Recipe'
import { dbConnect, dbDisconnect } from '../../../../utils/db';
import type { BriefRecipeType } from '../../../../../types/types';
import { Recipe } from '../../../../../models/Recipe'
import { dbConnect, dbDisconnect } from '../../../../../utils/db';
import { rand_array } from '$lib/js/randomize';
export const GET: RequestHandler = async ({params}) => {

View File

@ -1,7 +1,7 @@
import { json, type RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../utils/db';
import type {BriefRecipeType} from '../../../../types/types';
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();

View File

@ -1,7 +1,7 @@
import { json, type RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../../utils/db';
import type {BriefRecipeType} from '../../../../../types/types';
import { Recipe } from '../../../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../../../utils/db';
import type {BriefRecipeType} from '../../../../../../types/types';
import { rand_array } from '$lib/js/randomize';
export const GET: RequestHandler = async ({params}) => {

View File

@ -1,7 +1,7 @@
import { json, type RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../utils/db';
import type {BriefRecipeType} from '../../../../types/types';
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();

View File

@ -1,7 +1,7 @@
import { json, type RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../../utils/db';
import type {BriefRecipeType} from '../../../../../types/types';
import { Recipe } from '../../../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../../../utils/db';
import type {BriefRecipeType} from '../../../../../../types/types';
import { rand_array } from '$lib/js/randomize';
export const GET: RequestHandler = async ({params}) => {

View File

@ -1,7 +1,7 @@
import type {rand_array} from '$lib/js/randomize';
import { json, type RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../../../models/Recipe'
import { dbConnect, dbDisconnect } from '../../../../../utils/db';
import { Recipe } from '../../../../../../models/Recipe'
import { dbConnect, dbDisconnect } from '../../../../../../utils/db';
import { rand_array } from '$lib/js/randomize';
export const GET: RequestHandler = async ({params}) => {

View File

@ -1,7 +1,7 @@
import { json, type RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../utils/db';
import type {BriefRecipeType} from '../../../../types/types';
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();

View File

@ -1,7 +1,7 @@
import { json, type RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../../utils/db';
import type {BriefRecipeType} from '../../../../../types/types';
import { Recipe } from '../../../../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../../../../utils/db';
import type {BriefRecipeType} from '../../../../../../types/types';
import { rand_array } from '$lib/js/randomize';
export const GET: RequestHandler = async ({params}) => {

View File

@ -1,411 +0,0 @@
import { json } from '@sveltejs/kit';
import { Recipe } from '../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../utils/db';
const test_json = [
{
short_name: "aelplermagronen",
name : "Älplermagronen",
category: "Hauptspeise",
icon: "🍂",
datecreated: 20230619,
datemodified: 20230619,
images: [{
mediapath: "aelplermagronen.webp",
alt: "Älplermagronen serviert mit Apfelmuß",
caption: "",
}],
description: "Alles was das Bauernherz erfreuen lässt in einer Mahlzeit.",
preamble: "Dieser Schweizer Klassiker ist wohl das beste Essen nach einem langen Tag von Skifahren. Die Beilage aus Apfelmus ist ein Muss.",
tags: ["Schweiz", "Käse", "Speck", "Nudeln", "Apfelmuß", "Kartoffeln", "Fleisch"],
season: [10,11,12,1],
portions: "4 Hauptspeisen",
preparation: "10 min",
total_time: "30 min",
ingredients: [ {
name: "",
list: [
{ name: "Speckwürfel",
unit: "g",
amount: "150"
},
{
name: "mittelgroße Zwiebeln",
unit: "",
amount: "3",
},
{
name: "Kartoffeln, festkochend",
unit: "g",
amount: "400",
},
{
name: "Milch",
unit: "L",
amount: "1-2",
},
{
name: "Maccaroni",
unit: "g",
amount: "400",
},
{
name: "Appenzeller",
unit: "g",
amount: "150",
},
{
name: "<a href=apfelmuss>Apfelmuß</a>",
unit: "",
amount: "",
},
]},
],
instructions: [
{name: "",
steps: [
"In einem großen Topf oder tiefer Pfanne Speckwürfel anbraten.",
"Zwiebel in Halbringe schneiden und im gleichen Topf schwitzen lassen.",
"Kartoffeln schälen und in ~1 cm<sup>3</sup> schneiden.",
"Wenn Ziwebeln genügend gekocht sind die Kartoffeln hinzufügen und Milch hinzufügen, sodass alles bedeckt ist. Ca. 10 Minuten kochen lassen.",
"Ca. 1 L Milch hinzugeben. Für den nächsten Schritt wollen wir die Maccaroni hinzufügen. Damit diese nicht zu breiig werden geben wir erst die Milch zu und lassen sie aufkochen.",
"Wenn die der Topf wieder kocht jetzt die Maccaroni hinzugeben.",
"Den Käse zerreiben oder in kleine Würfel schneiden.",
"Ein bis zwei Minuten bevor die Nudeln durchgekocht sind den Käse hinzugeben und schmelzen lassen.",
"Mit Salz und Muskat würzen.",
"Den Topf ein bisschen zu früh vom Herd nehmen und ein bisschen auskühlen lassen.",
"Mit <a href=apfelkompott>Apfelmuß oder Apfelkompott</a> servieren."
]
}
],
addendum: "<p>Man kann das Gericht noch dekanter machen indem man zu Teilen Rahm an Stelle von Milch verwendet. Zudem kann man das ganze auch noch in eine Auflaufform geben und im Ofen eine Kruste anbacken</p>",
},
{
short_name: "baerlauchravioli",
name : "Bärlauchravioli",
category: "Pasta",
icon: "🌷",
datecreated: 20230619,
datemodified: 20230619,
images: [{
mediapath: "baerlauchravioli.webp",
alt: "3 Ravioli mit durchscheinender grüner Bärlauchfüllung auf einem Teller.",
caption: "",
}],
description: "Unwiderstehliche Ravioli mit Bärlauchfüllung.",
tags: ["Bärlauch", "Wald", "Frühling", "Ravioli", "Italien", "Käse"],
season: [ 2,3,4],
baking: {
temperature: "220",
length: "40 Minuten",
mode: "Ober-/Unterhitze",
},
preparation: "20 Minuten",
fermentation: {
bulk: "2.5 Stunden",
final: "2 Stunden"
},
portions: "4 Pizzen",
total_time: "1 Tag",
ingredients: [],
instructions: []
},
{
short_name: "anisbroetli",
name : "Anisbrötli",
category: "Guetzli",
icon: "🎄",
datecreated: 20230619,
datemodified: 20230619,
images: [{
mediapath: "anisbrot.webp",
alt: "Ein ganzes Brot",
caption: "",
}],
description: "Allemannische Weihnachstkekese bekannt durch seine harte Kruste und weiches Inneres.",
tags: ["Backen", "Advent", "schweiz", "Deutschland", "Anis", "Weihnachten", "Kekse"],
season: [ 12,1],
baking: {
temperature: "220",
length: "40 Minuten",
mode: "Ober-/Unterhitze",
},
preparation: "20 Minuten",
fermentation: {
bulk: "2.5 Stunden",
final: "2 Stunden"
},
portions: "4 Pizzen",
total_time: "1 Tag",
ingredients: [],
instructions: []
},
{
short_name: "alragu",
name : "Pasta al Ragù",
category: "Pasta",
icon: "☀️",
datecreated: 20230619,
datemodified: 20230619,
images: [{
mediapath: "al_ragu.webp",
alt: "Ein ganzes Brot",
caption: "",
}],
description: "Eine etwas gehobene Version der klassichen Bolognese.",
tags: ["Pasta", "Fleisch", "Rind", "Italien", "Bolognese", "Linguine"],
season: [ 6,7,8,9],
baking: {
temperature: "220",
length: "40 Minuten",
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: "sauerteigbrot",
name : "Simples Sauerteigbrot",
category: "Brot",
icon: "🍂",
datecreated: 20230619,
datemodified: 20230619,
images: [{
mediapath: "sauerteigbrot.webp",
alt: "Ein ganzes Brot",
caption: "",
}],
description: "Einfach und sehr lecker",
tags: ["Brot", "Backen", "Sauerteig"],
season: [],
baking: {
temperature: "220",
length: "40 Minuten",
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: "rhabarberkonfi",
name: "Rhabarberkonfi",
category: "Aufstrich",
icon: "☀️",
datecreated: 20230610,
datemodified: 20230611,
images:
[ {
mediapath: "rhabarberkonfi.webp",
alt: "Ein Brot mit Marmelade darauf.",
caption: ""
}
],
description: "Die erste Marmelade des Jahres mit säuerlicher Note.",
tags:["Marmelade", "sauer", "Sommer", "süß"],
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: "osterkuchen",
name: "Osterkuchen",
category: "Kuchen",
icon: "🐇",
datecreated: 20230610,
datemodified: 20230611,
images:
[ {
mediapath: "osterkuchen.webp",
alt: "Ein Brot mit Marmelade darauf.",
caption: ""
}
],
description: "Ein traditioneller Milchreiskuchen mit Aprikosenmarmelade und Rosinen.",
tags:["Schweiz", "Ostern", "Milchreis", "Aprikosen", 'Backen', 'süß', "Marmelade"],
season: [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',
});
}

View File

@ -1,77 +0,0 @@
const obj =
{
short_name: "aelplermagronen",
name : "Älplermagronen",
category: "Hauptspeise",
icon: "🍂",
datecreated: 20230619,
datemodified: 20230619,
images: [{
mediapath: "aelplermagronen.webp",
alt: "Älplermagronen serviert mit Apfelmuß",
caption: "",
}],
description: "Alles was das Bauernherz erfreuen lässt in einer Mahlzeit.",
tags: ["Schweiz", "Käse", "Speck", "Nudeln", "Apfelmuß", "Kartoffeln"],
season: [6,7,8,9,10,11,12,1],
portions: "4 Hauptspeisen",
total_time: "30 Minuten",
ingredients: [ {
name: "",
list: [
{ name: "Speckwürfel",
unit: "g",
amount: "150"
},
{
name: "mittelgroße Zwiebeln",
unit: "",
amount: "3",
},
{
name: "Kartoffeln, festkochend",
unit: "g",
amount: "400",
},
{
name: "Milch",
unit: "L",
amount: "1-2",
},
{
name: "Maccaroni",
unit: "g",
amount: "400",
},
{
name: "Appenzeller",
unit: "g",
amount: "150",
},
{
name: "<a href=apfelmuss>Apfelmuß</a>",
unit: "",
amount: "",
},
]},
],
instructions: [
{name: "",
steps: [
"In einem großen Topf oder tiefer Pfanne Speckwürfel anbraten.",
"Zwiebel in Halbringe schneiden und im gleichen Topf schwitzen lassen.",
"Kartoffeln schälen und in ~1 cm<sup>3</sup> schneiden.",
"Wenn Ziwebeln genügend gekocht sind die Kartoffeln hinzufügen und Milch hinzufügen, sodass alles bedeckt ist. Ca. 10 Minuten kochen lassen.",
"Ca. 1 L Milch hinzugeben. Für den nächsten Schritt wollen wir die Maccaroni hinzufügen. Damit diese nicht zu breiig werden geben wir erst die Milch zu und lassen sie aufkochen.",
"Wenn die der Topf wieder kocht jetzt die Maccaroni hinzugeben.",
"Den Käse zerreiben oder in kleine Würfel schneiden.",
"Ein bis zwei Minuten bevor die Nudeln durchgekocht sind den Käse hinzugeben und schmelzen lassen.",
"Mit Salz und Muskat würzen.",
"Den Topf ein bisschen zu früh vom Herd nehmen und ein bisschen auskühlen lassen.",
"Mit <a href=apfelkompott>Apfelmuß oder Apfelkompott</a> servieren."
]
}
],
addendum: "<p>Man kann das Gericht noch dekanter machen indem man zu Teilen Rahm an Stelle von Milch verwendet. Zudem kann man das ganze auch noch in eine Auflaufform geben und im Ofen eine Kruste anbacken</p>",
}

View File

@ -1,50 +0,0 @@
const obj =
{
short_name: "<++>",
name : "<++>",
category: "<++>",
icon: "<++>",
datecreated: 20230619,
datemodified: 20230619,
images: [{
mediapath: "<++>.webp",
alt: "<++>",
caption: "<++>",
}],
description: "<++>",
tags: [<++>],
season: [<++>],
baking: {
temperature: "<++>",
length: "<++>",
mode: "<++>",
},
preparation: "<++>",
fermentation: {
bulk: "<++>",
final: "<++>"
},
portions: "<++>",
total_time: "<++>",
ingredients: [ {
name: "<++>",
list: [
{ name: "<++>",
unit: "<++>",
amount: <++>,
},
{
name: "<++>",
unit: "<++>",
amount: <++>,
},
]},
],
instructions: [
{name: "<++>",
steps: [
"<++>",
"<++>"
]
}
]}

View File

@ -0,0 +1,23 @@
import type { RequestHandler } from '@sveltejs/kit';
import { error } from '@sveltejs/kit';
import { dbConnect, dbDisconnect } from '../../../../../utils/db';
import { User } from '../../../../../models/User';
import { get_username } from '$lib/js/get_username';
// header: use for bearer token for now
// recipe json in body
export const POST: RequestHandler = async ({cookies}) => {
const requesting_user = await get_username(cookies)
await dbConnect()
let res = await User.findOne({username: requesting_user}, 'access').lean()
if(!res.access.contains("admin")){
await dbDisconnect()
throw error(401, {message: "Your user does not have the permissions to do this"})
}
else{
let res = await User.find({}, 'username access').lean()
await dbDisconnect()
return { res }
}
};

View File

@ -0,0 +1,40 @@
import type { RequestHandler } from '@sveltejs/kit';
import { error } from '@sveltejs/kit';
import { hash } from 'argon2';
import { PEPPER } from '$env/static/private';
import { User } from '../../../../models/User';
import { dbConnect, dbDisconnect } from '../../../../utils/db';
// header: use for bearer token for now
// recipe json in body
export const POST: RequestHandler = async ({request}) => {
const {username, old_password, new_password} = await request.json()
await dbConnect();
const salt = await User.findOne({username: username}, 'salt');
const pass_hash = await hashPassword(old_password + PEPPER, salt)
try{
await User.updateOne({
username: username,
pass_hash: pass_hash,
})
}catch(e){
await dbDisconnect();
throw error(400, e);
}
await dbDisconnect();
return new Response(JSON.stringify({message: "User added successfully"}),
{status: 200}
);
}
};
async function hashPassword(password, salt) {
try {
const hashedPassword = await hash(password, salt); // Hash the password with the salt and pepper
return hashedPassword;
} catch (error) {
console.error('Error hashing password:', error);
}
}

View File

@ -6,8 +6,8 @@ import { verify} from 'argon2';
import { COOKIE_SECRET } from '$env/static/private'
import { PEPPER } from '$env/static/private'
import { dbConnect, dbDisconnect } from '../../../utils/db';
import { User } from '../../../models/User';
import { dbConnect, dbDisconnect } from '../../../../utils/db';
import { User } from '../../../../models/User';
// header: use for bearer token for now
// recipe json in body

View File

@ -5,14 +5,14 @@ import { randomBytes } from 'crypto';
import { ALLOW_REGISTRATION } from '$env/static/private';
import { PEPPER } from '$env/static/private';
import { User } from '../../../models/User';
import { dbConnect, dbDisconnect } from '../../../utils/db';
import { User } from '../../../../models/User';
import { dbConnect, dbDisconnect } from '../../../../utils/db';
// header: use for bearer token for now
// recipe json in body
export const POST: RequestHandler = async ({request}) => {
if(ALLOW_REGISTRATION){
const {username, password, access} = await request.json()
const {username, password} = await request.json()
const salt = randomBytes(32).toString('hex'); // Generate a random salt
const pass_hash = await hashPassword(password + PEPPER, salt)
@ -22,7 +22,7 @@ export const POST: RequestHandler = async ({request}) => {
username: username,
pass_hash: pass_hash,
salt: salt,
access: access,
access: [],
})
}catch(e){
await dbDisconnect();

View File

@ -1,63 +0,0 @@
import type { RequestHandler } from '@sveltejs/kit';
import { error } from '@sveltejs/kit';
import pkg from 'jsonwebtoken';
const { verify } = pkg;
import { hash} from 'argon2';
import { randomBytes } from 'crypto';
import { COOKIE_SECRET } from '$env/static/private'
import { ALLOW_REGISTRATION } from '$env/static/private'
import { User } from '../../../models/User';
import { dbConnect, dbDisconnect } from '../../../utils/db';
import { getJWTFromRequest } from '../../../utils/cookie';
// header: use for bearer token for now
// recipe json in body
export const GET: RequestHandler = async ({request}) => {
const jwt = getJWTFromRequest(request)
// Set your master secret key (replace with your own secret)
const masterSecret = COOKIE_SECRET;
const secretKey = masterSecret
let decoded
try{
decoded = await verify(jwt, secretKey);
}
catch(e){
throw error(401, "Cookies have changed, please log in again")
}
await dbConnect()
let res = await User.findOne({username: decoded.username}, 'access').lean();
await dbDisconnect()
if(!res){
throw error(404, "User for this Cookie does no longer exist")
}
return new Response(JSON.stringify({
username: decoded.username,
access: res.access
}), {status: 200})
};
async function hashPassword(password, salt) {
try {
const hashedPassword = await hash(password, salt); // Hash the password with the salt
return hashedPassword;
} catch (error) {
console.error('Error hashing password:', error);
}
}
async function createJWT(username, userSalt) {
const payload = {
username: username,
};
const masterSecret = COOKIE_SECRET;
const secretKey = masterSecret + userSalt;
const jwt = sign(payload, secretKey);
return jwt
}