import { z } from 'zod' const bodySchema = z.object({ email: z.string().email(), password: z.string(), }) function check_login(user: string,pwd: string): number { /*const r = $fetch("http://localhost:5000/login", { method: "POST", body: JSON.stringify({user: user, pwd: pwd}), })*/ if (user === "tomas@suricatingss.xyz" && pwd === "tomas190905") return 0; // 0 = no errror = success else return 1; } export default defineEventHandler(async (event) => { const { email, password } = await readValidatedBody(event, bodySchema.parse) const response = (check_login(email, password)); switch (response) { case 0: // set the user session in the cookie // this server util is auto-imported by the auth-utils module await setUserSession(event, { user: { name: 'John Doe', }, }) return ""; case 1: setResponseStatus(event, 403); return "Incorrect login"; } })