David Mehren
490e4cac69
MediaController: Add DELETE /{filename}
route
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 21:54:44 +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
16dfbdd42d
UsersService: Wait for the DB to find a user
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 21:52:59 +02:00
David Mehren
f4c73a8f96
Use POST /media
for file upload
...
The old `/media/upload` subpath does not follow the convention of REST APIs.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 20:58:10 +02:00
David Mehren
eb77642604
Public API: Update /media/upload
route with supported content-types
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 20:55:40 +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
5a07abfd43
MediaController: Handle errors when trying to save file
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 18:51:29 +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
219a3bcb5f
UsersService: Add methods to find, create and delete users
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-12 21:46:53 +02:00
David Mehren
1f22f47327
NotesService: Throw NotInDBError
when the note wasn't found
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 18:47:10 +02:00
David Mehren
273d9b2d19
MediaController: Get parent note from HedgeDoc-Note
header
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 16:44:00 +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
9b3345fa13
Use serve-static
to serve uploaded files.
...
Add `@nestjs/serve-static` to serve uploaded media from the upload directory on the local filesystem.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-16 22:38:31 +02:00
David Mehren
e2b5acaf84
MediaController: Use MediaService
to store media
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-16 22:37:20 +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
David Mehren
5cc20707dc
DB Schema: Add MediaUpload entity
...
MediaUpload stores the uploading user, the note the media was uploaded to and backend data.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-13 10:19:12 +02:00
David Mehren
3ccfc9bbb7
Public API: /media/upload returns the URL of the uploaded file
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-12 21:51:09 +02:00
Jonas Zohren
139e1156da
Source version from package.json
...
Signed-off-by: Jonas Zohren <jonas.zohren@adesso.de>
2020-10-05 20:39:35 +02:00
David Mehren
95a809f0a3
Collect coverage information for E2E tests
...
As proposed in https://github.com/nestjs/nest/issues/3169#issuecomment-588287478
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-03 18:00:12 +02:00
David Mehren
108c5e670c
NestConsoleLoggerService: Propagate trace
parameter to consoleLoggerService
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-03 15:52:07 +02:00
Yannick Bungers
11faa24468
Added markdownbody-decorator
...
which puts the markdown text directly to a variable in the route function.
Content-type of the http request is checked to be text/markdown because we dealing with markdown. Technically by now there can be any content which can be encoded. There could be features in the software which do not work properly if the text can't be parsed as markdown.
Signed-off-by: Yannick Bungers <git@innay.de>
2020-09-27 16:16:07 +02:00
David Mehren
e37722a56a
Switch to using the new custom logger
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-27 21:48:42 +02:00
David Mehren
b256fc8b36
Add logger module and custom logger implementation
...
ConsoleLoggerService is based on the default Nest LoggerService, but adds the ability to give context about the function that is logging something. It also removes the `[Nest]` string and the PID at the beginning of each log line.
NestConsoleLoggerService is a wrapper around ConsoleLoggerService and makes it possible to use our implementation as a default Nest LoggerService
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-27 21:41:02 +02:00
Yannick Bungers
743eb7469d
Fixes types of timestamps and property name
...
Signed-off-by: Yannick Bungers <git@innay.de>
2020-10-01 12:22:52 +02:00
Yannick Bungers
d1bfa5e4c7
Changed let to const to make eslint happy
...
Signed-off-by: Yannick Bungers <git@innay.de>
2020-09-26 23:47:51 +02:00
Yannick Bungers
79dd9af988
Added await to wait for completion of note creation in tests
...
Signed-off-by: Yannick Bungers <git@innay.de>
2020-09-26 23:40:15 +02:00
Yannick Bungers
6a98412285
Added tests test functions for /me routes
...
Note that they don't contain the functions from the services yet.
Signed-off-by: Yannick Bungers <git@innay.de>
2020-09-26 23:27:24 +02:00
David Mehren
776c230877
NotesService: Add TODO that createNote
still needs to calculate a proper patch
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-26 16:01:01 +02:00
David Mehren
ab4ecf6a8f
UsersService: Merge if-statements and add null
to return type in toUserDto
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-26 16:00:17 +02:00
David Mehren
5bd1259949
RevisionsService: Asynchronously inject NotesService to resolve circular dependency while testing
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 20:42:35 +02:00
David Mehren
b9b5af8b7f
Add various missing imports and provider overrides to fix unit tests.
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:59:09 +02:00
David Mehren
a61127dbd6
Note E2E tests: Use response.body
to get the note content
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:46:32 +02:00
David Mehren
3c711e8cb8
Note E2E tests: Use the correct revision-id when checking GET /notes/{note}/revisions/{revision-id}
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:45:56 +02:00
David Mehren
4cf31c1bcb
NotesService: Implement getNoteContent
and getNoteMetdata
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:45:20 +02:00
David Mehren
bc1c8448df
NotesService: Let createNote
create an actual Note
and introduce createNoteDto
to create & convert in one step.
...
It might be handy to have access to the original `Note` after creating one, so the creation and conversion to a `NoteDto` is now split.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:44:53 +02:00
David Mehren
446d6dec06
RevisionsService: Get note revision from database
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:42:17 +02:00
David Mehren
4649b6e796
Note E2E tests: The response for the /notes/<id>/revision route does not contain a revisions
property
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:11:56 +02:00
David Mehren
711358ec0c
Note E2E tests: Await all note-creations and fix test for note-deletion.
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:10:09 +02:00
David Mehren
05a62b31ee
RevisionService: Implement getNoteRevisionMetadatas
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:09:14 +02:00
David Mehren
3d4e9a9b92
NotesController: revisionId
is a number
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:08:14 +02:00
David Mehren
706f3a2360
Public API spec: Update NoteRevisionsMetadata and timestamp definition
...
NoteRevisionsMetadata is an array containing revision data and not an object with a single property containing an array.
Revision timestamps are ISO strings, not UNIX timestamps.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:07:41 +02:00
David Mehren
2140faab07
RevisionMetadataDto: Rename attribute updatedAt
to createdAt
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:04:55 +02:00
David Mehren
2030141c66
Note E2E tests: Use on-disk sqlite to aid debugging
...
It was helpful to inspect database contents while the code was stopped by the debugger. Therefore the E2E test database is now persisted on disk and cleared before every test-run.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 20:09:36 +02:00
David Mehren
cf88cde551
NotesService: Use the database for delete and update actions.
...
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 20:07:36 +02:00