David Mehren
0d9dfc4076
AuthTokenEntity: Make validUntil not nullable
...
As all tokens are valid for a maximum of 2 years, the
validUntil attribute is always populated.
This updates the database schema and the DTO to reflect that.
Fixes #1256
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 22:05:47 +02:00
David Mehren
f4587cfa9b
Merge pull request #1253 from hedgedoc/renovate/develop-major-definitelytyped
...
Update dependency @types/bcrypt to v5 (develop)
2021-05-09 21:52:04 +02:00
Renovate Bot
cedbee5a94
Update dependency @types/bcrypt to v5
...
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2021-05-09 19:42:04 +00:00
David Mehren
cc851d9631
Remove superfluous overrideProvider statements
...
Fixes #1254
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 21:35:34 +02:00
David Mehren
c9d50cb60c
Merge pull request #1207 from hedgedoc/maintenance/ts_strict_mode
2021-05-09 21:23:59 +02:00
David Mehren
a72b4b1eb1
Add error handling in seed.ts
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:32 +02:00
David Mehren
980da1fa43
Fix nullable property types in Note DTOs
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
64f9a29f02
MediaUploadDto: Make noteId optional
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
b518583fd2
E2E Tests: Fix ESLint errors
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
30712abe31
GroupsService: Remove test obsoleted by strict mode
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
0c89d8715e
UsersService: Remove test obsoleted by strict mode
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
ea11fbff12
Ensure optional properties of AuthTokenDto are initialized
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
f0c4fbe371
Disable strict mode for tests
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
d1e352d56c
Add explicit type annotations to nullable columns
...
TypeORM can't correctly infer the data type on properties with a `| null` type.
This commit adds explicit type annotations.
See also https://github.com/typeorm/typeorm/issues/2567#issuecomment-408599335
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
f9a0353748
NotesService.toNoteMetadataDto: Handle undefined updateUser
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
f8efb9717e
NotesService: Fix type errors
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
3b0ffaca30
Consistently type properties as optional
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
b3e01fff7f
GroupsService: Remove null from toGroupDto return type
...
toGroupDto won't return null, as TS's strict mode
prevents group from being nullish
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
664a64495f
NotesController: Double-check that req.user is defined
...
TokenAuthGuard ensures that req.user is always
defined, but thanks to strict mode we have to check again.
In the future, we may add a custom Request type and
a custom param decorator to centralize the check.
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
6aa1aa229a
NoteEntity: Allow anonymous notes
...
Notes created by anonymous users don't have an owner.
This commit updates the entity accordingly.
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
b08a314863
MediaUploadDto: Make noteId optional
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
dc7d8ab470
MediaService: Handle unexpected backend type
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
b93f01fe57
Correctly type nullable columns
...
TypeORM columns with `nullable: true` can be `null` at runtime.
This commit ensures that the types of the corresponding properties reflect that.
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
16ed12bfd7
MediaController: Double-check that req.user is defined
...
TokenAuthGuard ensures that req.user is always
defined, but thanks to strict mode we have to check again.
In the future, we may add a custom Request type and
a custom param decorator to centralize the check.
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
ace1b7fad6
MeController: Double-check that req.user is defined
...
TokenAuthGuard ensures that req.user is always
defined, but thanks to strict mode we have to check again.
In the future, we may add a custom Request type and
a custom param decorator to centralize the check.
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
e18ee1f0fe
UsersService: Remove null from toUserDto return type
...
toUserDto won't return null, as TS's strict mode
prevents user from being nullish
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
96f8284e64
MarkdownBody: Handle error in getOwnPropertyDescriptor
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
a04a111293
Handle config initialisation error on app bootstrap
...
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
994bd7ae64
HistoryService: Throw NotInDBError on empty DB result
...
This adds error handling to getEntryByNote, so it throws a
NotInDBError instead of (illegally, according to the type) returning
null.
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
0573ce4e08
FrontendConfig DTOs: Make properties consistently optional
...
Some properties already have a IsOptional decorator,
this makes the properties themselves also optional
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
99103ad217
ConsoleLoggerService: Fix type of context properties
...
Nullish values of functionContext and classContext are handled correctly,
so the type can be adjusted
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
d9799717b5
AuthService: Fix type of toAuthTokenWithSecretDto
...
toAuthTokenDto does not return nor accept a nullish value anymore,
so the types can be adjusted.
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
53a0c87a53
AuthService.randomString: Throw Error instead of returning null
...
A string with a negative length is invalid, so we should throw here
instead of complicating the type with a possible null return value.
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:30 +02:00
David Mehren
72b545fec5
AuthTokenDto: Make properties consistently optional
...
validUntil and lastUsed already have a IsOptional decorator,
this makes the properties themselves also optional
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:30 +02:00
David Mehren
cfaa07806b
AuthService: Throw NotInDBError on empty DB result
...
This adds error handling to various functions, so they throw a
NotInDBError instead of a TypeError
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:30 +02:00
David Mehren
6fd9d64ad7
Safely parse numbers from environment vars
...
This adds the function parseOptionalInt to help parse numbers
from environment variables
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:30 +02:00
David Mehren
2da9b76a31
Config Utils: Fix type of toArrayConfig
...
configValue is checked for a nullish value,
the type should reflect that.
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:30 +02:00
David Mehren
74bc9612cc
AuthService: Remove null from toAuthTokenDto return type
...
toAuthTokenDto won't return null, as TS's strict mode
prevents authToken from being nullish
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:30 +02:00
David Mehren
a6e245c551
RevisionsService: Throw NotInDBError on empty DB result
...
This adds error handling to various getters, so they throw a
NotInDBError instead of (illegally, according to the type) returning
null.
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:30 +02:00
David Mehren
3861d4beb4
Enable TypeScript strict mode
...
This enables strict mode, but sets strictPropertyInitialization to false,
as "the class-validator DTO pattern described in the documentation is
not compatible with strict property initialization" according to
https://github.com/nestjs/typescript-starter/pull/192
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 17:44:20 +02:00
David Mehren
0334014f7e
Merge pull request #1248 from hedgedoc/renovate/develop-linters
...
Update dependency eslint to v7.26.0 (develop)
2021-05-09 14:45:42 +02:00
David Mehren
be25f32f53
Merge pull request #1235 from hedgedoc/renovate/develop-ts-loader-9.x
...
Update dependency ts-loader to v9.1.2 (develop)
2021-05-09 14:45:09 +02:00
Renovate Bot
89b9160787
Update dependency eslint to v7.26.0
...
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2021-05-09 12:41:30 +00:00
Renovate Bot
84cb34eef3
Update dependency ts-loader to v9.1.2
...
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2021-05-09 12:41:15 +00:00
David Mehren
b1c9a4430d
Merge pull request #1251 from hedgedoc/renovate/develop-pymdown-extensions-8.x
...
Update dependency pymdown-extensions to v8.2 (develop)
2021-05-09 14:39:57 +02:00
Renovate Bot
6af90b9555
Update dependency pymdown-extensions to v8.2
...
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2021-05-08 19:43:43 +00:00
Yannick Bungers
0db8a31e3f
Merge pull request #1238 from hedgedoc/renovate/develop-mkdocs-material-7.x
...
Update dependency mkdocs-material to v7.1.4 (develop)
2021-05-08 21:41:29 +02:00
Renovate Bot
b38b2b12f0
Update dependency mkdocs-material to v7.1.4
...
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2021-05-07 09:51:32 +00:00
Yannick Bungers
77b7f30eb8
Merge pull request #1224 from hedgedoc/renovate/develop-linters
...
Update linters to v4.22.1 (develop)
2021-05-07 11:48:43 +02:00
Yannick Bungers
f55ebc5bcf
Merge pull request #1229 from hedgedoc/renovate/develop-file-type-16.x
...
Update dependency file-type to v16.4.0 (develop)
2021-05-07 11:48:28 +02:00