From d91ef06ce7d8bc04cf5e2a5638b360f63bd4dacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Perlusz=20D=C3=A1vid?= Date: Tue, 3 Sep 2024 15:50:49 +0200 Subject: [PATCH] Testing --- components/user/user.controller.js | 12 ++++++------ test-api.http | 8 ++++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/components/user/user.controller.js b/components/user/user.controller.js index 51325b0..7669483 100644 --- a/components/user/user.controller.js +++ b/components/user/user.controller.js @@ -9,14 +9,14 @@ class UserController { const user = await this.userService.addUser(req.body); return res.status(201).send(user); } catch (error) { - if (process.env.NODE_ENV === 'development') { + if (process.env.VERCEL_ENV === 'development') { return res.status(500).json({ error: 'Internal Server Error', 'msg': error.message, 'stack': error.stack }); } else { - return res.status(500).json({ error: 'Internal Server Error' }); + return res.status(500).json({ error: 'Internal Server Error, bla bla bla' }); } } }; @@ -26,7 +26,7 @@ class UserController { const users = await this.userService.getUsers(); return res.status(200).send(users); } catch (error) { - if (process.env.NODE_ENV === 'development') { + if (process.env.VERCEL_ENV === 'development') { return res.status(500).json({ error: 'Internal Server Error', 'msg': error.message, @@ -44,7 +44,7 @@ class UserController { const user = await this.userService.getUser(Number(id)); return res.status(200).send(user); } catch (error) { - if (process.env.NODE_ENV === 'development') { + if (process.env.VERCEL_ENV === 'development') { return res.status(500).json({ error: 'Internal Server Error', 'msg': error.message, @@ -70,7 +70,7 @@ class UserController { const user = await this.userService.getUser(userId); return res.status(200).send(user); } catch (error) { - if (process.env.NODE_ENV === 'development') { + if (process.env.VERCEL_ENV === 'development') { return res.status(500).json({ error: 'Internal Server Error', 'msg': error.message, @@ -91,7 +91,7 @@ class UserController { } return res.status(200).json({ success: true }); } catch (error) { - if (process.env.NODE_ENV === 'development') { + if (process.env.VERCEL_ENV === 'development') { return res.status(500).json({ error: 'Internal Server Error', 'msg': error.message, diff --git a/test-api.http b/test-api.http index 5e5f673..d2f75f6 100644 --- a/test-api.http +++ b/test-api.http @@ -1,5 +1,5 @@ ### Define the base URL -@BASE_URL = https://server-tribal-digital.vercel.app/ +@BASE_URL = https://server-tribal-digital.vercel.app ### POST request to create a new user POST {{BASE_URL}}/users/register @@ -30,4 +30,8 @@ Authorization: Bearer {{auth_token}} ### GET request to get user details GET {{BASE_URL}}/users/1 Content-Type: application/json -Authorization: Bearer {{auth_token}} \ No newline at end of file +Authorization: Bearer {{auth_token}} + +### GET home +GET {{BASE_URL}} +Content-Type: application/json \ No newline at end of file