Marcos Henrique da Silva
1 min readNov 18, 2022

Hi Ericventor, thanks for the message!

I think you raised great questions.

Which relates to the authService, you could be having the mutation for /login in an auth resolver instead of using the user resolver but you would still need to use some user business logic there. I personally don't have a strong opinion here, specially because nowadays most probably you would be using an external auth service for that such as Cognito, Auth0, Otka or other auth provider.

Which relates to !user error, I don't see as a huge issue on having the throw BadRequestException there since NestJS framework handles it quite good. But, to be more precise and aligned with your question, I would be inclined to refactor it and use the validation in a Middleware/Interceptor before the service is being called. This way it would be similar to an express application like:

```

app.post('/start-freelancing', oneOf([

check('programming_language').isIn(['javascript', 'java', 'php']),

check('design_tools').isIn(['canva', 'photoshop', 'gimp'])

]), (req, res, next) => {

try {

...

```

What do you think it would fit better for you?

Thanks!

No responses yet

Write a response