From 6fb58e91a3334bb1cd798e2c7d29f0be503aab31 Mon Sep 17 00:00:00 2001 From: uo282936 Date: Tue, 2 May 2023 21:19:10 +0200 Subject: [PATCH 1/2] Intento 3 Eliminar Bugs --- restapi/api.ts | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/restapi/api.ts b/restapi/api.ts index 1a5cfa0..049682a 100644 --- a/restapi/api.ts +++ b/restapi/api.ts @@ -20,25 +20,27 @@ api.get( api.get( "/user/isRegistered", - async (req: Request, res: Response): Promise => { + (req: Request, res: Response): void => { try { const userName = req.query.userName; const userWebId = req.query.userWebId; const provider = req.query.provider; - const user = await User.findOne({ userName: userName?.toString(), userWebId: userWebId?.toString(), provider: provider?.toString() }); - - if (user) { - return res.status(200).send({ isRegistered: true }); - } else { - return res.status(200).send({ isRegistered: false }); - } + User.findOne({ userName: userName?.toString(), userWebId: userWebId?.toString(), provider: provider?.toString() }) + .then((user) => { + if (user) { + res.status(200).send({ isRegistered: true }); + } else { + res.status(200).send({ isRegistered: false }); + } + }) } catch (error) { - return res.status(500).send({ error: 'Error al buscar usuario' }); + res.status(500).send({ error: 'Error al buscar usuario' }); } } ); + api.post( "/user/add", async (req: Request, res: Response): Promise => { @@ -76,26 +78,28 @@ api.get( api.get( "/solicitude/exists", - async (req: Request, res: Response): Promise => { + (req: Request, res: Response): void => { try { const receiverName = req.query.receiverName; const receiverProvider = req.query.receiverProvider; const senderName = req.query.senderName; const senderProvider = req.query.senderProvider; - const solicitude = await Solicitude.findOne({ senderName: senderName?.toString(), senderProvider: senderProvider?.toString(), receiverName: receiverName?.toString(), receiverProvider: receiverProvider?.toString() }); - - if (solicitude) { - return res.status(200).send({ exists: true }); - } else { - return res.status(200).send({ exists: false }); - } + Solicitude.findOne({ senderName: senderName?.toString(), senderProvider: senderProvider?.toString(), receiverName: receiverName?.toString(), receiverProvider: receiverProvider?.toString() }) + .then((solicitude) => { + if (solicitude) { + res.status(200).send({ exists: true }); + } else { + res.status(200).send({ exists: false }); + } + }) } catch (error) { - return res.status(500).send({ error: 'Error al buscar solicitud' }); + res.status(500).send({ error: 'Error al buscar solicitud' }); } } ); + api.post( "/solicitude/add", async (req: Request, res: Response): Promise => { From d6b192075c9f75152659a3d9ea00a3783fb46c10 Mon Sep 17 00:00:00 2001 From: uo282936 Date: Tue, 2 May 2023 21:25:46 +0200 Subject: [PATCH 2/2] Revert "Intento 3 Eliminar Bugs" This reverts commit 6fb58e91a3334bb1cd798e2c7d29f0be503aab31. --- restapi/api.ts | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/restapi/api.ts b/restapi/api.ts index 049682a..1a5cfa0 100644 --- a/restapi/api.ts +++ b/restapi/api.ts @@ -20,27 +20,25 @@ api.get( api.get( "/user/isRegistered", - (req: Request, res: Response): void => { + async (req: Request, res: Response): Promise => { try { const userName = req.query.userName; const userWebId = req.query.userWebId; const provider = req.query.provider; - User.findOne({ userName: userName?.toString(), userWebId: userWebId?.toString(), provider: provider?.toString() }) - .then((user) => { - if (user) { - res.status(200).send({ isRegistered: true }); - } else { - res.status(200).send({ isRegistered: false }); - } - }) + const user = await User.findOne({ userName: userName?.toString(), userWebId: userWebId?.toString(), provider: provider?.toString() }); + + if (user) { + return res.status(200).send({ isRegistered: true }); + } else { + return res.status(200).send({ isRegistered: false }); + } } catch (error) { - res.status(500).send({ error: 'Error al buscar usuario' }); + return res.status(500).send({ error: 'Error al buscar usuario' }); } } ); - api.post( "/user/add", async (req: Request, res: Response): Promise => { @@ -78,28 +76,26 @@ api.get( api.get( "/solicitude/exists", - (req: Request, res: Response): void => { + async (req: Request, res: Response): Promise => { try { const receiverName = req.query.receiverName; const receiverProvider = req.query.receiverProvider; const senderName = req.query.senderName; const senderProvider = req.query.senderProvider; - Solicitude.findOne({ senderName: senderName?.toString(), senderProvider: senderProvider?.toString(), receiverName: receiverName?.toString(), receiverProvider: receiverProvider?.toString() }) - .then((solicitude) => { - if (solicitude) { - res.status(200).send({ exists: true }); - } else { - res.status(200).send({ exists: false }); - } - }) + const solicitude = await Solicitude.findOne({ senderName: senderName?.toString(), senderProvider: senderProvider?.toString(), receiverName: receiverName?.toString(), receiverProvider: receiverProvider?.toString() }); + + if (solicitude) { + return res.status(200).send({ exists: true }); + } else { + return res.status(200).send({ exists: false }); + } } catch (error) { - res.status(500).send({ error: 'Error al buscar solicitud' }); + return res.status(500).send({ error: 'Error al buscar solicitud' }); } } ); - api.post( "/solicitude/add", async (req: Request, res: Response): Promise => {