Commit graph

39 commits

Author SHA1 Message Date
David Mehren
05926c08d6
FilesystemBackend: Fix ESLint errors
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-26 12:24:35 +01:00
David Mehren
21403ba606
Fix various ESLint errors in unit tests
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-24 20:20:04 +01:00
David Mehren
9485597e6f
ESLint: Enable @typescript-eslint/return-await rule
This ensures stack traces are helpful at the cost of a slightly
lower performance (one more tick in the event loop).

Fixes #838

Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-20 20:14:36 +01:00
Philip Molares
0e4b65ca9d
MediaBackendInterface: Correct JSDoc of deleteFile
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 12:24:02 +01:00
Philip Molares
2c6af85f14
FilesystemBackend: Remove getFileURL
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 11:38:50 +01:00
Philip Molares
4ef3fd029d
MediaBackendInterface: Remove getFileURL
closes #957

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-26 16:15:46 +01:00
Philip Molares
8e7be737fa
FilesystemBackend: Throw MediaBackendError where appropriate
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-25 13:52:50 +01:00
Philip Molares
8515d824b7
MediaService: Add MediaBackendError
This get's thrown when the backend can't perform the required action.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-25 13:51:54 +01:00
Philip Molares
b1683a5c64
GroupsService: Create new GroupsService
This service is necessary as we plan to have functions to create and manipulate groups in the future.
The GroupInfoDto was moved from the file note-permissions.dto.ts to mimic the UserInfoDto.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-20 11:41:15 +01:00
Yannick Bungers
68cbb5a9c2
Add relation between User and Group
This represents the users which are members of this group

Signed-off-by: Yannick Bungers <git@innay.de>
2021-01-27 22:58:55 +01:00
Philip Molares
3ebea8ed77
MediaService: Add unit tests
The file test.zip is used to fail the saveFile test with 'MIME Type not supported'

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-13 22:12:19 +01:00
Philip Molares
c4289c9693
MediaService: Add JS-Docs to media service
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-13 22:06:33 +01:00
Yannick Bungers
22aaa956a7
Reformat code by yarn format
Signed-off-by: Yannick Bungers <git@innay.de>
2021-01-30 18:09:00 +01:00
Yannick Bungers
0d5b9dea00
Refactoring of controllers and service interfaces
DTO should only be used for sending information to and from user.
Services now have methods which return normal internal objects and
methods which convert them to DTOs. This conversion is done in the
controlers

Signed-off-by: Yannick Bungers <git@innay.de>
2021-01-30 00:06:38 +01:00
Philip Molares
508ad26771
auth: Add tests for AuthService
Move AuthTokens to auth folder

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-01-22 15:29:10 +01:00
Philip Molares
4372106ef0
tests: Removed unnecessary import of appConfigMock
As suggested by an review of David Mehren

Co-authored by: David Mehren <git@herrmehren.de>

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-01-19 12:45:36 +01:00
Philip Molares
072ef223e0
config: splits config in multiple files
splits the big appConfig in multiple configs
adds media.config.mock.ts

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-01-15 16:57:04 +01:00
Philip Molares
286575315e
Extend config with various options from 1.x
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2020-12-31 22:37:37 +01:00
David Mehren
18c6694bcb
Add config to tests in various places
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-08 12:56:25 +01:00
David Mehren
e8e82076d0
FilesystemBackend: Use scoped appConfig
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-08 12:53:16 +01:00
David Mehren
67c7c4b8d1
MediaService: Get media backend from configuration
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-08 13:06:44 +01:00
David Mehren
cd37eef45e
Get port and upload path from config
Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
2020-10-30 22:35:57 +01:00
David Mehren
3801b1b042
Format with Prettier 2
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-06 23:48:53 +01:00
Tilman Vatteroth
7aeaf488c4
Change year in copyright to 2021
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2021-01-06 21:36:07 +01:00
Philip Molares
dc63c76f43
added reuse information
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-01-05 22:12:38 +01:00
David Mehren
c95c68541c
Fix tests
Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
2020-10-24 21:11:16 +02:00
David Mehren
ff0651e659
FilesystemBackend: Ensure uploads directory exists
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-24 12:28:52 +02:00
David Mehren
2b23dcc5a9
MediaService: Simplify saveFile signature
As the `saveFile` method only really uses the files `Buffer`, this commit changes the signature so it directly gets a `Buffer` instead of a complicated `MulterFile` object. This also simplifies testing.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-24 11:49:01 +02:00
David Mehren
eeb3f6f5a7
MediaService: Implement delete feature
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 21:54:08 +02:00
David Mehren
5262a58639
FilesystemBackend: ESLint fixes
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 21:53:34 +02:00
David Mehren
c2c51f1eef
MediaService: Only allow upload of common image formats and PDFs
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 20:50:20 +02:00
David Mehren
d41b68b41a
Add various missing imports and provider ovverides in unit tests
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 20:21:22 +02:00
David Mehren
0cc9c6b347
MediaService: Improve error handling and logging
Add debug logging to `saveFile` method and throw the proper errors when problems with the mime type are encountered

Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 18:50:53 +02:00
David Mehren
a877f57875
FilesystemBackend: Implement deleteFile and getFileURL.
We use `fs.unlink` instead of `fs.rm`, as the latter is only available in the fsPromises API since Node 14.14

Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 16:24:30 +02:00
David Mehren
c0cbcc863a
Add MediaService
This service is responsible for operations regarding uploaded media. It should perform save, get and delete operations with the configured backend.
The service also checks, if the mime type of the uploaded media is allowed.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-16 22:35:53 +02:00
David Mehren
23ba2026cc
Do not save file extension as a separate field.
It turned out that saving the file extension in a separate field is not necessary. Instead, the extension is saved in the complete filename in the `id` field.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-16 22:32:58 +02:00
David Mehren
dc49bfcccb
Implement filesystem media backend
This backend stores uploaded media into files on the local filesystem.
This commit also adds a `BackendType` enum, which can be used to distinguish different media backends.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-16 22:30:57 +02:00
David Mehren
db15afcb88
Define a MediaBackend interface
This interface defines the functionality that all media backends (like S3 or Azure) must implement.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-16 22:29:13 +02:00
David Mehren
617f46f32f
Add MediaUpload entity & Media module
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-13 10:33:54 +02:00