implement basic login

This commit is contained in:
Anika Raemer 2025-10-07 19:27:35 +02:00
parent bdd90b50d9
commit 7a6f5b5bcd
18 changed files with 222 additions and 35 deletions

View file

@ -0,0 +1,27 @@
import type { Recipe } from "../../types/recipe"
import type { LoginRequestDto } from "../dtos/LoginRequestDto";
import type { LoginResponseDto } from "../dtos/LoginResponseDto";
import { get, postJson, putJson } from "../utils/requests";
/**
* Util for handling the recipe api
*/
// read base url from .env file
const BASE_URL = import.meta.env.VITE_API_BASE;
/**
* URL for handling recipes
*/
const AUTH_URL = `${BASE_URL}/auth`
/**
* Create new Recipe
* @param recipe Recipe to create
* @returns Saved recipe
*/
export async function login(requestDto: LoginRequestDto): Promise<LoginResponseDto> {
const res = await postJson(`${AUTH_URL}/login`, JSON.stringify(requestDto), false);
return res.json();
}