mirror of
https://github.com/docmost/docmost.git
synced 2025-11-17 00:11:11 +10:00
Refactoring
* Refactor workspace membership system * Create setup endpoint * Use Passport.js * Several updates and fixes
This commit is contained in:
@ -12,18 +12,18 @@ import {
|
||||
import { AttachmentService } from './attachment.service';
|
||||
import { FastifyReply, FastifyRequest } from 'fastify';
|
||||
import { AttachmentInterceptor } from './attachment.interceptor';
|
||||
import { JwtGuard } from '../auth/guards/jwt.guard';
|
||||
import * as bytes from 'bytes';
|
||||
import { AuthUser } from '../../decorators/auth-user.decorator';
|
||||
import { User } from '../user/entities/user.entity';
|
||||
import { CurrentWorkspace } from '../../decorators/current-workspace.decorator';
|
||||
import { AuthWorkspace } from '../../decorators/auth-workspace.decorator';
|
||||
import { Workspace } from '../workspace/entities/workspace.entity';
|
||||
import { JwtAuthGuard } from '../../guards/jwt-auth.guard';
|
||||
|
||||
@Controller('attachments')
|
||||
export class AttachmentController {
|
||||
constructor(private readonly attachmentService: AttachmentService) {}
|
||||
|
||||
@UseGuards(JwtGuard)
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
@Post('upload/avatar')
|
||||
@UseInterceptors(AttachmentInterceptor)
|
||||
@ -50,7 +50,7 @@ export class AttachmentController {
|
||||
}
|
||||
}
|
||||
|
||||
@UseGuards(JwtGuard)
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
@Post('upload/workspace-logo')
|
||||
@UseInterceptors(AttachmentInterceptor)
|
||||
@ -58,7 +58,7 @@ export class AttachmentController {
|
||||
@Req() req: FastifyRequest,
|
||||
@Res() res: FastifyReply,
|
||||
@AuthUser() user: User,
|
||||
@CurrentWorkspace() workspace: Workspace,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
) {
|
||||
const maxFileSize = bytes('5MB');
|
||||
|
||||
@ -79,7 +79,7 @@ export class AttachmentController {
|
||||
}
|
||||
}
|
||||
|
||||
@UseGuards(JwtGuard)
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
@Post('upload/file')
|
||||
@UseInterceptors(AttachmentInterceptor)
|
||||
@ -87,7 +87,7 @@ export class AttachmentController {
|
||||
@Req() req: FastifyRequest,
|
||||
@Res() res: FastifyReply,
|
||||
@AuthUser() user: User,
|
||||
@CurrentWorkspace() workspace: Workspace,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
) {
|
||||
const maxFileSize = bytes('20MB');
|
||||
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AttachmentService } from './attachment.service';
|
||||
import { AttachmentController } from './attachment.controller';
|
||||
import { StorageModule } from '../storage/storage.module';
|
||||
import { StorageModule } from '../../integrations/storage/storage.module';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Attachment } from './entities/attachment.entity';
|
||||
import { AttachmentRepository } from './repositories/attachment.repository';
|
||||
import { AuthModule } from '../auth/auth.module';
|
||||
import { UserModule } from '../user/user.module';
|
||||
import { WorkspaceModule } from '../workspace/workspace.module';
|
||||
|
||||
@ -13,7 +12,6 @@ import { WorkspaceModule } from '../workspace/workspace.module';
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([Attachment]),
|
||||
StorageModule,
|
||||
AuthModule,
|
||||
UserModule,
|
||||
WorkspaceModule,
|
||||
],
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { BadRequestException, Injectable } from '@nestjs/common';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { StorageService } from '../../integrations/storage/storage.service';
|
||||
import { MultipartFile } from '@fastify/multipart';
|
||||
import { AttachmentRepository } from './repositories/attachment.repository';
|
||||
import { Attachment } from './entities/attachment.entity';
|
||||
|
||||
Reference in New Issue
Block a user