Commit graph

126 commits

Author SHA1 Message Date
David Mehren
f01c7dbbe2
Add MediaUpload entity & Media module
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 19:58:22 +02:00
David Mehren
6af4379a27
NestConsoleLoggerService: Propagate trace parameter to consoleLoggerService
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-03 15:54:00 +02:00
Yannick Bungers
258dd1db56 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-10-02 21:31:10 +02:00
David Mehren
d7f407da2d
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
1a2959f6dc
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:43:52 +02:00
David Mehren
a0740ffdf7
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
8fada8809c
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
a028dac448
RevisionsService: Asynchronously inject NotesService to resolve circular dependency while testing
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:40 +02:00
David Mehren
2ce87f3d64
Add various missing imports and provider overrides to fix unit tests.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:40 +02:00
David Mehren
6e4893d179
NotesService: Implement getNoteContent and getNoteMetdata
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:40 +02:00
David Mehren
8b9a45b738
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-25 21:37:39 +02:00
David Mehren
881263f2a4
RevisionsService: Get note revision from database
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
51aec1ea54
RevisionService: Implement getNoteRevisionMetadatas
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
e1079947e1
NotesController: revisionId is a number
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
7c0e069cbf
RevisionMetadataDto: Rename attribute updatedAt to createdAt
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
47bf8c9c17
NotesService: Use the database for delete and update actions.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
e43008c627
NotesController: Get text from request body when updating and deleting a note.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
99dccc0567
RevisionEntity: Change primary key type from UUID to number
The precision of sqlites datetime() timestamp is only one second (see https://www.sqlite.org/lang_datefunc.html). Therefore we could not order revisions of one note that were created in the same second. To remedy this, the primary key was changed to a monotonically increasing number, which solves the ordering problem.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
1a22f749be
NotesController: Get text from request body when creating a named note.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
a2a9ad224f
NotesService: Find note by ID or alias in database
This commit also introduces the `getNoteDtoByIdOrAlias` method, that converts a `Note` entity to a `NoteDto`

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
e97f9fe174
NoteEntity: Lazy-load revisions relation
Using a `Promise` type in a TypeORM entity automatically enables lazy-loading of that relation.
See https://typeorm.io/#/eager-and-lazy-relations/lazy-relations

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
74b03fc1fd
RevisionsService: Implement getLatestRevision and createRevision methods
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
fae8c679a9
UsersService: Add null check to toUserDto() converter
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
6805c2a41e
NotesService: Get more note metadata from the database
Some previously hardcoded metadata-values are now retrieved from the database.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
e1e0e45434
UsersService: Add toUserDto() converter
This conversion function makes sure that a photo URL exists.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
f937042439
NoteUtils: Add methods to parse note metadata
These methods are intended to parse metadata details from YAML tags, but not implemented for now.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
f5e043b8b1
NoteEntity: Always initialize arrays
The `create()` function did not initialize all arrays, which caused them to be `undefined` instead of empty.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:38 +02:00
David Mehren
5d07481387
RevisionEntity: Add create() method
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:38 +02:00
David Mehren
2ab90917bc
NotesService: createNote() now saves new notes to the database
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:38 +02:00
David Mehren
39410ab9c8
NoteEntity: Move constructor-code to create() method
TypeORM does not like having application code in the constructor (https://github.com/typeorm/typeorm/issues/1772#issuecomment-514787854), therefore that is moved into a new `create() static method. Additionally, the constructor is now `private`, which enforces the use of the new method.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:38 +02:00
David Mehren
8c050b3c2f
NoteEntity: Formatting fixes
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:38 +02:00
David Mehren
4ff60b162e
NoteEntity: Enable CASCADE for revision column
This makes creating new Notes easier, as the first Revision is automatically created in the database.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:38 +02:00
David Mehren
2c3a75187e
NoteController: Do not use text/markdown as response content-type for createNote
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:38 +02:00
David Mehren
b17da345c7
NoteDto: Rename attribute metdata to metadata
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:35:47 +02:00
David Mehren
b4b91acddb
NotesController: Use custom logic to access raw markdown
NestJS does not support content-types other than application/json.
Therefore we need to directly access the request object to get the raw body content.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:35:47 +02:00
David Mehren
d55e3bb622
NotesController: Add missing mock repositories for testing
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:57:56 +02:00
David Mehren
35051986be
MeController: Add missing mock repositories for testing
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:57:47 +02:00
David Mehren
8689b44f59
Implement User entity.
This commit implements the User entity according to the database schema and adds the Identity and AuthToken entities.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:12 +02:00
David Mehren
db026d6a57
Add Session entity
This entity implements the Session interface from connect-typeorm, which we will later use to store session data from express-session.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:12 +02:00
David Mehren
67e60a3c37
Update Note entity
We now use the new permissions split in users and groups. Also the note now knows the colors of its authors.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:12 +02:00
David Mehren
1121ed9507
Add AuthorColor entity
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:12 +02:00
David Mehren
669dd01ecc
Initialize TypeORM for Group entity
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:12 +02:00
David Mehren
82f6e6920c
Update revision entity according to the current database scheme.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:11 +02:00
David Mehren
c6816f9bba
Add authorship entity.
It stores which parts of a revision were edited by a particular user.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:11 +02:00
David Mehren
36a2b3c03d
Add PermissionModule and GroupsModule
Both currently contain only the database entities, taken from the schema.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:11 +02:00
David Mehren
47d005e4fc
Update NotesService and HistoryService to use the new permission model.
We now have separate sharedTo attributes for users and groups.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:11 +02:00
David Mehren
fbd89977cd
Add 'special' property to GroupInfoDto and rename 'id' to 'name'
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:10 +02:00
David Mehren
ea217b3613
Adapt permission DTOs for group permissions
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:10 +02:00
David Mehren
84b7840ce3
Implement routes in MonitoringController
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:10 +02:00
David Mehren
eab06c0296
Add monitoring module
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:10 +02:00