37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { Controller } from '@nestjs/common';
|
|
import { AssetsService } from './services/assets.service';
|
|
import { MessagePattern } from '@nestjs/microservices';
|
|
import { AssetUploadRequest } from './interfaces/upload-request.interface';
|
|
import { UserInfo } from '@freeblox/shared';
|
|
|
|
@Controller()
|
|
export class AssetsController {
|
|
constructor(private readonly assetsService: AssetsService) {}
|
|
|
|
@MessagePattern('assets.upload')
|
|
async uploadAsset({
|
|
body,
|
|
user,
|
|
}: {
|
|
body: AssetUploadRequest;
|
|
user?: UserInfo;
|
|
}) {
|
|
return this.assetsService.uploadFile(body, user);
|
|
}
|
|
|
|
@MessagePattern('assets.info.byId')
|
|
async assetInfo({ id, user }: { id: string; user?: UserInfo }) {
|
|
return this.assetsService.getAssetInfoById(id, user);
|
|
}
|
|
|
|
@MessagePattern('assets.download.byId')
|
|
async downloadAsset({ id, user }: { id: string; user?: UserInfo }) {
|
|
return this.assetsService.downloadAssetById(id, user);
|
|
}
|
|
|
|
@MessagePattern('assets.delete.byId')
|
|
async deleteAsset({ id }: { id: string }) {
|
|
return this.assetsService.deleteAsset(id);
|
|
}
|
|
}
|