Commit graph

3689 commits

Author SHA1 Message Date
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
Renovate Bot
041574bd07
Update linters to v4.22.1
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2021-05-05 20:27:14 +00:00
Renovate Bot
7d6596b822
Update dependency file-type to v16.4.0
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2021-05-05 20:26:59 +00:00
Yannick Bungers
edaeb6ae46
Merge pull request #1230 from hedgedoc/renovate/develop-ts-jest-26.x
Update dependency ts-jest to v26.5.6 (develop)
2021-05-05 22:25:41 +02:00
Renovate Bot
23640dc1ab
Update dependency ts-jest to v26.5.6
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2021-05-05 16:10:56 +00:00
Yannick Bungers
80adde6c44
Merge pull request #1214 from hedgedoc/renovate/develop-lock-file-maintenance
Lock file maintenance (develop)
2021-05-03 21:29:53 +02:00
Renovate Bot
5f8c108868
Lock file maintenance
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2021-05-03 01:12:21 +00:00
David Mehren
7adbc72a5f
Merge pull request #1130 from hedgedoc/history/transaction 2021-05-02 18:15:05 +02:00
Philip Molares
2ba1be6ea3 PrivateHistoryE2E: Extend POST /me/history
Test the correct behaviour in error cases

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-02 18:09:16 +02:00
Philip Molares
f967b34018 ControllerTests: Add connection to controller tests
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-02 18:09:16 +02:00
Philip Molares
f7e483da81 ESLint: Add extra rules for tests
Add afterEach and beforeAll as additional additionalTestBlockFunctions for jest/no-standalone-expect. This is necessary, because we use expects in those functions for the history service unit tests.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-02 18:09:16 +02:00
Philip Molares
f731d2d455 HistoryService: Add test for setHistory
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-02 18:09:16 +02:00
Philip Molares
ea4c58c68f HistoryService: Add setHistory method
This is the transactional reimplementation of the business logic of the history controllers setHistory method (of the private api). This should prevent the problem that the history gets deleted, but a later error in the handling of the list of HistoryEntryImportDto let's the call fail.

See also: https://docs.nestjs.com/techniques/database#transactions

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-02 18:09:11 +02:00
Philip Molares
353f444f30 HistoryService: Remove extra parameters from createOrUpdateHistoryEntry
As the function is now only called with a user and a note and the previous extra parameters are now added into the transactional setHistory method, this is no longer necessary.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-02 18:08:36 +02:00
Philip Molares
056ab12e67 NotesService: Extract checkNoteIdOrAlias into own method
To reuse this functionality in the history services setHistory method, it was extracted into its own exported function.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-02 18:08:34 +02:00
David Mehren
8dbca54da7
Merge pull request #1206 from hedgedoc/test/seedDB
[Project] Add seed script
2021-05-02 17:54:14 +02:00
David Mehren
2d79404c5e
Merge pull request #1162 from hedgedoc/privateApi/fixes 2021-05-02 17:39:51 +02:00
David Mehren
c05e5bde43
Merge pull request #1203 from hedgedoc/config/renderOriginDefault 2021-05-02 17:39:17 +02:00
Yannick Bungers
cc82aae2ef
Merge pull request #1211 from hedgedoc/renovate/develop-pin-dependencies
Pin dependency @tsconfig/node12 to 1.0.7 (develop)
2021-05-01 14:20:34 +02:00
Yannick Bungers
de56380cf3
Merge pull request #1208 from hedgedoc/renovate/develop-rxjs-7.x
Update dependency rxjs to v7 (develop)
2021-05-01 14:20:09 +02:00
Renovate Bot
0af997ada1
Update dependency rxjs to v7
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2021-04-30 18:53:59 +00:00
Renovate Bot
1a99cdccab
Pin dependency @tsconfig/node12 to 1.0.7
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2021-04-30 18:53:44 +00:00
Yannick Bungers
bb9a6d7028
Merge pull request #1209 from hedgedoc/maintenance/ts_base_config
Use Node 12 TypeScript base config
2021-04-30 20:24:01 +02:00
David Mehren
5e61de9bd5
Use node12 TypeScript base config
TypeScript recommends using a base config from https://github.com/tsconfig/bases.

Using this config reduces compile times by ~30%
and the size of the dist folder by ~45%.
It also enables the recommended `esModuleInterop` option,
which necessitated some changes to imports.
See also https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#support-for-import-d-from-cjs-from-commonjs-modules-with---esmoduleinterop

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 22:55:01 +02:00
Yannick Bungers
9f72028203
Merge pull request #1197 from hedgedoc/renovate/develop-lock-file-maintenance
Lock file maintenance (develop)
2021-04-29 16:54:44 +02:00
Renovate Bot
7a988e8652
Lock file maintenance
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2021-04-29 14:49:27 +00:00
Yannick Bungers
14708e3bbd
Merge pull request #1198 from hedgedoc/renovate/develop-linters
Update dependency eslint-plugin-jest to v24.3.6 (develop)
2021-04-29 16:48:16 +02:00
Philip Molares
55356f36a9 [Project] Add seed script
This script invokes src/seed.ts to create a sqlite DB. The DB already contains some objects to manual test with. This ensures that devs easily can spin up a test instance of HedgeDoc and don't need to fumble around with the DB file.

See https://github.com/typeorm/typeorm#creating-a-connection-to-the-database

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-29 14:31:07 +02:00
Philip Molares
265f3095e4 FrontendConfig: Fix unit test
Emulate the behaviour of the new app config: If renderOrigin is undefined instead use domain.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-27 23:33:13 +02:00
Philip Molares
8bf5aa77e3 AppConfig: Move default for rendererOrigin to config file
As we only use rendererOrigin in the frontend config service, where domain will be used if it is not defined, it makes more sense to move this default behavior to the app config directly. That makes it easier to understand what this variable contains and that it defaults to domain.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-27 23:08:22 +02:00
Renovate Bot
42a627b464
Update dependency eslint-plugin-jest to v24.3.6
Signed-off-by: Renovate Bot <bot@renovateapp.com>
2021-04-27 20:32:19 +00:00
Yannick Bungers
57ad615e6f
Merge pull request #1200 from hedgedoc/renovate/develop-definitelytyped
Update definitelyTyped (develop)
2021-04-27 22:31:17 +02:00