Add NotesService

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2020-07-26 17:28:58 +02:00
parent 643adb7f9f
commit b05022945c
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
3 changed files with 60 additions and 0 deletions

View file

@ -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 {}

View file

@ -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>(NotesService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View file

@ -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,
},
];
}
}