Does not work: uploading images

Adding/Editing/Deleting works
SeasonsSelect works
Nice recipe layout
This commit is contained in:
2023-06-24 15:31:10 +02:00
parent 3d0d3f41e2
commit 9392ff6ada
25 changed files with 1150 additions and 209 deletions

View File

@ -0,0 +1,23 @@
import type { RequestHandler } from '@sveltejs/kit';
import { Recipe } from '../../../models/Recipe';
import { dbConnect, dbDisconnect } from '../../../utils/db';
import type {RecipeModelType} from '../../../types/types';
import { BEARER_TOKEN } from '$env/static/private'
// header: use for bearer token for now
// recipe json in body
export const POST: RequestHandler = async ({request}) => {
let message = await request.json()
const short_name = message.old_short_name
const bearer_token = message.headers.bearer
if(bearer_token === BEARER_TOKEN){
console.log("PASSWORD CORRECT")
await dbConnect();
await Recipe.findOneAndDelete({short_name: short_name});
await dbDisconnect();
return {status: 400} //TODO: cleanup error throwing
}
else{
console.log("PASSWORD INCORRECT")
return {status: 403}
}
};