Implement backend API and database services in Docker setup
- Added a new `api` service for the NestJS backend, including health checks and dependencies on PostgreSQL, Redis, and MinIO. - Introduced PostgreSQL and Redis services with health checks and configurations for data persistence. - Added MinIO for S3-compatible object storage and a one-shot service to initialize required buckets. - Updated the Nginx configuration to proxy requests to the new backend API and MinIO storage. - Enhanced the Dockerfile to support the new API environment variables and configurations. - Updated the `package.json` and `package-lock.json` to include new dependencies for QR code generation and other utilities. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
13
backend/src/users/dto/request/create-user.dto.ts
Normal file
13
backend/src/users/dto/request/create-user.dto.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { IsEmail, IsString } from 'class-validator';
|
||||
|
||||
export class CreateUserDTO {
|
||||
@IsString()
|
||||
legalName: string;
|
||||
|
||||
@IsString()
|
||||
@IsEmail()
|
||||
email: string;
|
||||
|
||||
@IsString()
|
||||
cognitoId: string;
|
||||
}
|
||||
16
backend/src/users/dto/request/update-user.dto.ts
Normal file
16
backend/src/users/dto/request/update-user.dto.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { ApiProperty, PartialType } from '@nestjs/swagger';
|
||||
import { CreateUserDTO } from './create-user.dto';
|
||||
import { UpdateFilmmakerDTO } from 'src/filmmakers/dto/request/update-filmmaker.dto';
|
||||
import { IsOptional, IsString, ValidateNested } from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
|
||||
export class UpdateUserDTO extends PartialType(CreateUserDTO) {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
profilePictureUrl?: string;
|
||||
|
||||
@ValidateNested()
|
||||
@ApiProperty({ type: () => UpdateFilmmakerDTO })
|
||||
@Type(() => UpdateFilmmakerDTO)
|
||||
filmmaker?: UpdateFilmmakerDTO;
|
||||
}
|
||||
42
backend/src/users/dto/response/user.dto.ts
Normal file
42
backend/src/users/dto/response/user.dto.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { FilmmakerDTO } from 'src/filmmakers/dto/response/filmmaker.dto';
|
||||
import { SubscriptionDTO } from 'src/subscriptions/dto/response/subscription.dto';
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
|
||||
export class UserDTO {
|
||||
id: string;
|
||||
email: string;
|
||||
cognitoId: string;
|
||||
filmmaker?: FilmmakerDTO;
|
||||
subscriptions?: SubscriptionDTO[];
|
||||
legalName: string;
|
||||
lastName: string;
|
||||
profilePictureUrl: string;
|
||||
|
||||
constructor(user: User) {
|
||||
this.id = user.id;
|
||||
this.email = user.email;
|
||||
this.cognitoId = user.cognitoId;
|
||||
if (user.filmmaker) {
|
||||
this.filmmaker = new FilmmakerDTO(user.filmmaker);
|
||||
}
|
||||
if (user.subscriptions && user.subscriptions.length > 0) {
|
||||
user.subscriptions.sort(
|
||||
(a, b) => b.periodEnd.getTime() - a.periodEnd.getTime(),
|
||||
);
|
||||
const activeSubscriptions = user.subscriptions.filter(
|
||||
(subscription) =>
|
||||
subscription.periodEnd > new Date() &&
|
||||
(subscription.status === 'succeeded' ||
|
||||
subscription.status === 'cancelled'),
|
||||
);
|
||||
this.subscriptions = activeSubscriptions.map(
|
||||
(activeSubscription) => new SubscriptionDTO(activeSubscription),
|
||||
);
|
||||
}
|
||||
this.legalName = user.legalName;
|
||||
if (user.profilePictureUrl) {
|
||||
this.profilePictureUrl =
|
||||
process.env.S3_PUBLIC_BUCKET_URL + user.profilePictureUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user