Skip to content

Commit

Permalink
Delete endpoint for custom projects
Browse files Browse the repository at this point in the history
  • Loading branch information
catalin-oancea committed Dec 24, 2024
1 parent 340f071 commit 7f84c87
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions backoffice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ const start = async () => {
secure: false,
maxAge: undefined,
},
},
}
);

app.use(admin.options.rootPath, adminRouter);

app.listen(PORT, () => {
console.log(
`AdminJS started on http://localhost:${PORT}${admin.options.rootPath}`,
`AdminJS started on http://localhost:${PORT}${admin.options.rootPath}`
);
});
};
Expand Down
6 changes: 3 additions & 3 deletions shared/contracts/custom-projects.contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ export const customProjectContract = contract.router({
},
body: contract.type<CustomProject>(),
},
deleteCustomProject: {
deleteCustomProjects: {
method: "DELETE",
path: "/custom-projects/:id",
path: "/custom-projects",
responses: {
200: contract.type<null>(),
},
body: null,
body: contract.type<{ ids: string[] }>(),
},
});

Expand Down
15 changes: 9 additions & 6 deletions shared/entities/custom-project.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export enum CARBON_REVENUES_TO_COVER {
}

export enum PROJECT_SPECIFIC_EMISSION {
ONE_EMISSION_FACTOR = 'One emission factor',
TWO_EMISSION_FACTORS = 'Two emission factors',
ONE_EMISSION_FACTOR = "One emission factor",
TWO_EMISSION_FACTORS = "Two emission factors",
}
export enum PROJECT_EMISSION_FACTORS {
TIER_1 = 'Tier 1 - Global emission factor',
TIER_2 = 'Tier 2 - Country-specific emission factor',
TIER_3 = 'Tier 3 - Project specific emission factor',
TIER_1 = "Tier 1 - Global emission factor",
TIER_2 = "Tier 2 - Country-specific emission factor",
TIER_3 = "Tier 3 - Project specific emission factor",
}

@Entity({ name: "custom_projects" })
Expand All @@ -54,7 +54,10 @@ export class CustomProject {
@Column({ name: "abatement_potential", type: "decimal", nullable: true })
abatementPotential?: number;

@ManyToOne(() => User, (user) => user.customProjects, { onDelete: "CASCADE" })
@ManyToOne(() => User, (user) => user.customProjects, {
onDelete: "CASCADE",
eager: true,
})
@JoinColumn({ name: "user_id" })
user?: User;

Expand Down

0 comments on commit 7f84c87

Please sign in to comment.