diff --git a/src/notes/notes.module.ts b/src/notes/notes.module.ts index b267951f9..d869d692a 100644 --- a/src/notes/notes.module.ts +++ b/src/notes/notes.module.ts @@ -1,9 +1,12 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; import { Note } from './note.entity'; +import { NotesService } from './notes.service'; @Module({ imports: [TypeOrmModule.forFeature([Note])], controllers: [], + providers: [NotesService], + exports: [NotesService], }) export class NotesModule {} diff --git a/src/notes/notes.service.spec.ts b/src/notes/notes.service.spec.ts new file mode 100644 index 000000000..18f1c22c6 --- /dev/null +++ b/src/notes/notes.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { NotesService } from './notes.service'; + +describe('NotesService', () => { + let service: NotesService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [NotesService], + }).compile(); + + service = module.get(NotesService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/src/notes/notes.service.ts b/src/notes/notes.service.ts new file mode 100644 index 000000000..cf66b0190 --- /dev/null +++ b/src/notes/notes.service.ts @@ -0,0 +1,39 @@ +import { Injectable, Logger } from "@nestjs/common"; +import { NoteMetadataDto } from './note-metadata.dto'; + +@Injectable() +export class NotesService { + private readonly logger = new Logger(NotesService.name); + + getUserNotes(username: string): NoteMetadataDto[] { + this.logger.warn('Using hardcoded data!'); + return [ + { + alias: null, + createTime: new Date(), + description: 'Very descriptive text.', + editedBy: [], + id: 'foobar-barfoo', + permission: { + owner: { + displayName: 'foo', + userName: 'fooUser', + email: 'foo@example.com', + photo: '', + }, + sharedTo: [], + }, + tags: [], + title: 'Title!', + updateTime: new Date(), + updateUser: { + displayName: 'foo', + userName: 'fooUser', + email: 'foo@example.com', + photo: '', + }, + viewCount: 42, + }, + ]; + } +}