For reasons, during testing, reflect-metadata might not be imported.
This causes the `@Type` annotation to crash the test with a TypeError.
Signed-off-by: David Mehren <git@herrmehren.de>
MariaDB does not support `connect-typeorm`s subqueries,
so they need to be disabled if this dialect is used.
Signed-off-by: David Mehren <git@herrmehren.de>
Previously, the `logout` method immediately returned and did not wait
for the possible error callback.
This wraps the call to `session.destroy` into a promise,
so the error can be properly handled.
Signed-off-by: David Mehren <git@herrmehren.de>
The `validUntil` parameter for `createTokenForUser` may be undefined
in some usages.
As it is easy to add handling for that here, this commit implements it.
Signed-off-by: David Mehren <git@herrmehren.de>
This allows us to handle the possible errors due to non-integer numbers with joi and return more precise error messages.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
validate HD_DOMAIN and HD_RENDERER_ORIGIN with the uri validator of Joi. This should prevent the problem described in #2150.
Fixes#2150
See also: https://joi.dev/api/#stringurioptions
Signed-off-by: Philip Molares <philip.molares@udo.edu>
The email address should only be available
in /me routes.
This commit splits the email address into a new FullUserInfoDto.
Signed-off-by: David Mehren <git@herrmehren.de>
This now correctly returns the dto if it is provided. Previously it would return () => undefined, when the dto was not defined, which crashed some internal logic in nestjs.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This decorator gets a list of http codes and possible descriptions and adds all necessary decorator internally to the method or the class. This will prevent long OpenApi annotations and keep the controllers shorter.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
The constructor of an exception filter must be given
an instance of HttpAdapterHost, otherwise it will crash at runtime.
This can be reproduced by GETing /.
Reference: https://docs.nestjs.com/exception-filters#inheritance
Signed-off-by: David Mehren <git@herrmehren.de>
With these additional annotations the openapi docs under `/apidoc` and `/private/apidoc` will be improved by adding errors that the requests can return
Signed-off-by: Philip Molares <philip.molares@udo.edu>
As the public api is nearly completely protected by the TokenAuthGuard it seems unnecessarily verbose to add the guard to every method in the controllers, when an annotation at the top of the controller would be sufficient.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This filters all error that the controller will throw and either maps
them to the correct HttpException if they are internal errors like
NotInDBError, or just leaves them be if they are not part in the map.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
Because this mapping will now be done with the ErrorExceptionMapping class, the mapping will be omitted in the interceptor.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
The ErrorExceptionMapping class maps internal error to nestjs's appropriate HttpException.
The object returned by those HttpExceptions is now changed to include the name of the intern error code and error message instead of statusCode and error message as is default. This makes it possible to more easily programmatically distinguish between two errors that map to the same HttpException and only differ in the error message.
The statusCode was unnecessary, because any user of the api gets this information already by which HttpException was used.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
It's not really necessary to tell the user via get that this id is forbidden, it will not be there and as such NotInDBError is the correct message to the user
Signed-off-by: Philip Molares <philip.molares@udo.edu>
These test files are only autogenerated and don't have any benefit. Any behaviour one would test with them are (or at least should) already be covered by our e2e tests.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
To minimize type errors, when the config objects are changed, this commit introduces types to the mock config object accordingly.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit separates the app config object from a new note config object. This was done to separate different concerns in different config files. Especially if the number of settings that are about notes increase, it is a good idea to keep them separate from the app config.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This is part of an effort to consistently not embed User objects
in API responses. Usernames are returned instead.
Signed-off-by: David Mehren <git@herrmehren.de>