collaborative editor - wip

This commit is contained in:
Philipinho
2023-09-15 01:22:47 +01:00
parent 0d648c17fa
commit 4382c5a1d0
21 changed files with 375 additions and 23 deletions
@@ -3,7 +3,7 @@ import { JwtService } from '@nestjs/jwt';
import { EnvironmentService } from '../../../environment/environment.service';
import { User } from '../../user/entities/user.entity';
import { FastifyRequest } from 'fastify';
import { TokensDto } from "../dto/tokens.dto";
import { TokensDto } from '../dto/tokens.dto';
@Injectable()
export class TokenService {
+3 -3
View File
@@ -20,14 +20,14 @@ export class Page {
@Column({ length: 500, nullable: true })
title: string;
@Column({ type: 'text', nullable: true })
@Column({ type: 'jsonb', nullable: true })
content: string;
@Column({ type: 'text', nullable: true })
html: string;
@Column({ type: 'jsonb', nullable: true })
json: any;
@Column({ type: 'bytea', nullable: true })
ydoc: any;
@Column({ nullable: true })
slug: string;
+1
View File
@@ -11,5 +11,6 @@ import { WorkspaceModule } from '../workspace/workspace.module';
imports: [TypeOrmModule.forFeature([Page]), AuthModule, WorkspaceModule],
controllers: [PageController],
providers: [PageService, PageRepository],
exports: [PageService, PageRepository],
})
export class PageModule {}
+12 -2
View File
@@ -22,19 +22,29 @@ export class PageService {
page.creatorId = userId;
page.workspaceId = workspaceId;
console.log(page);
return await this.pageRepository.save(page);
}
async update(pageId: string, updatePageDto: UpdatePageDto): Promise<Page> {
const existingPage = await this.pageRepository.findById(pageId);
if (!existingPage) {
throw new Error(`Page with ID ${pageId} not found`);
}
const page = await this.pageRepository.preload({
id: pageId,
...updatePageDto,
} as Page);
return await this.pageRepository.save(page);
}
async updateState(pageId: string, content: any, ydoc: any): Promise<void> {
await this.pageRepository.update(pageId, {
content: content,
ydoc: ydoc,
});
}
async delete(pageId: string): Promise<void> {
await this.pageRepository.softDelete(pageId);
}