mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-27 03:58:02 -05:00
Merge pull request #1590 from hedgedoc/chore/sort_imports
This commit is contained in:
commit
d92b39eae2
134 changed files with 718 additions and 633 deletions
|
@ -38,7 +38,7 @@ module.exports = {
|
||||||
'eslint:recommended',
|
'eslint:recommended',
|
||||||
'plugin:@typescript-eslint/recommended',
|
'plugin:@typescript-eslint/recommended',
|
||||||
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
||||||
'prettier',
|
'plugin:prettier/recommended',
|
||||||
],
|
],
|
||||||
root: true,
|
root: true,
|
||||||
env: {
|
env: {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
{
|
{
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"trailingComma": "all"
|
"trailingComma": "all",
|
||||||
|
"importOrder": ["^[./]"],
|
||||||
|
"importOrderSeparation": true
|
||||||
}
|
}
|
|
@ -66,6 +66,7 @@
|
||||||
"@nestjs/cli": "8.1.1",
|
"@nestjs/cli": "8.1.1",
|
||||||
"@nestjs/schematics": "8.0.3",
|
"@nestjs/schematics": "8.0.3",
|
||||||
"@nestjs/testing": "8.0.6",
|
"@nestjs/testing": "8.0.6",
|
||||||
|
"@trivago/prettier-plugin-sort-imports": "^2.0.4",
|
||||||
"@tsconfig/node12": "1.0.9",
|
"@tsconfig/node12": "1.0.9",
|
||||||
"@types/cli-color": "2.0.1",
|
"@types/cli-color": "2.0.1",
|
||||||
"@types/express": "4.17.13",
|
"@types/express": "4.17.13",
|
||||||
|
@ -77,6 +78,7 @@
|
||||||
"eslint": "7.32.0",
|
"eslint": "7.32.0",
|
||||||
"eslint-config-prettier": "8.3.0",
|
"eslint-config-prettier": "8.3.0",
|
||||||
"eslint-plugin-import": "2.24.2",
|
"eslint-plugin-import": "2.24.2",
|
||||||
|
"eslint-plugin-prettier": "^3.4.1",
|
||||||
"jest": "27.1.0",
|
"jest": "27.1.0",
|
||||||
"prettier": "2.3.2",
|
"prettier": "2.3.2",
|
||||||
"supertest": "6.1.6",
|
"supertest": "6.1.6",
|
||||||
|
|
|
@ -3,16 +3,16 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { ConfigController } from './config.controller';
|
|
||||||
import { LoggerModule } from '../../../logger/logger.module';
|
|
||||||
import { FrontendConfigModule } from '../../../frontend-config/frontend-config.module';
|
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
import authConfigMock from '../../../config/mock/auth.config.mock';
|
import authConfigMock from '../../../config/mock/auth.config.mock';
|
||||||
import customizationConfigMock from '../../../config/mock/customization.config.mock';
|
import customizationConfigMock from '../../../config/mock/customization.config.mock';
|
||||||
import externalConfigMock from '../../../config/mock/external-services.config.mock';
|
import externalConfigMock from '../../../config/mock/external-services.config.mock';
|
||||||
|
import { FrontendConfigModule } from '../../../frontend-config/frontend-config.module';
|
||||||
|
import { LoggerModule } from '../../../logger/logger.module';
|
||||||
|
import { ConfigController } from './config.controller';
|
||||||
|
|
||||||
describe('ConfigController', () => {
|
describe('ConfigController', () => {
|
||||||
let controller: ConfigController;
|
let controller: ConfigController;
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Controller, Get } from '@nestjs/common';
|
import { Controller, Get } from '@nestjs/common';
|
||||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
|
||||||
import { FrontendConfigService } from '../../../frontend-config/frontend-config.service';
|
|
||||||
import { FrontendConfigDto } from '../../../frontend-config/frontend-config.dto';
|
import { FrontendConfigDto } from '../../../frontend-config/frontend-config.dto';
|
||||||
|
import { FrontendConfigService } from '../../../frontend-config/frontend-config.service';
|
||||||
|
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||||
|
|
||||||
@Controller('config')
|
@Controller('config')
|
||||||
export class ConfigController {
|
export class ConfigController {
|
||||||
|
|
|
@ -3,33 +3,33 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { Author } from '../../../../authors/author.entity';
|
|
||||||
import { Session } from '../../../../users/session.entity';
|
|
||||||
import { HistoryController } from './history.controller';
|
|
||||||
import { LoggerModule } from '../../../../logger/logger.module';
|
|
||||||
import { UsersModule } from '../../../../users/users.module';
|
|
||||||
import { HistoryModule } from '../../../../history/history.module';
|
|
||||||
import { NotesModule } from '../../../../notes/notes.module';
|
|
||||||
import {
|
import {
|
||||||
getConnectionToken,
|
getConnectionToken,
|
||||||
getRepositoryToken,
|
getRepositoryToken,
|
||||||
TypeOrmModule,
|
TypeOrmModule,
|
||||||
} from '@nestjs/typeorm';
|
} from '@nestjs/typeorm';
|
||||||
import { User } from '../../../../users/user.entity';
|
|
||||||
import { Note } from '../../../../notes/note.entity';
|
|
||||||
import { AuthToken } from '../../../../auth/auth-token.entity';
|
import { AuthToken } from '../../../../auth/auth-token.entity';
|
||||||
import { Identity } from '../../../../users/identity.entity';
|
import { Author } from '../../../../authors/author.entity';
|
||||||
import { Edit } from '../../../../revisions/edit.entity';
|
import appConfigMock from '../../../../config/mock/app.config.mock';
|
||||||
import { Revision } from '../../../../revisions/revision.entity';
|
import { Group } from '../../../../groups/group.entity';
|
||||||
import { Tag } from '../../../../notes/tag.entity';
|
|
||||||
import { HistoryEntry } from '../../../../history/history-entry.entity';
|
import { HistoryEntry } from '../../../../history/history-entry.entity';
|
||||||
|
import { HistoryModule } from '../../../../history/history.module';
|
||||||
|
import { LoggerModule } from '../../../../logger/logger.module';
|
||||||
|
import { Note } from '../../../../notes/note.entity';
|
||||||
|
import { NotesModule } from '../../../../notes/notes.module';
|
||||||
|
import { Tag } from '../../../../notes/tag.entity';
|
||||||
import { NoteGroupPermission } from '../../../../permissions/note-group-permission.entity';
|
import { NoteGroupPermission } from '../../../../permissions/note-group-permission.entity';
|
||||||
import { NoteUserPermission } from '../../../../permissions/note-user-permission.entity';
|
import { NoteUserPermission } from '../../../../permissions/note-user-permission.entity';
|
||||||
import { Group } from '../../../../groups/group.entity';
|
import { Edit } from '../../../../revisions/edit.entity';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { Revision } from '../../../../revisions/revision.entity';
|
||||||
import appConfigMock from '../../../../config/mock/app.config.mock';
|
import { Identity } from '../../../../users/identity.entity';
|
||||||
|
import { Session } from '../../../../users/session.entity';
|
||||||
|
import { User } from '../../../../users/user.entity';
|
||||||
|
import { UsersModule } from '../../../../users/users.module';
|
||||||
|
import { HistoryController } from './history.controller';
|
||||||
|
|
||||||
describe('HistoryController', () => {
|
describe('HistoryController', () => {
|
||||||
let controller: HistoryController;
|
let controller: HistoryController;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
Body,
|
Body,
|
||||||
|
@ -16,13 +15,14 @@ import {
|
||||||
Put,
|
Put,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { UsersService } from '../../../../users/users.service';
|
|
||||||
import { HistoryEntryDto } from '../../../../history/history-entry.dto';
|
|
||||||
import { ForbiddenIdError, NotInDBError } from '../../../../errors/errors';
|
import { ForbiddenIdError, NotInDBError } from '../../../../errors/errors';
|
||||||
import { HistoryEntryImportDto } from '../../../../history/history-entry-import.dto';
|
import { HistoryEntryImportDto } from '../../../../history/history-entry-import.dto';
|
||||||
import { HistoryEntryUpdateDto } from '../../../../history/history-entry-update.dto';
|
import { HistoryEntryUpdateDto } from '../../../../history/history-entry-update.dto';
|
||||||
import { ConsoleLoggerService } from '../../../../logger/console-logger.service';
|
import { HistoryEntryDto } from '../../../../history/history-entry.dto';
|
||||||
import { HistoryService } from '../../../../history/history.service';
|
import { HistoryService } from '../../../../history/history.service';
|
||||||
|
import { ConsoleLoggerService } from '../../../../logger/console-logger.service';
|
||||||
|
import { UsersService } from '../../../../users/users.service';
|
||||||
|
|
||||||
@ApiTags('history')
|
@ApiTags('history')
|
||||||
@Controller('/me/history')
|
@Controller('/me/history')
|
||||||
|
|
|
@ -3,31 +3,31 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { Author } from '../../../authors/author.entity';
|
|
||||||
import { Session } from '../../../users/session.entity';
|
|
||||||
import { MeController } from './me.controller';
|
|
||||||
import { UsersModule } from '../../../users/users.module';
|
|
||||||
import { LoggerModule } from '../../../logger/logger.module';
|
|
||||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||||
import { User } from '../../../users/user.entity';
|
|
||||||
import { Identity } from '../../../users/identity.entity';
|
import { Author } from '../../../authors/author.entity';
|
||||||
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
|
import authConfigMock from '../../../config/mock/auth.config.mock';
|
||||||
|
import customizationConfigMock from '../../../config/mock/customization.config.mock';
|
||||||
|
import externalServicesConfigMock from '../../../config/mock/external-services.config.mock';
|
||||||
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
|
import { Group } from '../../../groups/group.entity';
|
||||||
|
import { LoggerModule } from '../../../logger/logger.module';
|
||||||
|
import { MediaUpload } from '../../../media/media-upload.entity';
|
||||||
import { MediaModule } from '../../../media/media.module';
|
import { MediaModule } from '../../../media/media.module';
|
||||||
|
import { Note } from '../../../notes/note.entity';
|
||||||
|
import { Tag } from '../../../notes/tag.entity';
|
||||||
import { NoteGroupPermission } from '../../../permissions/note-group-permission.entity';
|
import { NoteGroupPermission } from '../../../permissions/note-group-permission.entity';
|
||||||
import { NoteUserPermission } from '../../../permissions/note-user-permission.entity';
|
import { NoteUserPermission } from '../../../permissions/note-user-permission.entity';
|
||||||
import { Edit } from '../../../revisions/edit.entity';
|
import { Edit } from '../../../revisions/edit.entity';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
|
||||||
import authConfigMock from '../../../config/mock/auth.config.mock';
|
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
|
||||||
import customizationConfigMock from '../../../config/mock/customization.config.mock';
|
|
||||||
import externalServicesConfigMock from '../../../config/mock/external-services.config.mock';
|
|
||||||
import { MediaUpload } from '../../../media/media-upload.entity';
|
|
||||||
import { Note } from '../../../notes/note.entity';
|
|
||||||
import { Tag } from '../../../notes/tag.entity';
|
|
||||||
import { Revision } from '../../../revisions/revision.entity';
|
import { Revision } from '../../../revisions/revision.entity';
|
||||||
import { Group } from '../../../groups/group.entity';
|
import { Identity } from '../../../users/identity.entity';
|
||||||
|
import { Session } from '../../../users/session.entity';
|
||||||
|
import { User } from '../../../users/user.entity';
|
||||||
|
import { UsersModule } from '../../../users/users.module';
|
||||||
|
import { MeController } from './me.controller';
|
||||||
|
|
||||||
describe('MeController', () => {
|
describe('MeController', () => {
|
||||||
let controller: MeController;
|
let controller: MeController;
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Body, Controller, Delete, Get, HttpCode, Post } from '@nestjs/common';
|
import { Body, Controller, Delete, Get, HttpCode, Post } from '@nestjs/common';
|
||||||
import { UserInfoDto } from '../../../users/user-info.dto';
|
|
||||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||||
import { UsersService } from '../../../users/users.service';
|
|
||||||
import { MediaService } from '../../../media/media.service';
|
|
||||||
import { MediaUploadDto } from '../../../media/media-upload.dto';
|
import { MediaUploadDto } from '../../../media/media-upload.dto';
|
||||||
|
import { MediaService } from '../../../media/media.service';
|
||||||
|
import { UserInfoDto } from '../../../users/user-info.dto';
|
||||||
|
import { UsersService } from '../../../users/users.service';
|
||||||
|
|
||||||
@Controller('me')
|
@Controller('me')
|
||||||
export class MeController {
|
export class MeController {
|
||||||
|
|
|
@ -3,33 +3,33 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { Author } from '../../../authors/author.entity';
|
|
||||||
import { Session } from '../../../users/session.entity';
|
|
||||||
import { UsersModule } from '../../../users/users.module';
|
|
||||||
import { MediaController } from './media.controller';
|
|
||||||
import { LoggerModule } from '../../../logger/logger.module';
|
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||||
|
|
||||||
|
import { AuthToken } from '../../../auth/auth-token.entity';
|
||||||
|
import { Author } from '../../../authors/author.entity';
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
import authConfigMock from '../../../config/mock/auth.config.mock';
|
import authConfigMock from '../../../config/mock/auth.config.mock';
|
||||||
import customizationConfigMock from '../../../config/mock/customization.config.mock';
|
import customizationConfigMock from '../../../config/mock/customization.config.mock';
|
||||||
import externalConfigMock from '../../../config/mock/external-services.config.mock';
|
import externalConfigMock from '../../../config/mock/external-services.config.mock';
|
||||||
import { MediaModule } from '../../../media/media.module';
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
import { NotesModule } from '../../../notes/notes.module';
|
import { Group } from '../../../groups/group.entity';
|
||||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
import { LoggerModule } from '../../../logger/logger.module';
|
||||||
import { Edit } from '../../../revisions/edit.entity';
|
|
||||||
import { AuthToken } from '../../../auth/auth-token.entity';
|
|
||||||
import { Identity } from '../../../users/identity.entity';
|
|
||||||
import { MediaUpload } from '../../../media/media-upload.entity';
|
import { MediaUpload } from '../../../media/media-upload.entity';
|
||||||
|
import { MediaModule } from '../../../media/media.module';
|
||||||
import { Note } from '../../../notes/note.entity';
|
import { Note } from '../../../notes/note.entity';
|
||||||
import { Revision } from '../../../revisions/revision.entity';
|
import { NotesModule } from '../../../notes/notes.module';
|
||||||
import { User } from '../../../users/user.entity';
|
|
||||||
import { Tag } from '../../../notes/tag.entity';
|
import { Tag } from '../../../notes/tag.entity';
|
||||||
import { NoteGroupPermission } from '../../../permissions/note-group-permission.entity';
|
import { NoteGroupPermission } from '../../../permissions/note-group-permission.entity';
|
||||||
import { NoteUserPermission } from '../../../permissions/note-user-permission.entity';
|
import { NoteUserPermission } from '../../../permissions/note-user-permission.entity';
|
||||||
import { Group } from '../../../groups/group.entity';
|
import { Edit } from '../../../revisions/edit.entity';
|
||||||
|
import { Revision } from '../../../revisions/revision.entity';
|
||||||
|
import { Identity } from '../../../users/identity.entity';
|
||||||
|
import { Session } from '../../../users/session.entity';
|
||||||
|
import { User } from '../../../users/user.entity';
|
||||||
|
import { UsersModule } from '../../../users/users.module';
|
||||||
|
import { MediaController } from './media.controller';
|
||||||
|
|
||||||
describe('MediaController', () => {
|
describe('MediaController', () => {
|
||||||
let controller: MediaController;
|
let controller: MediaController;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
Controller,
|
Controller,
|
||||||
|
@ -14,16 +13,17 @@ import {
|
||||||
UploadedFile,
|
UploadedFile,
|
||||||
UseInterceptors,
|
UseInterceptors,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
import { FileInterceptor } from '@nestjs/platform-express';
|
||||||
import { MediaService } from '../../../media/media.service';
|
|
||||||
import { MulterFile } from '../../../media/multer-file.interface';
|
|
||||||
import { MediaUploadUrlDto } from '../../../media/media-upload-url.dto';
|
|
||||||
import {
|
import {
|
||||||
ClientError,
|
ClientError,
|
||||||
MediaBackendError,
|
MediaBackendError,
|
||||||
NotInDBError,
|
NotInDBError,
|
||||||
} from '../../../errors/errors';
|
} from '../../../errors/errors';
|
||||||
import { FileInterceptor } from '@nestjs/platform-express';
|
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||||
|
import { MediaUploadUrlDto } from '../../../media/media-upload-url.dto';
|
||||||
|
import { MediaService } from '../../../media/media.service';
|
||||||
|
import { MulterFile } from '../../../media/multer-file.interface';
|
||||||
|
|
||||||
@Controller('media')
|
@Controller('media')
|
||||||
export class MediaController {
|
export class MediaController {
|
||||||
|
|
|
@ -3,39 +3,39 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { Author } from '../../../authors/author.entity';
|
|
||||||
import { Session } from '../../../users/session.entity';
|
|
||||||
import { NotesController } from './notes.controller';
|
|
||||||
import { NotesService } from '../../../notes/notes.service';
|
|
||||||
import {
|
import {
|
||||||
getConnectionToken,
|
getConnectionToken,
|
||||||
getRepositoryToken,
|
getRepositoryToken,
|
||||||
TypeOrmModule,
|
TypeOrmModule,
|
||||||
} from '@nestjs/typeorm';
|
} from '@nestjs/typeorm';
|
||||||
import { Note } from '../../../notes/note.entity';
|
|
||||||
import { Tag } from '../../../notes/tag.entity';
|
import { AuthToken } from '../../../auth/auth-token.entity';
|
||||||
import { RevisionsModule } from '../../../revisions/revisions.module';
|
import { Author } from '../../../authors/author.entity';
|
||||||
import { UsersModule } from '../../../users/users.module';
|
|
||||||
import { GroupsModule } from '../../../groups/groups.module';
|
|
||||||
import { LoggerModule } from '../../../logger/logger.module';
|
|
||||||
import { PermissionsModule } from '../../../permissions/permissions.module';
|
|
||||||
import { HistoryModule } from '../../../history/history.module';
|
|
||||||
import { MediaModule } from '../../../media/media.module';
|
|
||||||
import { ConfigModule } from '@nestjs/config';
|
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
import { Revision } from '../../../revisions/revision.entity';
|
import { Group } from '../../../groups/group.entity';
|
||||||
import { Edit } from '../../../revisions/edit.entity';
|
import { GroupsModule } from '../../../groups/groups.module';
|
||||||
import { User } from '../../../users/user.entity';
|
|
||||||
import { AuthToken } from '../../../auth/auth-token.entity';
|
|
||||||
import { Identity } from '../../../users/identity.entity';
|
|
||||||
import { HistoryEntry } from '../../../history/history-entry.entity';
|
import { HistoryEntry } from '../../../history/history-entry.entity';
|
||||||
|
import { HistoryModule } from '../../../history/history.module';
|
||||||
|
import { LoggerModule } from '../../../logger/logger.module';
|
||||||
|
import { MediaUpload } from '../../../media/media-upload.entity';
|
||||||
|
import { MediaModule } from '../../../media/media.module';
|
||||||
|
import { Note } from '../../../notes/note.entity';
|
||||||
|
import { NotesService } from '../../../notes/notes.service';
|
||||||
|
import { Tag } from '../../../notes/tag.entity';
|
||||||
import { NoteGroupPermission } from '../../../permissions/note-group-permission.entity';
|
import { NoteGroupPermission } from '../../../permissions/note-group-permission.entity';
|
||||||
import { NoteUserPermission } from '../../../permissions/note-user-permission.entity';
|
import { NoteUserPermission } from '../../../permissions/note-user-permission.entity';
|
||||||
import { Group } from '../../../groups/group.entity';
|
import { PermissionsModule } from '../../../permissions/permissions.module';
|
||||||
import { MediaUpload } from '../../../media/media-upload.entity';
|
import { Edit } from '../../../revisions/edit.entity';
|
||||||
|
import { Revision } from '../../../revisions/revision.entity';
|
||||||
|
import { RevisionsModule } from '../../../revisions/revisions.module';
|
||||||
|
import { Identity } from '../../../users/identity.entity';
|
||||||
|
import { Session } from '../../../users/session.entity';
|
||||||
|
import { User } from '../../../users/user.entity';
|
||||||
|
import { UsersModule } from '../../../users/users.module';
|
||||||
|
import { NotesController } from './notes.controller';
|
||||||
|
|
||||||
describe('NotesController', () => {
|
describe('NotesController', () => {
|
||||||
let controller: NotesController;
|
let controller: NotesController;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
Body,
|
Body,
|
||||||
|
@ -16,25 +15,26 @@ import {
|
||||||
Post,
|
Post,
|
||||||
UnauthorizedException,
|
UnauthorizedException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { Note } from '../../../notes/note.entity';
|
|
||||||
import {
|
import {
|
||||||
AlreadyInDBError,
|
AlreadyInDBError,
|
||||||
ForbiddenIdError,
|
ForbiddenIdError,
|
||||||
NotInDBError,
|
NotInDBError,
|
||||||
} from '../../../errors/errors';
|
} from '../../../errors/errors';
|
||||||
import { NoteDto } from '../../../notes/note.dto';
|
|
||||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
|
||||||
import { NotesService } from '../../../notes/notes.service';
|
|
||||||
import { PermissionsService } from '../../../permissions/permissions.service';
|
|
||||||
import { HistoryService } from '../../../history/history.service';
|
import { HistoryService } from '../../../history/history.service';
|
||||||
import { UsersService } from '../../../users/users.service';
|
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||||
import { MediaUploadDto } from '../../../media/media-upload.dto';
|
import { MediaUploadDto } from '../../../media/media-upload.dto';
|
||||||
import { MediaService } from '../../../media/media.service';
|
import { MediaService } from '../../../media/media.service';
|
||||||
|
import { NoteDto } from '../../../notes/note.dto';
|
||||||
|
import { Note } from '../../../notes/note.entity';
|
||||||
|
import { NoteMediaDeletionDto } from '../../../notes/note.media-deletion.dto';
|
||||||
|
import { NotesService } from '../../../notes/notes.service';
|
||||||
|
import { PermissionsService } from '../../../permissions/permissions.service';
|
||||||
import { RevisionMetadataDto } from '../../../revisions/revision-metadata.dto';
|
import { RevisionMetadataDto } from '../../../revisions/revision-metadata.dto';
|
||||||
import { RevisionDto } from '../../../revisions/revision.dto';
|
import { RevisionDto } from '../../../revisions/revision.dto';
|
||||||
import { RevisionsService } from '../../../revisions/revisions.service';
|
import { RevisionsService } from '../../../revisions/revisions.service';
|
||||||
|
import { UsersService } from '../../../users/users.service';
|
||||||
import { MarkdownBody } from '../../utils/markdownbody-decorator';
|
import { MarkdownBody } from '../../utils/markdownbody-decorator';
|
||||||
import { NoteMediaDeletionDto } from '../../../notes/note.media-deletion.dto';
|
|
||||||
|
|
||||||
@Controller('notes')
|
@Controller('notes')
|
||||||
export class NotesController {
|
export class NotesController {
|
||||||
|
|
|
@ -3,23 +3,23 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { TokensController } from './tokens/tokens.controller';
|
|
||||||
import { LoggerModule } from '../../logger/logger.module';
|
|
||||||
import { UsersModule } from '../../users/users.module';
|
|
||||||
import { AuthModule } from '../../auth/auth.module';
|
import { AuthModule } from '../../auth/auth.module';
|
||||||
import { MeController } from './me/me.controller';
|
|
||||||
import { ConfigController } from './config/config.controller';
|
|
||||||
import { FrontendConfigModule } from '../../frontend-config/frontend-config.module';
|
import { FrontendConfigModule } from '../../frontend-config/frontend-config.module';
|
||||||
import { HistoryController } from './me/history/history.controller';
|
|
||||||
import { HistoryModule } from '../../history/history.module';
|
import { HistoryModule } from '../../history/history.module';
|
||||||
import { NotesModule } from '../../notes/notes.module';
|
import { LoggerModule } from '../../logger/logger.module';
|
||||||
import { MediaModule } from '../../media/media.module';
|
import { MediaModule } from '../../media/media.module';
|
||||||
import { MediaController } from './media/media.controller';
|
import { NotesModule } from '../../notes/notes.module';
|
||||||
import { NotesController } from './notes/notes.controller';
|
|
||||||
import { PermissionsModule } from '../../permissions/permissions.module';
|
import { PermissionsModule } from '../../permissions/permissions.module';
|
||||||
import { RevisionsModule } from '../../revisions/revisions.module';
|
import { RevisionsModule } from '../../revisions/revisions.module';
|
||||||
|
import { UsersModule } from '../../users/users.module';
|
||||||
|
import { ConfigController } from './config/config.controller';
|
||||||
|
import { HistoryController } from './me/history/history.controller';
|
||||||
|
import { MeController } from './me/me.controller';
|
||||||
|
import { MediaController } from './media/media.controller';
|
||||||
|
import { NotesController } from './notes/notes.controller';
|
||||||
|
import { TokensController } from './tokens/tokens.controller';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
|
|
@ -3,18 +3,18 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { Session } from '../../../users/session.entity';
|
|
||||||
import { TokensController } from './tokens.controller';
|
|
||||||
import { LoggerModule } from '../../../logger/logger.module';
|
|
||||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||||
import { Identity } from '../../../users/identity.entity';
|
|
||||||
import { User } from '../../../users/user.entity';
|
|
||||||
import { AuthToken } from '../../../auth/auth-token.entity';
|
import { AuthToken } from '../../../auth/auth-token.entity';
|
||||||
import { AuthModule } from '../../../auth/auth.module';
|
import { AuthModule } from '../../../auth/auth.module';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
|
import { LoggerModule } from '../../../logger/logger.module';
|
||||||
|
import { Identity } from '../../../users/identity.entity';
|
||||||
|
import { Session } from '../../../users/session.entity';
|
||||||
|
import { User } from '../../../users/user.entity';
|
||||||
|
import { TokensController } from './tokens.controller';
|
||||||
|
|
||||||
describe('TokensController', () => {
|
describe('TokensController', () => {
|
||||||
let controller: TokensController;
|
let controller: TokensController;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
|
@ -13,13 +12,14 @@ import {
|
||||||
Param,
|
Param,
|
||||||
Post,
|
Post,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
|
||||||
import { AuthService } from '../../../auth/auth.service';
|
|
||||||
import { TimestampMillis } from '../../../utils/timestamp';
|
|
||||||
import { AuthTokenDto } from '../../../auth/auth-token.dto';
|
|
||||||
import { AuthTokenWithSecretDto } from '../../../auth/auth-token-with-secret.dto';
|
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
|
|
||||||
|
import { AuthTokenWithSecretDto } from '../../../auth/auth-token-with-secret.dto';
|
||||||
|
import { AuthTokenDto } from '../../../auth/auth-token.dto';
|
||||||
|
import { AuthService } from '../../../auth/auth.service';
|
||||||
|
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||||
|
import { TimestampMillis } from '../../../utils/timestamp';
|
||||||
|
|
||||||
@ApiTags('tokens')
|
@ApiTags('tokens')
|
||||||
@Controller('tokens')
|
@Controller('tokens')
|
||||||
export class TokensController {
|
export class TokensController {
|
||||||
|
|
|
@ -3,36 +3,36 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import {
|
import {
|
||||||
getConnectionToken,
|
getConnectionToken,
|
||||||
getRepositoryToken,
|
getRepositoryToken,
|
||||||
TypeOrmModule,
|
TypeOrmModule,
|
||||||
} from '@nestjs/typeorm';
|
} from '@nestjs/typeorm';
|
||||||
|
|
||||||
|
import { AuthToken } from '../../../auth/auth-token.entity';
|
||||||
import { Author } from '../../../authors/author.entity';
|
import { Author } from '../../../authors/author.entity';
|
||||||
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
|
import { Group } from '../../../groups/group.entity';
|
||||||
|
import { HistoryEntry } from '../../../history/history-entry.entity';
|
||||||
import { HistoryModule } from '../../../history/history.module';
|
import { HistoryModule } from '../../../history/history.module';
|
||||||
import { LoggerModule } from '../../../logger/logger.module';
|
import { LoggerModule } from '../../../logger/logger.module';
|
||||||
|
import { MediaUpload } from '../../../media/media-upload.entity';
|
||||||
|
import { MediaModule } from '../../../media/media.module';
|
||||||
import { Note } from '../../../notes/note.entity';
|
import { Note } from '../../../notes/note.entity';
|
||||||
import { NotesModule } from '../../../notes/notes.module';
|
import { NotesModule } from '../../../notes/notes.module';
|
||||||
import { Tag } from '../../../notes/tag.entity';
|
import { Tag } from '../../../notes/tag.entity';
|
||||||
|
import { NoteGroupPermission } from '../../../permissions/note-group-permission.entity';
|
||||||
|
import { NoteUserPermission } from '../../../permissions/note-user-permission.entity';
|
||||||
import { Edit } from '../../../revisions/edit.entity';
|
import { Edit } from '../../../revisions/edit.entity';
|
||||||
import { Revision } from '../../../revisions/revision.entity';
|
import { Revision } from '../../../revisions/revision.entity';
|
||||||
import { AuthToken } from '../../../auth/auth-token.entity';
|
|
||||||
import { Identity } from '../../../users/identity.entity';
|
import { Identity } from '../../../users/identity.entity';
|
||||||
import { Session } from '../../../users/session.entity';
|
import { Session } from '../../../users/session.entity';
|
||||||
import { User } from '../../../users/user.entity';
|
import { User } from '../../../users/user.entity';
|
||||||
import { UsersModule } from '../../../users/users.module';
|
import { UsersModule } from '../../../users/users.module';
|
||||||
import { MeController } from './me.controller';
|
import { MeController } from './me.controller';
|
||||||
import { HistoryEntry } from '../../../history/history-entry.entity';
|
|
||||||
import { NoteGroupPermission } from '../../../permissions/note-group-permission.entity';
|
|
||||||
import { NoteUserPermission } from '../../../permissions/note-user-permission.entity';
|
|
||||||
import { Group } from '../../../groups/group.entity';
|
|
||||||
import { MediaModule } from '../../../media/media.module';
|
|
||||||
import { MediaUpload } from '../../../media/media-upload.entity';
|
|
||||||
import { ConfigModule } from '@nestjs/config';
|
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
|
||||||
|
|
||||||
describe('Me Controller', () => {
|
describe('Me Controller', () => {
|
||||||
let controller: MeController;
|
let controller: MeController;
|
||||||
|
|
|
@ -3,27 +3,19 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Get,
|
Get,
|
||||||
HttpCode,
|
HttpCode,
|
||||||
|
InternalServerErrorException,
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
Param,
|
Param,
|
||||||
Put,
|
Put,
|
||||||
UseGuards,
|
|
||||||
Req,
|
Req,
|
||||||
InternalServerErrorException,
|
UseGuards,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { HistoryEntryUpdateDto } from '../../../history/history-entry-update.dto';
|
|
||||||
import { HistoryService } from '../../../history/history.service';
|
|
||||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
|
||||||
import { NoteMetadataDto } from '../../../notes/note-metadata.dto';
|
|
||||||
import { NotesService } from '../../../notes/notes.service';
|
|
||||||
import { UsersService } from '../../../users/users.service';
|
|
||||||
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
|
||||||
import {
|
import {
|
||||||
ApiNoContentResponse,
|
ApiNoContentResponse,
|
||||||
ApiNotFoundResponse,
|
ApiNotFoundResponse,
|
||||||
|
@ -32,12 +24,20 @@ import {
|
||||||
ApiTags,
|
ApiTags,
|
||||||
ApiUnauthorizedResponse,
|
ApiUnauthorizedResponse,
|
||||||
} from '@nestjs/swagger';
|
} from '@nestjs/swagger';
|
||||||
import { HistoryEntryDto } from '../../../history/history-entry.dto';
|
|
||||||
import { UserInfoDto } from '../../../users/user-info.dto';
|
|
||||||
import { NotInDBError } from '../../../errors/errors';
|
|
||||||
import { Request } from 'express';
|
import { Request } from 'express';
|
||||||
import { MediaService } from '../../../media/media.service';
|
|
||||||
|
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
||||||
|
import { NotInDBError } from '../../../errors/errors';
|
||||||
|
import { HistoryEntryUpdateDto } from '../../../history/history-entry-update.dto';
|
||||||
|
import { HistoryEntryDto } from '../../../history/history-entry.dto';
|
||||||
|
import { HistoryService } from '../../../history/history.service';
|
||||||
|
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||||
import { MediaUploadDto } from '../../../media/media-upload.dto';
|
import { MediaUploadDto } from '../../../media/media-upload.dto';
|
||||||
|
import { MediaService } from '../../../media/media.service';
|
||||||
|
import { NoteMetadataDto } from '../../../notes/note-metadata.dto';
|
||||||
|
import { NotesService } from '../../../notes/notes.service';
|
||||||
|
import { UserInfoDto } from '../../../users/user-info.dto';
|
||||||
|
import { UsersService } from '../../../users/users.service';
|
||||||
import {
|
import {
|
||||||
notFoundDescription,
|
notFoundDescription,
|
||||||
successfullyDeletedDescription,
|
successfullyDeletedDescription,
|
||||||
|
|
|
@ -3,29 +3,29 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||||
|
|
||||||
|
import { AuthToken } from '../../../auth/auth-token.entity';
|
||||||
import { Author } from '../../../authors/author.entity';
|
import { Author } from '../../../authors/author.entity';
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
|
import { Group } from '../../../groups/group.entity';
|
||||||
import { LoggerModule } from '../../../logger/logger.module';
|
import { LoggerModule } from '../../../logger/logger.module';
|
||||||
import { MediaUpload } from '../../../media/media-upload.entity';
|
import { MediaUpload } from '../../../media/media-upload.entity';
|
||||||
import { MediaModule } from '../../../media/media.module';
|
import { MediaModule } from '../../../media/media.module';
|
||||||
import { Note } from '../../../notes/note.entity';
|
import { Note } from '../../../notes/note.entity';
|
||||||
import { NotesModule } from '../../../notes/notes.module';
|
import { NotesModule } from '../../../notes/notes.module';
|
||||||
import { Tag } from '../../../notes/tag.entity';
|
import { Tag } from '../../../notes/tag.entity';
|
||||||
|
import { NoteGroupPermission } from '../../../permissions/note-group-permission.entity';
|
||||||
|
import { NoteUserPermission } from '../../../permissions/note-user-permission.entity';
|
||||||
import { Edit } from '../../../revisions/edit.entity';
|
import { Edit } from '../../../revisions/edit.entity';
|
||||||
import { Revision } from '../../../revisions/revision.entity';
|
import { Revision } from '../../../revisions/revision.entity';
|
||||||
import { AuthToken } from '../../../auth/auth-token.entity';
|
|
||||||
import { Identity } from '../../../users/identity.entity';
|
import { Identity } from '../../../users/identity.entity';
|
||||||
import { Session } from '../../../users/session.entity';
|
import { Session } from '../../../users/session.entity';
|
||||||
import { User } from '../../../users/user.entity';
|
import { User } from '../../../users/user.entity';
|
||||||
import { MediaController } from './media.controller';
|
import { MediaController } from './media.controller';
|
||||||
import { NoteGroupPermission } from '../../../permissions/note-group-permission.entity';
|
|
||||||
import { NoteUserPermission } from '../../../permissions/note-user-permission.entity';
|
|
||||||
import { Group } from '../../../groups/group.entity';
|
|
||||||
|
|
||||||
describe('Media Controller', () => {
|
describe('Media Controller', () => {
|
||||||
let controller: MediaController;
|
let controller: MediaController;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
Controller,
|
Controller,
|
||||||
|
@ -21,17 +20,6 @@ import {
|
||||||
UseInterceptors,
|
UseInterceptors,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { FileInterceptor } from '@nestjs/platform-express';
|
import { FileInterceptor } from '@nestjs/platform-express';
|
||||||
import { Request } from 'express';
|
|
||||||
import {
|
|
||||||
ClientError,
|
|
||||||
MediaBackendError,
|
|
||||||
NotInDBError,
|
|
||||||
PermissionError,
|
|
||||||
} from '../../../errors/errors';
|
|
||||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
|
||||||
import { MediaService } from '../../../media/media.service';
|
|
||||||
import { MulterFile } from '../../../media/multer-file.interface';
|
|
||||||
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
|
||||||
import {
|
import {
|
||||||
ApiBody,
|
ApiBody,
|
||||||
ApiConsumes,
|
ApiConsumes,
|
||||||
|
@ -43,7 +31,19 @@ import {
|
||||||
ApiTags,
|
ApiTags,
|
||||||
ApiUnauthorizedResponse,
|
ApiUnauthorizedResponse,
|
||||||
} from '@nestjs/swagger';
|
} from '@nestjs/swagger';
|
||||||
|
import { Request } from 'express';
|
||||||
|
|
||||||
|
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
||||||
|
import {
|
||||||
|
ClientError,
|
||||||
|
MediaBackendError,
|
||||||
|
NotInDBError,
|
||||||
|
PermissionError,
|
||||||
|
} from '../../../errors/errors';
|
||||||
|
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||||
import { MediaUploadUrlDto } from '../../../media/media-upload-url.dto';
|
import { MediaUploadUrlDto } from '../../../media/media-upload-url.dto';
|
||||||
|
import { MediaService } from '../../../media/media.service';
|
||||||
|
import { MulterFile } from '../../../media/multer-file.interface';
|
||||||
import {
|
import {
|
||||||
forbiddenDescription,
|
forbiddenDescription,
|
||||||
successfullyDeletedDescription,
|
successfullyDeletedDescription,
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
|
||||||
import { MonitoringService } from '../../../monitoring/monitoring.service';
|
import { MonitoringService } from '../../../monitoring/monitoring.service';
|
||||||
import { MonitoringController } from './monitoring.controller';
|
import { MonitoringController } from './monitoring.controller';
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,7 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Controller, Get, UseGuards } from '@nestjs/common';
|
import { Controller, Get, UseGuards } from '@nestjs/common';
|
||||||
import { MonitoringService } from '../../../monitoring/monitoring.service';
|
|
||||||
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
|
||||||
import {
|
import {
|
||||||
ApiForbiddenResponse,
|
ApiForbiddenResponse,
|
||||||
ApiOkResponse,
|
ApiOkResponse,
|
||||||
|
@ -15,6 +12,9 @@ import {
|
||||||
ApiTags,
|
ApiTags,
|
||||||
ApiUnauthorizedResponse,
|
ApiUnauthorizedResponse,
|
||||||
} from '@nestjs/swagger';
|
} from '@nestjs/swagger';
|
||||||
|
|
||||||
|
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
||||||
|
import { MonitoringService } from '../../../monitoring/monitoring.service';
|
||||||
import { ServerStatusDto } from '../../../monitoring/server-status.dto';
|
import { ServerStatusDto } from '../../../monitoring/server-status.dto';
|
||||||
import {
|
import {
|
||||||
forbiddenDescription,
|
forbiddenDescription,
|
||||||
|
|
|
@ -3,39 +3,39 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import {
|
import {
|
||||||
getConnectionToken,
|
getConnectionToken,
|
||||||
getRepositoryToken,
|
getRepositoryToken,
|
||||||
TypeOrmModule,
|
TypeOrmModule,
|
||||||
} from '@nestjs/typeorm';
|
} from '@nestjs/typeorm';
|
||||||
|
|
||||||
|
import { AuthToken } from '../../../auth/auth-token.entity';
|
||||||
import { Author } from '../../../authors/author.entity';
|
import { Author } from '../../../authors/author.entity';
|
||||||
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
|
import { Group } from '../../../groups/group.entity';
|
||||||
|
import { GroupsModule } from '../../../groups/groups.module';
|
||||||
|
import { HistoryEntry } from '../../../history/history-entry.entity';
|
||||||
|
import { HistoryModule } from '../../../history/history.module';
|
||||||
import { LoggerModule } from '../../../logger/logger.module';
|
import { LoggerModule } from '../../../logger/logger.module';
|
||||||
|
import { MediaUpload } from '../../../media/media-upload.entity';
|
||||||
|
import { MediaModule } from '../../../media/media.module';
|
||||||
import { Note } from '../../../notes/note.entity';
|
import { Note } from '../../../notes/note.entity';
|
||||||
import { NotesService } from '../../../notes/notes.service';
|
import { NotesService } from '../../../notes/notes.service';
|
||||||
import { Tag } from '../../../notes/tag.entity';
|
import { Tag } from '../../../notes/tag.entity';
|
||||||
|
import { NoteGroupPermission } from '../../../permissions/note-group-permission.entity';
|
||||||
|
import { NoteUserPermission } from '../../../permissions/note-user-permission.entity';
|
||||||
|
import { PermissionsModule } from '../../../permissions/permissions.module';
|
||||||
import { Edit } from '../../../revisions/edit.entity';
|
import { Edit } from '../../../revisions/edit.entity';
|
||||||
import { Revision } from '../../../revisions/revision.entity';
|
import { Revision } from '../../../revisions/revision.entity';
|
||||||
import { RevisionsModule } from '../../../revisions/revisions.module';
|
import { RevisionsModule } from '../../../revisions/revisions.module';
|
||||||
import { AuthToken } from '../../../auth/auth-token.entity';
|
|
||||||
import { Identity } from '../../../users/identity.entity';
|
import { Identity } from '../../../users/identity.entity';
|
||||||
import { Session } from '../../../users/session.entity';
|
import { Session } from '../../../users/session.entity';
|
||||||
import { User } from '../../../users/user.entity';
|
import { User } from '../../../users/user.entity';
|
||||||
import { UsersModule } from '../../../users/users.module';
|
import { UsersModule } from '../../../users/users.module';
|
||||||
import { NotesController } from './notes.controller';
|
import { NotesController } from './notes.controller';
|
||||||
import { PermissionsModule } from '../../../permissions/permissions.module';
|
|
||||||
import { HistoryModule } from '../../../history/history.module';
|
|
||||||
import { HistoryEntry } from '../../../history/history-entry.entity';
|
|
||||||
import { NoteGroupPermission } from '../../../permissions/note-group-permission.entity';
|
|
||||||
import { NoteUserPermission } from '../../../permissions/note-user-permission.entity';
|
|
||||||
import { Group } from '../../../groups/group.entity';
|
|
||||||
import { GroupsModule } from '../../../groups/groups.module';
|
|
||||||
import { ConfigModule } from '@nestjs/config';
|
|
||||||
import { MediaModule } from '../../../media/media.module';
|
|
||||||
import { MediaUpload } from '../../../media/media-upload.entity';
|
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
|
||||||
|
|
||||||
describe('Notes Controller', () => {
|
describe('Notes Controller', () => {
|
||||||
let controller: NotesController;
|
let controller: NotesController;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
Body,
|
Body,
|
||||||
|
@ -21,22 +20,6 @@ import {
|
||||||
UnauthorizedException,
|
UnauthorizedException,
|
||||||
UseGuards,
|
UseGuards,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import {
|
|
||||||
AlreadyInDBError,
|
|
||||||
ForbiddenIdError,
|
|
||||||
NotInDBError,
|
|
||||||
PermissionsUpdateInconsistentError,
|
|
||||||
} from '../../../errors/errors';
|
|
||||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
|
||||||
import {
|
|
||||||
NotePermissionsDto,
|
|
||||||
NotePermissionsUpdateDto,
|
|
||||||
} from '../../../notes/note-permissions.dto';
|
|
||||||
import { NotesService } from '../../../notes/notes.service';
|
|
||||||
import { RevisionsService } from '../../../revisions/revisions.service';
|
|
||||||
import { FullApi } from '../../utils/fullapi-decorator';
|
|
||||||
import { MarkdownBody } from '../../utils/markdownbody-decorator';
|
|
||||||
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
|
||||||
import {
|
import {
|
||||||
ApiCreatedResponse,
|
ApiCreatedResponse,
|
||||||
ApiForbiddenResponse,
|
ApiForbiddenResponse,
|
||||||
|
@ -47,22 +30,39 @@ import {
|
||||||
ApiTags,
|
ApiTags,
|
||||||
ApiUnauthorizedResponse,
|
ApiUnauthorizedResponse,
|
||||||
} from '@nestjs/swagger';
|
} from '@nestjs/swagger';
|
||||||
|
import { Request } from 'express';
|
||||||
|
|
||||||
|
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
||||||
|
import {
|
||||||
|
AlreadyInDBError,
|
||||||
|
ForbiddenIdError,
|
||||||
|
NotInDBError,
|
||||||
|
PermissionsUpdateInconsistentError,
|
||||||
|
} from '../../../errors/errors';
|
||||||
import { HistoryService } from '../../../history/history.service';
|
import { HistoryService } from '../../../history/history.service';
|
||||||
import { NoteDto } from '../../../notes/note.dto';
|
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||||
|
import { MediaUploadDto } from '../../../media/media-upload.dto';
|
||||||
|
import { MediaService } from '../../../media/media.service';
|
||||||
import { NoteMetadataDto } from '../../../notes/note-metadata.dto';
|
import { NoteMetadataDto } from '../../../notes/note-metadata.dto';
|
||||||
|
import {
|
||||||
|
NotePermissionsDto,
|
||||||
|
NotePermissionsUpdateDto,
|
||||||
|
} from '../../../notes/note-permissions.dto';
|
||||||
|
import { NoteDto } from '../../../notes/note.dto';
|
||||||
|
import { Note } from '../../../notes/note.entity';
|
||||||
|
import { NoteMediaDeletionDto } from '../../../notes/note.media-deletion.dto';
|
||||||
|
import { NotesService } from '../../../notes/notes.service';
|
||||||
|
import { PermissionsService } from '../../../permissions/permissions.service';
|
||||||
import { RevisionMetadataDto } from '../../../revisions/revision-metadata.dto';
|
import { RevisionMetadataDto } from '../../../revisions/revision-metadata.dto';
|
||||||
import { RevisionDto } from '../../../revisions/revision.dto';
|
import { RevisionDto } from '../../../revisions/revision.dto';
|
||||||
import { PermissionsService } from '../../../permissions/permissions.service';
|
import { RevisionsService } from '../../../revisions/revisions.service';
|
||||||
import { Note } from '../../../notes/note.entity';
|
|
||||||
import { Request } from 'express';
|
|
||||||
import {
|
import {
|
||||||
forbiddenDescription,
|
forbiddenDescription,
|
||||||
successfullyDeletedDescription,
|
successfullyDeletedDescription,
|
||||||
unauthorizedDescription,
|
unauthorizedDescription,
|
||||||
} from '../../utils/descriptions';
|
} from '../../utils/descriptions';
|
||||||
import { MediaUploadDto } from '../../../media/media-upload.dto';
|
import { FullApi } from '../../utils/fullapi-decorator';
|
||||||
import { MediaService } from '../../../media/media.service';
|
import { MarkdownBody } from '../../utils/markdownbody-decorator';
|
||||||
import { NoteMediaDeletionDto } from '../../../notes/note.media-deletion.dto';
|
|
||||||
|
|
||||||
@ApiTags('notes')
|
@ApiTags('notes')
|
||||||
@ApiSecurity('token')
|
@ApiSecurity('token')
|
||||||
|
|
|
@ -3,20 +3,20 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
import { HistoryModule } from '../../history/history.module';
|
import { HistoryModule } from '../../history/history.module';
|
||||||
import { LoggerModule } from '../../logger/logger.module';
|
import { LoggerModule } from '../../logger/logger.module';
|
||||||
import { MediaModule } from '../../media/media.module';
|
import { MediaModule } from '../../media/media.module';
|
||||||
import { MonitoringModule } from '../../monitoring/monitoring.module';
|
import { MonitoringModule } from '../../monitoring/monitoring.module';
|
||||||
import { NotesModule } from '../../notes/notes.module';
|
import { NotesModule } from '../../notes/notes.module';
|
||||||
|
import { PermissionsModule } from '../../permissions/permissions.module';
|
||||||
import { RevisionsModule } from '../../revisions/revisions.module';
|
import { RevisionsModule } from '../../revisions/revisions.module';
|
||||||
import { UsersModule } from '../../users/users.module';
|
import { UsersModule } from '../../users/users.module';
|
||||||
import { MeController } from './me/me.controller';
|
import { MeController } from './me/me.controller';
|
||||||
import { NotesController } from './notes/notes.controller';
|
|
||||||
import { MediaController } from './media/media.controller';
|
import { MediaController } from './media/media.controller';
|
||||||
import { MonitoringController } from './monitoring/monitoring.controller';
|
import { MonitoringController } from './monitoring/monitoring.controller';
|
||||||
import { PermissionsModule } from '../../permissions/permissions.module';
|
import { NotesController } from './notes/notes.controller';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { applyDecorators } from '@nestjs/common';
|
import { applyDecorators } from '@nestjs/common';
|
||||||
import {
|
import {
|
||||||
ApiForbiddenResponse,
|
ApiForbiddenResponse,
|
||||||
ApiNotFoundResponse,
|
ApiNotFoundResponse,
|
||||||
ApiUnauthorizedResponse,
|
ApiUnauthorizedResponse,
|
||||||
} from '@nestjs/swagger';
|
} from '@nestjs/swagger';
|
||||||
|
|
||||||
import { forbiddenDescription, notFoundDescription } from './descriptions';
|
import { forbiddenDescription, notFoundDescription } from './descriptions';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
createParamDecorator,
|
createParamDecorator,
|
||||||
|
|
|
@ -3,12 +3,26 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
|
import { ScheduleModule } from '@nestjs/schedule';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
import { RouterModule, Routes } from 'nest-router';
|
||||||
|
|
||||||
|
import { PrivateApiModule } from './api/private/private-api.module';
|
||||||
import { PublicApiModule } from './api/public/public-api.module';
|
import { PublicApiModule } from './api/public/public-api.module';
|
||||||
|
import { AuthModule } from './auth/auth.module';
|
||||||
import { AuthorsModule } from './authors/authors.module';
|
import { AuthorsModule } from './authors/authors.module';
|
||||||
|
import appConfig from './config/app.config';
|
||||||
|
import authConfig from './config/auth.config';
|
||||||
|
import cspConfig from './config/csp.config';
|
||||||
|
import customizationConfig from './config/customization.config';
|
||||||
|
import databaseConfig from './config/database.config';
|
||||||
|
import externalConfig from './config/external-services.config';
|
||||||
|
import hstsConfig from './config/hsts.config';
|
||||||
|
import mediaConfig from './config/media.config';
|
||||||
|
import { FrontendConfigModule } from './frontend-config/frontend-config.module';
|
||||||
|
import { FrontendConfigService } from './frontend-config/frontend-config.service';
|
||||||
import { GroupsModule } from './groups/groups.module';
|
import { GroupsModule } from './groups/groups.module';
|
||||||
import { HistoryModule } from './history/history.module';
|
import { HistoryModule } from './history/history.module';
|
||||||
import { LoggerModule } from './logger/logger.module';
|
import { LoggerModule } from './logger/logger.module';
|
||||||
|
@ -18,20 +32,6 @@ import { NotesModule } from './notes/notes.module';
|
||||||
import { PermissionsModule } from './permissions/permissions.module';
|
import { PermissionsModule } from './permissions/permissions.module';
|
||||||
import { RevisionsModule } from './revisions/revisions.module';
|
import { RevisionsModule } from './revisions/revisions.module';
|
||||||
import { UsersModule } from './users/users.module';
|
import { UsersModule } from './users/users.module';
|
||||||
import { AuthModule } from './auth/auth.module';
|
|
||||||
import appConfig from './config/app.config';
|
|
||||||
import mediaConfig from './config/media.config';
|
|
||||||
import hstsConfig from './config/hsts.config';
|
|
||||||
import cspConfig from './config/csp.config';
|
|
||||||
import databaseConfig from './config/database.config';
|
|
||||||
import authConfig from './config/auth.config';
|
|
||||||
import customizationConfig from './config/customization.config';
|
|
||||||
import externalConfig from './config/external-services.config';
|
|
||||||
import { PrivateApiModule } from './api/private/private-api.module';
|
|
||||||
import { ScheduleModule } from '@nestjs/schedule';
|
|
||||||
import { RouterModule, Routes } from 'nest-router';
|
|
||||||
import { FrontendConfigService } from './frontend-config/frontend-config.service';
|
|
||||||
import { FrontendConfigModule } from './frontend-config/frontend-config.module';
|
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IsString } from 'class-validator';
|
import { IsString } from 'class-validator';
|
||||||
|
|
||||||
import { AuthTokenDto } from './auth-token.dto';
|
import { AuthTokenDto } from './auth-token.dto';
|
||||||
|
|
||||||
export class AuthTokenWithSecretDto extends AuthTokenDto {
|
export class AuthTokenWithSecretDto extends AuthTokenDto {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IsDate, IsOptional, IsString } from 'class-validator';
|
import { IsDate, IsOptional, IsString } from 'class-validator';
|
||||||
|
|
||||||
export class AuthTokenDto {
|
export class AuthTokenDto {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Column,
|
Column,
|
||||||
CreateDateColumn,
|
CreateDateColumn,
|
||||||
|
@ -11,6 +10,7 @@ import {
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
PrimaryGeneratedColumn,
|
PrimaryGeneratedColumn,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
|
||||||
import { User } from '../users/user.entity';
|
import { User } from '../users/user.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { AuthService } from './auth.service';
|
|
||||||
import { UsersModule } from '../users/users.module';
|
|
||||||
import { PassportModule } from '@nestjs/passport';
|
import { PassportModule } from '@nestjs/passport';
|
||||||
import { TokenStrategy } from './token.strategy';
|
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
|
||||||
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
|
import { UsersModule } from '../users/users.module';
|
||||||
import { AuthToken } from './auth-token.entity';
|
import { AuthToken } from './auth-token.entity';
|
||||||
|
import { AuthService } from './auth.service';
|
||||||
|
import { TokenStrategy } from './token.strategy';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
|
|
@ -3,22 +3,22 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { Session } from '../users/session.entity';
|
|
||||||
import { AuthService } from './auth.service';
|
|
||||||
import { PassportModule } from '@nestjs/passport';
|
import { PassportModule } from '@nestjs/passport';
|
||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||||
|
import { randomBytes } from 'crypto';
|
||||||
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
|
import appConfigMock from '../config/mock/app.config.mock';
|
||||||
|
import { NotInDBError, TokenNotValidError } from '../errors/errors';
|
||||||
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
|
import { Identity } from '../users/identity.entity';
|
||||||
|
import { Session } from '../users/session.entity';
|
||||||
import { User } from '../users/user.entity';
|
import { User } from '../users/user.entity';
|
||||||
import { UsersModule } from '../users/users.module';
|
import { UsersModule } from '../users/users.module';
|
||||||
import { Identity } from '../users/identity.entity';
|
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
|
||||||
import { AuthToken } from './auth-token.entity';
|
import { AuthToken } from './auth-token.entity';
|
||||||
import { NotInDBError, TokenNotValidError } from '../errors/errors';
|
import { AuthService } from './auth.service';
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { ConfigModule } from '@nestjs/config';
|
|
||||||
import appConfigMock from '../config/mock/app.config.mock';
|
|
||||||
import { randomBytes } from 'crypto';
|
|
||||||
|
|
||||||
describe('AuthService', () => {
|
describe('AuthService', () => {
|
||||||
let service: AuthService;
|
let service: AuthService;
|
||||||
|
|
|
@ -3,25 +3,25 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { UsersService } from '../users/users.service';
|
import { Cron, Timeout } from '@nestjs/schedule';
|
||||||
import { User } from '../users/user.entity';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { AuthToken } from './auth-token.entity';
|
|
||||||
import { AuthTokenDto } from './auth-token.dto';
|
|
||||||
import { AuthTokenWithSecretDto } from './auth-token-with-secret.dto';
|
|
||||||
import { compare, hash } from 'bcrypt';
|
import { compare, hash } from 'bcrypt';
|
||||||
|
import { randomBytes } from 'crypto';
|
||||||
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
NotInDBError,
|
NotInDBError,
|
||||||
TokenNotValidError,
|
TokenNotValidError,
|
||||||
TooManyTokensError,
|
TooManyTokensError,
|
||||||
} from '../errors/errors';
|
} from '../errors/errors';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
||||||
|
import { User } from '../users/user.entity';
|
||||||
|
import { UsersService } from '../users/users.service';
|
||||||
import { TimestampMillis } from '../utils/timestamp';
|
import { TimestampMillis } from '../utils/timestamp';
|
||||||
import { Cron, Timeout } from '@nestjs/schedule';
|
import { AuthTokenWithSecretDto } from './auth-token-with-secret.dto';
|
||||||
import { randomBytes } from 'crypto';
|
import { AuthTokenDto } from './auth-token.dto';
|
||||||
|
import { AuthToken } from './auth-token.entity';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthService {
|
export class AuthService {
|
||||||
|
|
|
@ -3,15 +3,16 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ExecutionContext, Injectable } from '@nestjs/common';
|
import { ExecutionContext, Injectable } from '@nestjs/common';
|
||||||
import { UsersService } from '../users/users.service';
|
|
||||||
import { User } from '../users/user.entity';
|
|
||||||
import { Request } from 'express';
|
import { Request } from 'express';
|
||||||
|
|
||||||
|
import { User } from '../users/user.entity';
|
||||||
|
import { UsersService } from '../users/users.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MockAuthGuard {
|
export class MockAuthGuard {
|
||||||
private user: User;
|
private user: User;
|
||||||
|
|
||||||
constructor(private usersService: UsersService) {}
|
constructor(private usersService: UsersService) {}
|
||||||
|
|
||||||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
async canActivate(context: ExecutionContext): Promise<boolean> {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Strategy } from 'passport-http-bearer';
|
|
||||||
import { PassportStrategy } from '@nestjs/passport';
|
|
||||||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||||
import { AuthService } from './auth.service';
|
import { PassportStrategy } from '@nestjs/passport';
|
||||||
import { User } from '../users/user.entity';
|
import { Strategy } from 'passport-http-bearer';
|
||||||
|
|
||||||
import { NotInDBError, TokenNotValidError } from '../errors/errors';
|
import { NotInDBError, TokenNotValidError } from '../errors/errors';
|
||||||
|
import { User } from '../users/user.entity';
|
||||||
|
import { AuthService } from './auth.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TokenStrategy extends PassportStrategy(Strategy, 'token') {
|
export class TokenStrategy extends PassportStrategy(Strategy, 'token') {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Column,
|
Column,
|
||||||
Entity,
|
Entity,
|
||||||
|
@ -11,6 +10,7 @@ import {
|
||||||
OneToMany,
|
OneToMany,
|
||||||
PrimaryGeneratedColumn,
|
PrimaryGeneratedColumn,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
|
||||||
import { Edit } from '../revisions/edit.entity';
|
import { Edit } from '../revisions/edit.entity';
|
||||||
import { Session } from '../users/session.entity';
|
import { Session } from '../users/session.entity';
|
||||||
import { User } from '../users/user.entity';
|
import { User } from '../users/user.entity';
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
|
||||||
import { Author } from './author.entity';
|
import { Author } from './author.entity';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
import * as Joi from 'joi';
|
import * as Joi from 'joi';
|
||||||
|
|
||||||
import { Loglevel } from './loglevel.enum';
|
import { Loglevel } from './loglevel.enum';
|
||||||
import { buildErrorMessage, parseOptionalInt, toArrayConfig } from './utils';
|
import { buildErrorMessage, parseOptionalInt, toArrayConfig } from './utils';
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { registerAs } from '@nestjs/config';
|
||||||
import * as Joi from 'joi';
|
import * as Joi from 'joi';
|
||||||
|
|
||||||
import { GitlabScope, GitlabVersion } from './gitlab.enum';
|
import { GitlabScope, GitlabVersion } from './gitlab.enum';
|
||||||
import {
|
import {
|
||||||
buildErrorMessage,
|
buildErrorMessage,
|
||||||
replaceAuthErrorsWithEnvironmentVariables,
|
replaceAuthErrorsWithEnvironmentVariables,
|
||||||
toArrayConfig,
|
toArrayConfig,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import { registerAs } from '@nestjs/config';
|
|
||||||
|
|
||||||
export interface AuthConfig {
|
export interface AuthConfig {
|
||||||
email: {
|
email: {
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as Joi from 'joi';
|
|
||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
|
import * as Joi from 'joi';
|
||||||
|
|
||||||
import { buildErrorMessage } from './utils';
|
import { buildErrorMessage } from './utils';
|
||||||
|
|
||||||
export interface CspConfig {
|
export interface CspConfig {
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
import * as Joi from 'joi';
|
import * as Joi from 'joi';
|
||||||
|
|
||||||
import { buildErrorMessage } from './utils';
|
import { buildErrorMessage } from './utils';
|
||||||
|
|
||||||
export interface CustomizationConfig {
|
export interface CustomizationConfig {
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as Joi from 'joi';
|
|
||||||
import { DatabaseDialect } from './database-dialect.enum';
|
|
||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
|
import * as Joi from 'joi';
|
||||||
|
|
||||||
|
import { DatabaseDialect } from './database-dialect.enum';
|
||||||
import { buildErrorMessage, parseOptionalInt } from './utils';
|
import { buildErrorMessage, parseOptionalInt } from './utils';
|
||||||
|
|
||||||
export interface DatabaseConfig {
|
export interface DatabaseConfig {
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
import * as Joi from 'joi';
|
import * as Joi from 'joi';
|
||||||
|
|
||||||
import { buildErrorMessage } from './utils';
|
import { buildErrorMessage } from './utils';
|
||||||
|
|
||||||
export interface ExternalServicesConfig {
|
export interface ExternalServicesConfig {
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as Joi from 'joi';
|
|
||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
|
import * as Joi from 'joi';
|
||||||
|
|
||||||
import { buildErrorMessage, parseOptionalInt } from './utils';
|
import { buildErrorMessage, parseOptionalInt } from './utils';
|
||||||
|
|
||||||
export interface HstsConfig {
|
export interface HstsConfig {
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as Joi from 'joi';
|
|
||||||
import { BackendType } from '../media/backends/backend-type.enum';
|
|
||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
|
import * as Joi from 'joi';
|
||||||
|
|
||||||
|
import { BackendType } from '../media/backends/backend-type.enum';
|
||||||
import { buildErrorMessage } from './utils';
|
import { buildErrorMessage } from './utils';
|
||||||
|
|
||||||
export interface MediaConfig {
|
export interface MediaConfig {
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
|
|
||||||
import { Loglevel } from '../loglevel.enum';
|
import { Loglevel } from '../loglevel.enum';
|
||||||
|
|
||||||
export default registerAs('appConfig', () => ({
|
export default registerAs('appConfig', () => ({
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
|
|
||||||
export default registerAs('authConfig', () => ({
|
export default registerAs('authConfig', () => ({
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
|
|
||||||
export default registerAs('customizationConfig', () => ({
|
export default registerAs('customizationConfig', () => ({
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
|
|
||||||
export default registerAs('externalServicesConfig', () => ({
|
export default registerAs('externalServicesConfig', () => ({
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
|
|
||||||
export default registerAs('mediaConfig', () => ({
|
export default registerAs('mediaConfig', () => ({
|
||||||
|
|
|
@ -3,14 +3,13 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { Loglevel } from './loglevel.enum';
|
||||||
import {
|
import {
|
||||||
needToLog,
|
needToLog,
|
||||||
parseOptionalInt,
|
parseOptionalInt,
|
||||||
replaceAuthErrorsWithEnvironmentVariables,
|
replaceAuthErrorsWithEnvironmentVariables,
|
||||||
toArrayConfig,
|
toArrayConfig,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import { Loglevel } from './loglevel.enum';
|
|
||||||
|
|
||||||
describe('config utils', () => {
|
describe('config utils', () => {
|
||||||
describe('toArrayConfig', () => {
|
describe('toArrayConfig', () => {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Loglevel } from './loglevel.enum';
|
import { Loglevel } from './loglevel.enum';
|
||||||
|
|
||||||
export function toArrayConfig(configValue?: string, separator = ','): string[] {
|
export function toArrayConfig(configValue?: string, separator = ','): string[] {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IsArray,
|
IsArray,
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
|
@ -13,6 +12,7 @@ import {
|
||||||
IsUrl,
|
IsUrl,
|
||||||
ValidateNested,
|
ValidateNested,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
|
|
||||||
import { ServerVersion } from '../monitoring/server-status.dto';
|
import { ServerVersion } from '../monitoring/server-status.dto';
|
||||||
|
|
||||||
export class AuthProviders {
|
export class AuthProviders {
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
|
|
||||||
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
import { FrontendConfigService } from './frontend-config.service';
|
import { FrontendConfigService } from './frontend-config.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
|
|
|
@ -3,18 +3,18 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { FrontendConfigService } from './frontend-config.service';
|
|
||||||
import { ConfigModule, registerAs } from '@nestjs/config';
|
import { ConfigModule, registerAs } from '@nestjs/config';
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { AuthConfig } from '../config/auth.config';
|
|
||||||
import { GitlabScope, GitlabVersion } from '../config/gitlab.enum';
|
|
||||||
import { getServerVersionFromPackageJson } from '../utils/serverVersion';
|
|
||||||
import { CustomizationConfig } from '../config/customization.config';
|
|
||||||
import { AppConfig } from '../config/app.config';
|
import { AppConfig } from '../config/app.config';
|
||||||
|
import { AuthConfig } from '../config/auth.config';
|
||||||
|
import { CustomizationConfig } from '../config/customization.config';
|
||||||
import { ExternalServicesConfig } from '../config/external-services.config';
|
import { ExternalServicesConfig } from '../config/external-services.config';
|
||||||
|
import { GitlabScope, GitlabVersion } from '../config/gitlab.enum';
|
||||||
import { Loglevel } from '../config/loglevel.enum';
|
import { Loglevel } from '../config/loglevel.enum';
|
||||||
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
|
import { getServerVersionFromPackageJson } from '../utils/serverVersion';
|
||||||
|
import { FrontendConfigService } from './frontend-config.service';
|
||||||
|
|
||||||
/* eslint-disable
|
/* eslint-disable
|
||||||
jest/no-conditional-expect
|
jest/no-conditional-expect
|
||||||
|
|
|
@ -3,9 +3,18 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
|
import appConfiguration, { AppConfig } from '../config/app.config';
|
||||||
|
import authConfiguration, { AuthConfig } from '../config/auth.config';
|
||||||
|
import customizationConfiguration, {
|
||||||
|
CustomizationConfig,
|
||||||
|
} from '../config/customization.config';
|
||||||
|
import externalServicesConfiguration, {
|
||||||
|
ExternalServicesConfig,
|
||||||
|
} from '../config/external-services.config';
|
||||||
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
||||||
|
import { getServerVersionFromPackageJson } from '../utils/serverVersion';
|
||||||
import {
|
import {
|
||||||
AuthProviders,
|
AuthProviders,
|
||||||
BrandingDto,
|
BrandingDto,
|
||||||
|
@ -14,15 +23,6 @@ import {
|
||||||
IframeCommunicationDto,
|
IframeCommunicationDto,
|
||||||
SpecialUrlsDto,
|
SpecialUrlsDto,
|
||||||
} from './frontend-config.dto';
|
} from './frontend-config.dto';
|
||||||
import authConfiguration, { AuthConfig } from '../config/auth.config';
|
|
||||||
import customizationConfiguration, {
|
|
||||||
CustomizationConfig,
|
|
||||||
} from '../config/customization.config';
|
|
||||||
import appConfiguration, { AppConfig } from '../config/app.config';
|
|
||||||
import externalServicesConfiguration, {
|
|
||||||
ExternalServicesConfig,
|
|
||||||
} from '../config/external-services.config';
|
|
||||||
import { getServerVersionFromPackageJson } from '../utils/serverVersion';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FrontendConfigService {
|
export class FrontendConfigService {
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
import { IsBoolean, IsString } from 'class-validator';
|
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsBoolean, IsString } from 'class-validator';
|
||||||
|
|
||||||
export class GroupInfoDto {
|
export class GroupInfoDto {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Column,
|
Column,
|
||||||
Entity,
|
Entity,
|
||||||
|
@ -11,6 +10,7 @@ import {
|
||||||
ManyToMany,
|
ManyToMany,
|
||||||
PrimaryGeneratedColumn,
|
PrimaryGeneratedColumn,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
|
||||||
import { User } from '../users/user.entity';
|
import { User } from '../users/user.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
|
||||||
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
import { Group } from './group.entity';
|
import { Group } from './group.entity';
|
||||||
import { GroupsService } from './groups.service';
|
import { GroupsService } from './groups.service';
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TypeOrmModule.forFeature([Group]), LoggerModule],
|
imports: [TypeOrmModule.forFeature([Group]), LoggerModule],
|
||||||
|
|
|
@ -3,16 +3,16 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { GroupsService } from './groups.service';
|
|
||||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import { Group } from './group.entity';
|
|
||||||
|
import appConfigMock from '../config/mock/app.config.mock';
|
||||||
import { NotInDBError } from '../errors/errors';
|
import { NotInDBError } from '../errors/errors';
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { Group } from './group.entity';
|
||||||
import appConfigMock from '../config/mock/app.config.mock';
|
import { GroupsService } from './groups.service';
|
||||||
|
|
||||||
describe('GroupsService', () => {
|
describe('GroupsService', () => {
|
||||||
let service: GroupsService;
|
let service: GroupsService;
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import { Group } from './group.entity';
|
|
||||||
import { NotInDBError } from '../errors/errors';
|
import { NotInDBError } from '../errors/errors';
|
||||||
|
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
||||||
import { GroupInfoDto } from './group-info.dto';
|
import { GroupInfoDto } from './group-info.dto';
|
||||||
|
import { Group } from './group.entity';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GroupsService {
|
export class GroupsService {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IsBoolean, IsDate, IsString } from 'class-validator';
|
import { IsBoolean, IsDate, IsString } from 'class-validator';
|
||||||
|
|
||||||
export class HistoryEntryImportDto {
|
export class HistoryEntryImportDto {
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IsBoolean } from 'class-validator';
|
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsBoolean } from 'class-validator';
|
||||||
|
|
||||||
export class HistoryEntryUpdateDto {
|
export class HistoryEntryUpdateDto {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IsArray, IsBoolean, IsDate, IsString } from 'class-validator';
|
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsArray, IsBoolean, IsDate, IsString } from 'class-validator';
|
||||||
|
|
||||||
export class HistoryEntryDto {
|
export class HistoryEntryDto {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, ManyToOne, UpdateDateColumn } from 'typeorm';
|
import { Column, Entity, ManyToOne, UpdateDateColumn } from 'typeorm';
|
||||||
import { User } from '../users/user.entity';
|
|
||||||
import { Note } from '../notes/note.entity';
|
import { Note } from '../notes/note.entity';
|
||||||
|
import { User } from '../users/user.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class HistoryEntry {
|
export class HistoryEntry {
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
|
||||||
import { HistoryService } from './history.service';
|
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
||||||
import { HistoryEntry } from './history-entry.entity';
|
|
||||||
import { UsersModule } from '../users/users.module';
|
|
||||||
import { NotesModule } from '../notes/notes.module';
|
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
|
||||||
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
|
import { NotesModule } from '../notes/notes.module';
|
||||||
|
import { UsersModule } from '../users/users.module';
|
||||||
|
import { HistoryEntry } from './history-entry.entity';
|
||||||
|
import { HistoryService } from './history.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
providers: [HistoryService],
|
providers: [HistoryService],
|
||||||
|
|
|
@ -3,31 +3,31 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { Author } from '../authors/author.entity';
|
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
|
||||||
import { Session } from '../users/session.entity';
|
|
||||||
import { HistoryService } from './history.service';
|
|
||||||
import { UsersModule } from '../users/users.module';
|
|
||||||
import { NotesModule } from '../notes/notes.module';
|
|
||||||
import { getConnectionToken, getRepositoryToken } from '@nestjs/typeorm';
|
import { getConnectionToken, getRepositoryToken } from '@nestjs/typeorm';
|
||||||
import { Identity } from '../users/identity.entity';
|
|
||||||
import { User } from '../users/user.entity';
|
|
||||||
import { Edit } from '../revisions/edit.entity';
|
|
||||||
import { HistoryEntry } from './history-entry.entity';
|
|
||||||
import { Note } from '../notes/note.entity';
|
|
||||||
import { Tag } from '../notes/tag.entity';
|
|
||||||
import { AuthToken } from '../auth/auth-token.entity';
|
|
||||||
import { Revision } from '../revisions/revision.entity';
|
|
||||||
import { Connection, Repository } from 'typeorm';
|
import { Connection, Repository } from 'typeorm';
|
||||||
|
|
||||||
|
import { AuthToken } from '../auth/auth-token.entity';
|
||||||
|
import { Author } from '../authors/author.entity';
|
||||||
|
import appConfigMock from '../config/mock/app.config.mock';
|
||||||
import { NotInDBError } from '../errors/errors';
|
import { NotInDBError } from '../errors/errors';
|
||||||
|
import { Group } from '../groups/group.entity';
|
||||||
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
|
import { Note } from '../notes/note.entity';
|
||||||
|
import { NotesModule } from '../notes/notes.module';
|
||||||
|
import { Tag } from '../notes/tag.entity';
|
||||||
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
||||||
import { NoteUserPermission } from '../permissions/note-user-permission.entity';
|
import { NoteUserPermission } from '../permissions/note-user-permission.entity';
|
||||||
import { Group } from '../groups/group.entity';
|
import { Edit } from '../revisions/edit.entity';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { Revision } from '../revisions/revision.entity';
|
||||||
import appConfigMock from '../config/mock/app.config.mock';
|
import { Identity } from '../users/identity.entity';
|
||||||
|
import { Session } from '../users/session.entity';
|
||||||
|
import { User } from '../users/user.entity';
|
||||||
|
import { UsersModule } from '../users/users.module';
|
||||||
import { HistoryEntryImportDto } from './history-entry-import.dto';
|
import { HistoryEntryImportDto } from './history-entry-import.dto';
|
||||||
|
import { HistoryEntry } from './history-entry.entity';
|
||||||
|
import { HistoryService } from './history.service';
|
||||||
|
|
||||||
describe('HistoryService', () => {
|
describe('HistoryService', () => {
|
||||||
let service: HistoryService;
|
let service: HistoryService;
|
||||||
|
|
|
@ -3,20 +3,20 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
|
||||||
import { HistoryEntryUpdateDto } from './history-entry-update.dto';
|
|
||||||
import { HistoryEntryDto } from './history-entry.dto';
|
|
||||||
import { InjectConnection, InjectRepository } from '@nestjs/typeorm';
|
import { InjectConnection, InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Connection, Repository } from 'typeorm';
|
import { Connection, Repository } from 'typeorm';
|
||||||
import { HistoryEntry } from './history-entry.entity';
|
|
||||||
import { UsersService } from '../users/users.service';
|
import { NotInDBError } from '../errors/errors';
|
||||||
|
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
||||||
|
import { Note } from '../notes/note.entity';
|
||||||
import { NotesService } from '../notes/notes.service';
|
import { NotesService } from '../notes/notes.service';
|
||||||
import { User } from '../users/user.entity';
|
import { User } from '../users/user.entity';
|
||||||
import { Note } from '../notes/note.entity';
|
import { UsersService } from '../users/users.service';
|
||||||
import { NotInDBError } from '../errors/errors';
|
|
||||||
import { HistoryEntryImportDto } from './history-entry-import.dto';
|
import { HistoryEntryImportDto } from './history-entry-import.dto';
|
||||||
|
import { HistoryEntryUpdateDto } from './history-entry-update.dto';
|
||||||
|
import { HistoryEntryDto } from './history-entry.dto';
|
||||||
|
import { HistoryEntry } from './history-entry.entity';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class HistoryService {
|
export class HistoryService {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Inject,
|
Inject,
|
||||||
Injectable,
|
Injectable,
|
||||||
|
@ -12,12 +11,14 @@ import {
|
||||||
Scope,
|
Scope,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { isObject } from '@nestjs/common/utils/shared.utils';
|
import { isObject } from '@nestjs/common/utils/shared.utils';
|
||||||
import clc = require('cli-color');
|
|
||||||
import DateTimeFormatOptions = Intl.DateTimeFormatOptions;
|
|
||||||
import appConfiguration, { AppConfig } from '../config/app.config';
|
import appConfiguration, { AppConfig } from '../config/app.config';
|
||||||
import { Loglevel } from '../config/loglevel.enum';
|
import { Loglevel } from '../config/loglevel.enum';
|
||||||
import { needToLog } from '../config/utils';
|
import { needToLog } from '../config/utils';
|
||||||
|
|
||||||
|
import clc = require('cli-color');
|
||||||
|
import DateTimeFormatOptions = Intl.DateTimeFormatOptions;
|
||||||
|
|
||||||
@Injectable({ scope: Scope.TRANSIENT })
|
@Injectable({ scope: Scope.TRANSIENT })
|
||||||
export class ConsoleLoggerService implements LoggerService {
|
export class ConsoleLoggerService implements LoggerService {
|
||||||
private classContext: string | undefined;
|
private classContext: string | undefined;
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
import { ConsoleLoggerService } from './console-logger.service';
|
import { ConsoleLoggerService } from './console-logger.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
|
|
|
@ -3,17 +3,17 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { LogLevel, ValidationPipe } from '@nestjs/common';
|
import { LogLevel, ValidationPipe } from '@nestjs/common';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||||
|
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
import { AppConfig } from './config/app.config';
|
import { AppConfig } from './config/app.config';
|
||||||
import { MediaConfig } from './config/media.config';
|
import { MediaConfig } from './config/media.config';
|
||||||
import { setupPrivateApiDocs, setupPublicApiDocs } from './utils/swagger';
|
|
||||||
import { BackendType } from './media/backends/backend-type.enum';
|
|
||||||
import { ConsoleLoggerService } from './logger/console-logger.service';
|
import { ConsoleLoggerService } from './logger/console-logger.service';
|
||||||
|
import { BackendType } from './media/backends/backend-type.enum';
|
||||||
|
import { setupPrivateApiDocs, setupPublicApiDocs } from './utils/swagger';
|
||||||
|
|
||||||
async function bootstrap(): Promise<void> {
|
async function bootstrap(): Promise<void> {
|
||||||
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
|
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
|
||||||
|
|
|
@ -3,19 +3,19 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
|
||||||
import mediaConfiguration, { MediaConfig } from '../../config/media.config';
|
|
||||||
import { ConsoleLoggerService } from '../../logger/console-logger.service';
|
|
||||||
import { MediaBackend } from '../media-backend.interface';
|
|
||||||
import { BackendData } from '../media-upload.entity';
|
|
||||||
import {
|
import {
|
||||||
BlobServiceClient,
|
BlobServiceClient,
|
||||||
BlockBlobClient,
|
BlockBlobClient,
|
||||||
ContainerClient,
|
ContainerClient,
|
||||||
} from '@azure/storage-blob';
|
} from '@azure/storage-blob';
|
||||||
import { BackendType } from './backend-type.enum';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
|
import mediaConfiguration, { MediaConfig } from '../../config/media.config';
|
||||||
import { MediaBackendError } from '../../errors/errors';
|
import { MediaBackendError } from '../../errors/errors';
|
||||||
|
import { ConsoleLoggerService } from '../../logger/console-logger.service';
|
||||||
|
import { MediaBackend } from '../media-backend.interface';
|
||||||
|
import { BackendData } from '../media-upload.entity';
|
||||||
|
import { BackendType } from './backend-type.enum';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AzureBackend implements MediaBackend {
|
export class AzureBackend implements MediaBackend {
|
||||||
|
|
|
@ -3,16 +3,15 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import mediaConfiguration from '../../config/media.config';
|
|
||||||
|
import mediaConfiguration, { MediaConfig } from '../../config/media.config';
|
||||||
|
import { MediaBackendError } from '../../errors/errors';
|
||||||
import { ConsoleLoggerService } from '../../logger/console-logger.service';
|
import { ConsoleLoggerService } from '../../logger/console-logger.service';
|
||||||
import { MediaBackend } from '../media-backend.interface';
|
import { MediaBackend } from '../media-backend.interface';
|
||||||
import { BackendData } from '../media-upload.entity';
|
import { BackendData } from '../media-upload.entity';
|
||||||
import { MediaConfig } from '../../config/media.config';
|
|
||||||
import { MediaBackendError } from '../../errors/errors';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FilesystemBackend implements MediaBackend {
|
export class FilesystemBackend implements MediaBackend {
|
||||||
|
|
|
@ -3,16 +3,15 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import mediaConfiguration from '../../config/media.config';
|
import fetch, { Response } from 'node-fetch';
|
||||||
|
import { URLSearchParams } from 'url';
|
||||||
|
|
||||||
|
import mediaConfiguration, { MediaConfig } from '../../config/media.config';
|
||||||
|
import { MediaBackendError } from '../../errors/errors';
|
||||||
import { ConsoleLoggerService } from '../../logger/console-logger.service';
|
import { ConsoleLoggerService } from '../../logger/console-logger.service';
|
||||||
import { MediaBackend } from '../media-backend.interface';
|
import { MediaBackend } from '../media-backend.interface';
|
||||||
import { BackendData } from '../media-upload.entity';
|
import { BackendData } from '../media-upload.entity';
|
||||||
import { MediaConfig } from '../../config/media.config';
|
|
||||||
import fetch, { Response } from 'node-fetch';
|
|
||||||
import { URLSearchParams } from 'url';
|
|
||||||
import { MediaBackendError } from '../../errors/errors';
|
|
||||||
|
|
||||||
type UploadResult = {
|
type UploadResult = {
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -3,16 +3,15 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import mediaConfiguration from '../../config/media.config';
|
import { Client } from 'minio';
|
||||||
|
|
||||||
|
import mediaConfiguration, { MediaConfig } from '../../config/media.config';
|
||||||
|
import { MediaBackendError } from '../../errors/errors';
|
||||||
import { ConsoleLoggerService } from '../../logger/console-logger.service';
|
import { ConsoleLoggerService } from '../../logger/console-logger.service';
|
||||||
import { MediaBackend } from '../media-backend.interface';
|
import { MediaBackend } from '../media-backend.interface';
|
||||||
import { BackendData } from '../media-upload.entity';
|
import { BackendData } from '../media-upload.entity';
|
||||||
import { MediaConfig } from '../../config/media.config';
|
|
||||||
import { Client } from 'minio';
|
|
||||||
import { BackendType } from './backend-type.enum';
|
import { BackendType } from './backend-type.enum';
|
||||||
import { MediaBackendError } from '../../errors/errors';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class S3Backend implements MediaBackend {
|
export class S3Backend implements MediaBackend {
|
||||||
|
|
|
@ -3,16 +3,15 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import mediaConfiguration from '../../config/media.config';
|
import fetch, { Response } from 'node-fetch';
|
||||||
|
|
||||||
|
import mediaConfiguration, { MediaConfig } from '../../config/media.config';
|
||||||
|
import { MediaBackendError } from '../../errors/errors';
|
||||||
import { ConsoleLoggerService } from '../../logger/console-logger.service';
|
import { ConsoleLoggerService } from '../../logger/console-logger.service';
|
||||||
import { MediaBackend } from '../media-backend.interface';
|
import { MediaBackend } from '../media-backend.interface';
|
||||||
import { BackendData } from '../media-upload.entity';
|
import { BackendData } from '../media-upload.entity';
|
||||||
import { MediaConfig } from '../../config/media.config';
|
|
||||||
import { MediaBackendError } from '../../errors/errors';
|
|
||||||
import { BackendType } from './backend-type.enum';
|
import { BackendType } from './backend-type.enum';
|
||||||
import fetch, { Response } from 'node-fetch';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class WebdavBackend implements MediaBackend {
|
export class WebdavBackend implements MediaBackend {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { BackendData } from './media-upload.entity';
|
import { BackendData } from './media-upload.entity';
|
||||||
|
|
||||||
export interface MediaBackend {
|
export interface MediaBackend {
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IsString } from 'class-validator';
|
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsString } from 'class-validator';
|
||||||
|
|
||||||
export class MediaUploadUrlDto {
|
export class MediaUploadUrlDto {
|
||||||
@IsString()
|
@IsString()
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IsDate, IsOptional, IsString } from 'class-validator';
|
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsDate, IsOptional, IsString } from 'class-validator';
|
||||||
|
|
||||||
export class MediaUploadDto {
|
export class MediaUploadDto {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
import {
|
import {
|
||||||
Column,
|
Column,
|
||||||
|
@ -12,6 +11,7 @@ import {
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
PrimaryColumn,
|
PrimaryColumn,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
|
||||||
import { Note } from '../notes/note.entity';
|
import { Note } from '../notes/note.entity';
|
||||||
import { User } from '../users/user.entity';
|
import { User } from '../users/user.entity';
|
||||||
import { BackendType } from './backends/backend-type.enum';
|
import { BackendType } from './backends/backend-type.enum';
|
||||||
|
|
|
@ -3,20 +3,20 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
import { NotesModule } from '../notes/notes.module';
|
import { NotesModule } from '../notes/notes.module';
|
||||||
import { UsersModule } from '../users/users.module';
|
import { UsersModule } from '../users/users.module';
|
||||||
|
import { AzureBackend } from './backends/azure-backend';
|
||||||
import { FilesystemBackend } from './backends/filesystem-backend';
|
import { FilesystemBackend } from './backends/filesystem-backend';
|
||||||
|
import { ImgurBackend } from './backends/imgur-backend';
|
||||||
|
import { S3Backend } from './backends/s3-backend';
|
||||||
|
import { WebdavBackend } from './backends/webdav-backend';
|
||||||
import { MediaUpload } from './media-upload.entity';
|
import { MediaUpload } from './media-upload.entity';
|
||||||
import { MediaService } from './media.service';
|
import { MediaService } from './media.service';
|
||||||
import { S3Backend } from './backends/s3-backend';
|
|
||||||
import { ImgurBackend } from './backends/imgur-backend';
|
|
||||||
import { AzureBackend } from './backends/azure-backend';
|
|
||||||
import { WebdavBackend } from './backends/webdav-backend';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
|
|
@ -3,19 +3,26 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||||
|
import { promises as fs } from 'fs';
|
||||||
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
|
import appConfigMock from '../../src/config/mock/app.config.mock';
|
||||||
|
import { AuthToken } from '../auth/auth-token.entity';
|
||||||
import { Author } from '../authors/author.entity';
|
import { Author } from '../authors/author.entity';
|
||||||
import mediaConfigMock from '../config/mock/media.config.mock';
|
import mediaConfigMock from '../config/mock/media.config.mock';
|
||||||
|
import { ClientError, NotInDBError } from '../errors/errors';
|
||||||
|
import { Group } from '../groups/group.entity';
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
import { Note } from '../notes/note.entity';
|
import { Note } from '../notes/note.entity';
|
||||||
import { NotesModule } from '../notes/notes.module';
|
import { NotesModule } from '../notes/notes.module';
|
||||||
import { Tag } from '../notes/tag.entity';
|
import { Tag } from '../notes/tag.entity';
|
||||||
|
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
||||||
|
import { NoteUserPermission } from '../permissions/note-user-permission.entity';
|
||||||
import { Edit } from '../revisions/edit.entity';
|
import { Edit } from '../revisions/edit.entity';
|
||||||
import { Revision } from '../revisions/revision.entity';
|
import { Revision } from '../revisions/revision.entity';
|
||||||
import { AuthToken } from '../auth/auth-token.entity';
|
|
||||||
import { Identity } from '../users/identity.entity';
|
import { Identity } from '../users/identity.entity';
|
||||||
import { Session } from '../users/session.entity';
|
import { Session } from '../users/session.entity';
|
||||||
import { User } from '../users/user.entity';
|
import { User } from '../users/user.entity';
|
||||||
|
@ -23,13 +30,6 @@ import { UsersModule } from '../users/users.module';
|
||||||
import { FilesystemBackend } from './backends/filesystem-backend';
|
import { FilesystemBackend } from './backends/filesystem-backend';
|
||||||
import { BackendData, MediaUpload } from './media-upload.entity';
|
import { BackendData, MediaUpload } from './media-upload.entity';
|
||||||
import { MediaService } from './media.service';
|
import { MediaService } from './media.service';
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { promises as fs } from 'fs';
|
|
||||||
import { ClientError, NotInDBError } from '../errors/errors';
|
|
||||||
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
|
||||||
import { NoteUserPermission } from '../permissions/note-user-permission.entity';
|
|
||||||
import { Group } from '../groups/group.entity';
|
|
||||||
import appConfigMock from '../../src/config/mock/app.config.mock';
|
|
||||||
|
|
||||||
describe('MediaService', () => {
|
describe('MediaService', () => {
|
||||||
let service: MediaService;
|
let service: MediaService;
|
||||||
|
|
|
@ -3,29 +3,29 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { ModuleRef } from '@nestjs/core';
|
import { ModuleRef } from '@nestjs/core';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import * as FileType from 'file-type';
|
import * as FileType from 'file-type';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
import mediaConfiguration, { MediaConfig } from '../config/media.config';
|
import mediaConfiguration, { MediaConfig } from '../config/media.config';
|
||||||
import { ClientError, NotInDBError } from '../errors/errors';
|
import { ClientError, NotInDBError } from '../errors/errors';
|
||||||
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
||||||
|
import { Note } from '../notes/note.entity';
|
||||||
import { NotesService } from '../notes/notes.service';
|
import { NotesService } from '../notes/notes.service';
|
||||||
|
import { User } from '../users/user.entity';
|
||||||
import { UsersService } from '../users/users.service';
|
import { UsersService } from '../users/users.service';
|
||||||
|
import { AzureBackend } from './backends/azure-backend';
|
||||||
import { BackendType } from './backends/backend-type.enum';
|
import { BackendType } from './backends/backend-type.enum';
|
||||||
import { FilesystemBackend } from './backends/filesystem-backend';
|
import { FilesystemBackend } from './backends/filesystem-backend';
|
||||||
import { MediaBackend } from './media-backend.interface';
|
|
||||||
import { MediaUpload } from './media-upload.entity';
|
|
||||||
import { MediaUploadUrlDto } from './media-upload-url.dto';
|
|
||||||
import { S3Backend } from './backends/s3-backend';
|
|
||||||
import { AzureBackend } from './backends/azure-backend';
|
|
||||||
import { ImgurBackend } from './backends/imgur-backend';
|
import { ImgurBackend } from './backends/imgur-backend';
|
||||||
import { User } from '../users/user.entity';
|
import { S3Backend } from './backends/s3-backend';
|
||||||
import { MediaUploadDto } from './media-upload.dto';
|
|
||||||
import { Note } from '../notes/note.entity';
|
|
||||||
import { WebdavBackend } from './backends/webdav-backend';
|
import { WebdavBackend } from './backends/webdav-backend';
|
||||||
|
import { MediaBackend } from './media-backend.interface';
|
||||||
|
import { MediaUploadUrlDto } from './media-upload-url.dto';
|
||||||
|
import { MediaUploadDto } from './media-upload.dto';
|
||||||
|
import { MediaUpload } from './media-upload.entity';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MediaService {
|
export class MediaService {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Readable } from 'stream';
|
import { Readable } from 'stream';
|
||||||
|
|
||||||
// Type from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/multer/index.d.ts
|
// Type from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/multer/index.d.ts
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
import { MonitoringService } from './monitoring.service';
|
import { MonitoringService } from './monitoring.service';
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
|
||||||
import { MonitoringService } from './monitoring.service';
|
import { MonitoringService } from './monitoring.service';
|
||||||
|
|
||||||
describe('MonitoringService', () => {
|
describe('MonitoringService', () => {
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { ServerStatusDto } from './server-status.dto';
|
|
||||||
import { getServerVersionFromPackageJson } from '../utils/serverVersion';
|
import { getServerVersionFromPackageJson } from '../utils/serverVersion';
|
||||||
|
import { ServerStatusDto } from './server-status.dto';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MonitoringService {
|
export class MonitoringService {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
|
||||||
export class ServerVersion {
|
export class ServerVersion {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||||
import {
|
import {
|
||||||
IsArray,
|
IsArray,
|
||||||
IsDate,
|
IsDate,
|
||||||
|
@ -12,9 +12,9 @@ import {
|
||||||
IsString,
|
IsString,
|
||||||
ValidateNested,
|
ValidateNested,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
|
|
||||||
import { UserInfoDto } from '../users/user-info.dto';
|
import { UserInfoDto } from '../users/user-info.dto';
|
||||||
import { NotePermissionsDto } from './note-permissions.dto';
|
import { NotePermissionsDto } from './note-permissions.dto';
|
||||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
||||||
|
|
||||||
export class NoteMetadataDto {
|
export class NoteMetadataDto {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||||
import {
|
import {
|
||||||
IsArray,
|
IsArray,
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
|
@ -11,9 +11,9 @@ import {
|
||||||
IsString,
|
IsString,
|
||||||
ValidateNested,
|
ValidateNested,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { UserInfoDto } from '../users/user-info.dto';
|
|
||||||
import { GroupInfoDto } from '../groups/group-info.dto';
|
import { GroupInfoDto } from '../groups/group-info.dto';
|
||||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
import { UserInfoDto } from '../users/user-info.dto';
|
||||||
|
|
||||||
export class NoteUserPermissionEntryDto {
|
export class NoteUserPermissionEntryDto {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
import { IsArray, IsString, ValidateNested } from 'class-validator';
|
import { IsArray, IsString, ValidateNested } from 'class-validator';
|
||||||
|
|
||||||
import { EditDto } from '../revisions/edit.dto';
|
import { EditDto } from '../revisions/edit.dto';
|
||||||
import { NoteMetadataDto } from './note-metadata.dto';
|
import { NoteMetadataDto } from './note-metadata.dto';
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
|
||||||
|
|
||||||
export class NoteDto {
|
export class NoteDto {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Column,
|
Column,
|
||||||
Entity,
|
Entity,
|
||||||
|
@ -13,13 +12,14 @@ import {
|
||||||
OneToMany,
|
OneToMany,
|
||||||
PrimaryGeneratedColumn,
|
PrimaryGeneratedColumn,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
|
||||||
|
import { HistoryEntry } from '../history/history-entry.entity';
|
||||||
|
import { MediaUpload } from '../media/media-upload.entity';
|
||||||
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
||||||
import { NoteUserPermission } from '../permissions/note-user-permission.entity';
|
import { NoteUserPermission } from '../permissions/note-user-permission.entity';
|
||||||
import { Revision } from '../revisions/revision.entity';
|
import { Revision } from '../revisions/revision.entity';
|
||||||
import { User } from '../users/user.entity';
|
import { User } from '../users/user.entity';
|
||||||
import { Tag } from './tag.entity';
|
import { Tag } from './tag.entity';
|
||||||
import { HistoryEntry } from '../history/history-entry.entity';
|
|
||||||
import { MediaUpload } from '../media/media-upload.entity';
|
|
||||||
import { generatePublicId } from './utils';
|
import { generatePublicId } from './utils';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
import { IsBoolean } from 'class-validator';
|
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsBoolean } from 'class-validator';
|
||||||
|
|
||||||
export class NoteMediaDeletionDto {
|
export class NoteMediaDeletionDto {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { forwardRef, Module } from '@nestjs/common';
|
import { forwardRef, Module } from '@nestjs/common';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
|
||||||
import { GroupsModule } from '../groups/groups.module';
|
import { GroupsModule } from '../groups/groups.module';
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
||||||
|
|
|
@ -3,39 +3,39 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||||
import { Author } from '../authors/author.entity';
|
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
|
||||||
import { Edit } from '../revisions/edit.entity';
|
|
||||||
import { Revision } from '../revisions/revision.entity';
|
|
||||||
import { RevisionsModule } from '../revisions/revisions.module';
|
|
||||||
import { AuthToken } from '../auth/auth-token.entity';
|
|
||||||
import { Identity } from '../users/identity.entity';
|
|
||||||
import { Session } from '../users/session.entity';
|
|
||||||
import { User } from '../users/user.entity';
|
|
||||||
import { UsersModule } from '../users/users.module';
|
|
||||||
import { Note } from './note.entity';
|
|
||||||
import { NotesService } from './notes.service';
|
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import { Tag } from './tag.entity';
|
|
||||||
|
import { AuthToken } from '../auth/auth-token.entity';
|
||||||
|
import { Author } from '../authors/author.entity';
|
||||||
|
import appConfigMock from '../config/mock/app.config.mock';
|
||||||
import {
|
import {
|
||||||
AlreadyInDBError,
|
AlreadyInDBError,
|
||||||
ForbiddenIdError,
|
ForbiddenIdError,
|
||||||
NotInDBError,
|
NotInDBError,
|
||||||
PermissionsUpdateInconsistentError,
|
PermissionsUpdateInconsistentError,
|
||||||
} from '../errors/errors';
|
} from '../errors/errors';
|
||||||
|
import { Group } from '../groups/group.entity';
|
||||||
|
import { GroupsModule } from '../groups/groups.module';
|
||||||
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
|
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
||||||
|
import { NoteUserPermission } from '../permissions/note-user-permission.entity';
|
||||||
|
import { Edit } from '../revisions/edit.entity';
|
||||||
|
import { Revision } from '../revisions/revision.entity';
|
||||||
|
import { RevisionsModule } from '../revisions/revisions.module';
|
||||||
|
import { Identity } from '../users/identity.entity';
|
||||||
|
import { Session } from '../users/session.entity';
|
||||||
|
import { User } from '../users/user.entity';
|
||||||
|
import { UsersModule } from '../users/users.module';
|
||||||
import {
|
import {
|
||||||
NoteGroupPermissionUpdateDto,
|
NoteGroupPermissionUpdateDto,
|
||||||
NoteUserPermissionUpdateDto,
|
NoteUserPermissionUpdateDto,
|
||||||
} from './note-permissions.dto';
|
} from './note-permissions.dto';
|
||||||
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
import { Note } from './note.entity';
|
||||||
import { NoteUserPermission } from '../permissions/note-user-permission.entity';
|
import { NotesService } from './notes.service';
|
||||||
import { GroupsModule } from '../groups/groups.module';
|
import { Tag } from './tag.entity';
|
||||||
import { Group } from '../groups/group.entity';
|
|
||||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
||||||
import appConfigMock from '../config/mock/app.config.mock';
|
|
||||||
|
|
||||||
describe('NotesService', () => {
|
describe('NotesService', () => {
|
||||||
let service: NotesService;
|
let service: NotesService;
|
||||||
|
|
|
@ -3,21 +3,27 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { forwardRef, Inject, Injectable } from '@nestjs/common';
|
import { forwardRef, Inject, Injectable } from '@nestjs/common';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
|
import appConfiguration, { AppConfig } from '../config/app.config';
|
||||||
import {
|
import {
|
||||||
AlreadyInDBError,
|
AlreadyInDBError,
|
||||||
ForbiddenIdError,
|
ForbiddenIdError,
|
||||||
NotInDBError,
|
NotInDBError,
|
||||||
PermissionsUpdateInconsistentError,
|
PermissionsUpdateInconsistentError,
|
||||||
} from '../errors/errors';
|
} from '../errors/errors';
|
||||||
|
import { GroupsService } from '../groups/groups.service';
|
||||||
|
import { HistoryEntry } from '../history/history-entry.entity';
|
||||||
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
||||||
|
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
||||||
|
import { NoteUserPermission } from '../permissions/note-user-permission.entity';
|
||||||
import { Revision } from '../revisions/revision.entity';
|
import { Revision } from '../revisions/revision.entity';
|
||||||
import { RevisionsService } from '../revisions/revisions.service';
|
import { RevisionsService } from '../revisions/revisions.service';
|
||||||
import { User } from '../users/user.entity';
|
import { User } from '../users/user.entity';
|
||||||
import { UsersService } from '../users/users.service';
|
import { UsersService } from '../users/users.service';
|
||||||
|
import { checkArrayForDuplicates } from '../utils/arrayDuplicatCheck';
|
||||||
import { NoteMetadataDto } from './note-metadata.dto';
|
import { NoteMetadataDto } from './note-metadata.dto';
|
||||||
import {
|
import {
|
||||||
NotePermissionsDto,
|
NotePermissionsDto,
|
||||||
|
@ -26,14 +32,6 @@ import {
|
||||||
import { NoteDto } from './note.dto';
|
import { NoteDto } from './note.dto';
|
||||||
import { Note } from './note.entity';
|
import { Note } from './note.entity';
|
||||||
import { Tag } from './tag.entity';
|
import { Tag } from './tag.entity';
|
||||||
import { HistoryEntry } from '../history/history-entry.entity';
|
|
||||||
import { NoteUserPermission } from '../permissions/note-user-permission.entity';
|
|
||||||
import { NoteGroupPermission } from '../permissions/note-group-permission.entity';
|
|
||||||
import { GroupsService } from '../groups/groups.service';
|
|
||||||
import { checkArrayForDuplicates } from '../utils/arrayDuplicatCheck';
|
|
||||||
import appConfiguration, { AppConfig } from '../config/app.config';
|
|
||||||
import base32Encode from 'base32-encode';
|
|
||||||
import { randomBytes } from 'crypto';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class NotesService {
|
export class NotesService {
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from 'typeorm';
|
import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||||
|
|
||||||
import { Note } from './note.entity';
|
import { Note } from './note.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { randomBytes } from 'crypto';
|
import { randomBytes } from 'crypto';
|
||||||
|
|
||||||
import { generatePublicId } from './utils';
|
import { generatePublicId } from './utils';
|
||||||
|
|
||||||
jest.mock('crypto');
|
jest.mock('crypto');
|
||||||
|
|
||||||
it('generatePublicId', () => {
|
it('generatePublicId', () => {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue