Skip to content

Commit

Permalink
refactor: 🔥 remove fields uri & url from Prisma schema and associated…
Browse files Browse the repository at this point in the history
… code (#144)
  • Loading branch information
Carolinedanslesnuages authored Dec 9, 2024
1 parent 0be70f4 commit 97ee0fd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 61 deletions.
10 changes: 10 additions & 0 deletions server/prisma/migrations/20241209140539_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
Warnings:
- You are about to drop the column `uri` on the `applications` table. All the data in the column will be lost.
- You are about to drop the column `url` on the `applications` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "applications" DROP COLUMN "uri",
DROP COLUMN "url";
2 changes: 0 additions & 2 deletions server/prisma/schema/applications.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ model Application {
shortName String?
logo String?
description String
url String
uri String
purposes String[]
tags String[]
lifecycleId String
Expand Down
37 changes: 2 additions & 35 deletions server/src/application/application.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,18 @@ import {
BadRequestException,
NotFoundException,
Logger,
InternalServerErrorException,
} from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { CreateApplicationDto } from './dto/create-application.dto';
import { UpdateApplicationDto } from './dto/update-application.dto';
import { SearchApplicationDto } from './dto/search-application.dto';
import { GetApplicationDto } from './dto/get-application.dto';
import { ConfigService } from '@nestjs/config';
import { Prisma } from '@prisma/client';

@Injectable()
export class ApplicationService {
applications: any;
private readonly BASE_URL_APPLICATION: string;
private readonly BASE_URL_API: string;
constructor(
private prisma: PrismaService,
private configService: ConfigService,
) {
this.BASE_URL_APPLICATION = this.configService.get<string>(
'BASE_URL_APPLICATION',
);
this.BASE_URL_API = this.configService.get<string>('BASE_URL_API');
}
constructor(private prisma: PrismaService) {}

public async createApplication(
ownerId: string,
Expand All @@ -52,8 +40,7 @@ export class ApplicationService {
applicationMetadata.id,
createApplicationDto,
);
const updatedApplication = await this.updateApplicationUrls(application.id);
return updatedApplication;
return application;
}

public async updateApplication(
Expand Down Expand Up @@ -159,8 +146,6 @@ export class ApplicationService {
shortName: application.shortName || null,
logo: application.logo || null,
description: application.description,
url: application.url,
uri: application.uri,
purposes: application.purposes,
tags: application.tags,
lifecycleId: application.lifecycleId || null,
Expand Down Expand Up @@ -193,8 +178,6 @@ export class ApplicationService {
shortName: createApplicationDto.shortName || null,
logo: createApplicationDto.logo || null,
description: createApplicationDto.description,
url: createApplicationDto.url || this.BASE_URL_APPLICATION,
uri: createApplicationDto.uri || this.BASE_URL_API,
purposes: createApplicationDto.purposes,
tags: createApplicationDto.tags,
metadata: { connect: { id: applicationMetadataId } },
Expand Down Expand Up @@ -261,22 +244,6 @@ export class ApplicationService {
return application;
}

private async updateApplicationUrls(applicationId: string) {
return await this.prisma.application.update({
where: { id: applicationId },
data: {
url: `${this.BASE_URL_APPLICATION}/${applicationId}`,
uri: `${this.BASE_URL_API}/${applicationId}`,
},
include: {
lifecycle: { include: { metadata: true } },
metadata: true,
actors: true,
compliances: true,
},
});
}

private async isApplicationExist(applicationId: string): Promise<boolean> {
const application = await this.prisma.application.findUnique({
where: { id: applicationId },
Expand Down
18 changes: 0 additions & 18 deletions server/src/application/dto/create-application.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,24 +212,6 @@ export class CreateApplicationDto {
@IsString({ each: true })
tags?: string[];

@ApiProperty({
example: 'http://example.com/app',
description: 'URI of the application',
required: false,
})
@IsOptional()
@IsString()
uri?: string;

@ApiProperty({
example: 'http://example.com/dashboard',
description: 'URL of the application',
required: false,
})
@IsOptional()
@IsString()
url?: string;

@ApiProperty({
example: 'parentApp123',
description: 'Parent application ID',
Expand Down
6 changes: 0 additions & 6 deletions server/src/application/dto/get-application.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ export class GetApplicationDto {
@IsString()
description: string;

@IsString()
url: string;

@IsString()
uri: string;

@IsArray()
purposes: string[];

Expand Down

0 comments on commit 97ee0fd

Please sign in to comment.