Commit graph

1423 commits

Author SHA1 Message Date
Philip Molares
86ef8f3c7f docs: add documentation to OpenApi decorator
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-20 20:56:09 +01:00
Philip Molares
cae55e0baa test: fix e2e test error codes
As these were changed with the openapi decorator the test need to reflect this.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-20 20:56:09 +01:00
Philip Molares
89aac9d4b6 refactor: use new openapi decorator
Also remove fullapi decorator, because it's fully replaced by the openapi decorator.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-20 20:56:09 +01:00
Philip Molares
a283002a34 feat: create openapi decorator
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>
2022-02-20 20:56:09 +01:00
Philip Molares
c6bb8f62e8 refactor: use a base dto class
This gives all dto classes a common super class for usage of the type system.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-20 20:56:09 +01:00
Philip Molares
0955bf048d refactor: rename markdown body decorator
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-20 20:56:09 +01:00
Philip Molares
7f8d745c80 refactor: move permissions decorator into api utils dir
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-20 20:56:09 +01:00
Renovate Bot
e339f740e7 fix(deps): update dependency @types/node-fetch to v2.6.1
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-19 20:48:05 +01:00
Renovate Bot
2bdb567ff5 fix(deps): update nestjs packages
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-19 20:42:26 +01:00
Renovate Bot
b413c35d8a chore(deps): update linters
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-19 20:40:39 +01:00
Renovate Bot
c13ead34f8 chore(deps): update dependency mkdocs-material to v8.2.1
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-19 20:39:56 +01:00
Renovate Bot
48b52227f9 fix(deps): update dependency typeorm to v0.2.43
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-19 11:48:04 +00:00
Renovate Bot
8e3b7cf4f1 fix(deps): update dependency raw-body to v2.4.3
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-19 10:03:14 +00:00
Renovate Bot
5cbecf4ddd chore(deps): update dependency eslint-plugin-jest to v26.1.1
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-19 08:37:48 +00:00
Renovate Bot
161aa89747 chore(deps): update dependency @types/node to v16.11.25
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-19 04:55:57 +00:00
Renovate Bot
bd3add4d1b chore(deps): update dependency @nestjs/cli to v8.2.1
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-19 02:21:30 +00:00
Erik Michelson
c917e9d5f1 Update name in docs
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2022-02-14 11:50:02 +01:00
Erik Michelson
49b563f182 Use 'HedgeDoc' in changelog and license
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2022-02-14 11:50:02 +01:00
David Mehren
81d47b57d6 test: app should not crash on requests to /
Regression test for 396ad181d0

Signed-off-by: David Mehren <git@herrmehren.de>
2022-02-14 11:28:02 +01:00
David Mehren
2c081b8dbf fix: correctly initialize exception mapping
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>
2022-02-14 11:28:02 +01:00
Renovate Bot
bb115dedb6 chore(deps): lock file maintenance
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-14 02:35:57 +00:00
Renovate Bot
bf5917b563 fix(deps): update nestjs packages
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-12 11:54:16 +01:00
Renovate Bot
df857f9886 chore(deps): update linters
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-12 11:54:03 +01:00
Renovate Bot
c38e3e3fa1 fix(deps): update dependency rxjs to v7.5.4
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-12 11:53:55 +01:00
Renovate Bot
f631cf2423 chore(deps): update dependency mkdocs-material to v8.1.11
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-12 11:53:46 +01:00
Renovate Bot
77ed48b736 chore(deps): update dependency pymdown-extensions to v9.2
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-12 11:46:06 +01:00
Renovate Bot
c3ae62843f chore(deps): update dependency ts-node to v10.5.0
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-12 11:38:43 +01:00
Renovate Bot
505ad8575b chore(deps): update dependency jest to v27.5.1
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-12 09:35:42 +00:00
Renovate Bot
d41d5cf3f9 chore(deps): update dependency http-proxy-middleware to v2.0.3
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-12 06:03:54 +00:00
Renovate Bot
7a32a228cb chore(deps): update dependency @types/node to v16.11.24
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-12 03:52:53 +00:00
Renovate Bot
79573d7aa0 chore(deps): update dependency eslint-plugin-jest to v26.1.0
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-07 09:36:12 +01:00
Renovate Bot
45fe1941b7 chore(deps): lock file maintenance
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-07 02:58:57 +00:00
Philip Molares
1c67622bf8 test(notes.service): a forbidden id throws a ForbiddenIdError in getNoteByIdOrAlias method
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
c891a95588 feat: checkNoteIdOrAlias in more alias service methods
This should prevent any interaction by a forbidden id

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
6269c7f7bc test: fix expected error codes in multiple test
In the e2e tests the global filter must be added via the special provider 'APP_FILTER' and not with useGlobalFilters, because if not the filter breaks, because of the way supertest handles the http-connection.

See: https://github.com/nestjs/nest/issues/1160#issuecomment-468698640

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
796b8294cf docs: improved auto-generated openapi docs
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>
2022-02-07 00:08:41 +01:00
Philip Molares
2bc8c0d6da refactor(public-api): use TokenAuthGuard on controller not method level
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>
2022-02-07 00:08:41 +01:00
Philip Molares
d142cbadeb refactor: remove try catches from controllers
This is handled by the ErrorExceptionMapping class

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
2cd4f412e5 feat: add ErrorExceptionMapping as a global filter
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>
2022-02-07 00:08:41 +01:00
Philip Molares
2c7e82680e feat: add additional default descriptions for HttpExceptions
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
d0477a5e34 refactor: omit error mapping in GetNoteInterceptor
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>
2022-02-07 00:08:41 +01:00
Philip Molares
4ad7ad368c feat: add error-mapping
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>
2022-02-07 00:08:41 +01:00
Philip Molares
451dedef15 refactor: getNoteByIdOrAlias throws NotInDBError instead of ForbiddenIdError for an id on the forbidden list
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>
2022-02-07 00:08:41 +01:00
Philip Molares
4500caf882 refactor: move error messages from controller to service
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2022-02-07 00:08:41 +01:00
Philip Molares
f672c5179f test: remove controller tests
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>
2022-02-06 20:57:34 +01:00
Renovate Bot
d2db5a0cb8 chore(deps): update dependency mkdocs-material to v8.1.10
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-06 12:14:58 +00:00
Renovate Bot
4b34f94730 chore(deps): update dependency jest to v27.5.0
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-05 12:27:24 +01:00
Renovate Bot
39eab69c6c chore(deps): update dependency @types/node to v16.11.22
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-05 11:34:48 +01:00
Renovate Bot
c0f7178891 chore(deps): update linters to v5.10.2
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-05 11:34:25 +01:00
Renovate Bot
cde9a2f66a chore(deps): update dependency @trivago/prettier-plugin-sort-imports to v3.2.0
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2022-02-05 11:34:09 +01:00