From 02de7c7d54f026d66708270bc5794f4cf32df444 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sun, 26 Jul 2020 17:29:20 +0200 Subject: [PATCH] Add /me/notes route to MeController Signed-off-by: David Mehren --- src/api/public/me/me.controller.spec.ts | 6 +++++- src/api/public/me/me.controller.ts | 8 ++++++++ src/api/public/public-api.module.ts | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/api/public/me/me.controller.spec.ts b/src/api/public/me/me.controller.spec.ts index 0f6ffdc95..68ad7a343 100644 --- a/src/api/public/me/me.controller.spec.ts +++ b/src/api/public/me/me.controller.spec.ts @@ -1,6 +1,8 @@ import { Test, TestingModule } from '@nestjs/testing'; import { getRepositoryToken } from '@nestjs/typeorm'; import { HistoryModule } from '../../../history/history.module'; +import { Note } from '../../../notes/note.entity'; +import { NotesModule } from '../../../notes/notes.module'; import { User } from '../../../users/user.entity'; import { UsersModule } from '../../../users/users.module'; import { MeController } from './me.controller'; @@ -11,10 +13,12 @@ describe('Me Controller', () => { beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ controllers: [MeController], - imports: [UsersModule, HistoryModule], + imports: [UsersModule, HistoryModule, NotesModule], }) .overrideProvider(getRepositoryToken(User)) .useValue({}) + .overrideProvider(getRepositoryToken(Note)) + .useValue({}) .compile(); controller = module.get(MeController); diff --git a/src/api/public/me/me.controller.ts b/src/api/public/me/me.controller.ts index f561ceb7f..d0862472c 100644 --- a/src/api/public/me/me.controller.ts +++ b/src/api/public/me/me.controller.ts @@ -12,6 +12,8 @@ import { import { HistoryEntryUpdateDto } from '../../../history/history-entry-update.dto'; import { HistoryEntryDto } from '../../../history/history-entry.dto'; import { HistoryService } from '../../../history/history.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'; @@ -22,6 +24,7 @@ export class MeController { constructor( private usersService: UsersService, private historyService: HistoryService, + private notesService: NotesService, ) {} @Get() @@ -51,4 +54,9 @@ export class MeController { throw new NotFoundException(e.message); } } + + @Get('notes') + getMyNotes(): NoteMetadataDto[] { + return this.notesService.getUserNotes('someone'); + } } diff --git a/src/api/public/public-api.module.ts b/src/api/public/public-api.module.ts index bbb55828a..0bdd2c1cf 100644 --- a/src/api/public/public-api.module.ts +++ b/src/api/public/public-api.module.ts @@ -1,5 +1,6 @@ import { Module } from '@nestjs/common'; import { HistoryModule } from '../../history/history.module'; +import { NotesModule } from '../../notes/notes.module'; import { UsersModule } from '../../users/users.module'; import { MeController } from './me/me.controller'; import { NotesController } from './notes/notes.controller'; @@ -7,7 +8,7 @@ import { MediaController } from './media/media.controller'; import { MonitoringController } from './monitoring/monitoring.controller'; @Module({ - imports: [UsersModule, HistoryModule], + imports: [UsersModule, HistoryModule, NotesModule], controllers: [ MeController, NotesController,