mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 01:36:29 -05:00
Add NotesService
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
643adb7f9f
commit
b05022945c
3 changed files with 60 additions and 0 deletions
|
@ -1,9 +1,12 @@
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { Note } from './note.entity';
|
import { Note } from './note.entity';
|
||||||
|
import { NotesService } from './notes.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TypeOrmModule.forFeature([Note])],
|
imports: [TypeOrmModule.forFeature([Note])],
|
||||||
controllers: [],
|
controllers: [],
|
||||||
|
providers: [NotesService],
|
||||||
|
exports: [NotesService],
|
||||||
})
|
})
|
||||||
export class NotesModule {}
|
export class NotesModule {}
|
||||||
|
|
18
src/notes/notes.service.spec.ts
Normal file
18
src/notes/notes.service.spec.ts
Normal 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();
|
||||||
|
});
|
||||||
|
});
|
39
src/notes/notes.service.ts
Normal file
39
src/notes/notes.service.ts
Normal 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,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue