mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-12-29 05:33:28 +00:00
Add HistoryModule
This contains the module, a service (which only returns mock data), a model and two DTOs for history entries. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
e6ac4cf20b
commit
960deeb059
5 changed files with 123 additions and 0 deletions
6
src/history/history-entry-update.dto.ts
Normal file
6
src/history/history-entry-update.dto.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { IsBoolean } from 'class-validator';
|
||||
|
||||
export class HistoryEntryUpdateDto {
|
||||
@IsBoolean()
|
||||
pinStatus: boolean;
|
||||
}
|
9
src/history/history-entry.dto.ts
Normal file
9
src/history/history-entry.dto.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { IsBoolean, ValidateNested } from 'class-validator';
|
||||
import { NoteMetadataDto } from '../notes/note-metadata.dto';
|
||||
|
||||
export class HistoryEntryDto {
|
||||
@ValidateNested()
|
||||
metadata: NoteMetadataDto;
|
||||
@IsBoolean()
|
||||
pinStatus: boolean;
|
||||
}
|
8
src/history/history.module.ts
Normal file
8
src/history/history.module.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { HistoryService } from './history.service';
|
||||
|
||||
@Module({
|
||||
providers: [HistoryService],
|
||||
exports: [HistoryService],
|
||||
})
|
||||
export class HistoryModule {}
|
18
src/history/history.service.spec.ts
Normal file
18
src/history/history.service.spec.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { HistoryService } from './history.service';
|
||||
|
||||
describe('HistoryService', () => {
|
||||
let service: HistoryService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [HistoryService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<HistoryService>(HistoryService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
82
src/history/history.service.ts
Normal file
82
src/history/history.service.ts
Normal file
|
@ -0,0 +1,82 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { HistoryEntryUpdateDto } from './history-entry-update.dto';
|
||||
import { HistoryEntryDto } from './history-entry.dto';
|
||||
|
||||
@Injectable()
|
||||
export class HistoryService {
|
||||
getUserHistory(username: string): HistoryEntryDto[] {
|
||||
//TODO: Use the database
|
||||
return [
|
||||
{
|
||||
metadata: {
|
||||
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,
|
||||
},
|
||||
pinStatus: false,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
updateHistoryEntry(
|
||||
noteId: string,
|
||||
updateDto: HistoryEntryUpdateDto,
|
||||
): HistoryEntryDto {
|
||||
//TODO: Use the database
|
||||
return {
|
||||
metadata: {
|
||||
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,
|
||||
},
|
||||
pinStatus: updateDto.pinStatus,
|
||||
};
|
||||
}
|
||||
|
||||
deleteHistoryEntry(note: string) {
|
||||
//TODO: Use the database and actually do stuff
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue