Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

added a new route to remove the extension

Yevhenii Kc82457cd6d88
diff --git a/src/marketplace/extensions/dtos/delete-extension-params.dto.ts b/src/marketplace/extensions/dtos/delete-extension-params.dto.ts
new file mode 100644
index 000000000..861736f98
--- /dev/null
+++ b/src/marketplace/extensions/dtos/delete-extension-params.dto.ts
@@ -0,0 +1,6 @@
+import { IsNumberString } from 'class-validator'
+
+export class DeleteExtensionParams {
+ @IsNumberString()
+ readonly extensionId!: number
+}
diff --git a/src/marketplace/extensions/extensions.controller.ts b/src/marketplace/extensions/extensions.controller.ts
index e6a87c00f..b001cd8cd 100644
--- a/src/marketplace/extensions/extensions.controller.ts
+++ b/src/marketplace/extensions/extensions.controller.ts
@@ -2,6 +2,7 @@ import {
Body,
ConflictException,
Controller,
+ Delete,
Get,
NotFoundException,
Param,
@@ -12,6 +13,7 @@ import {
} from '@nestjs/common'
import { ApiParam, ApiQuery, ApiTags } from '@nestjs/swagger'
import { AddExtension } from './dtos/add-extension.dto'
+import { DeleteExtensionParams } from './dtos/delete-extension-params.dto'
import { GetExtensionParams } from './dtos/get-extension-params.dto'
import { GetExtensionsQueries } from './dtos/get-extensions-queries.dto'
import { Extension } from './extension.entity'
@@ -89,4 +91,21 @@ export class ExtensionsController {
return await this.extensionsService.save(extensionInstance)
}
+
+ @ApiParam({
+ name: 'extensionId',
+ description: 'Extension ID',
+ example: '1',
+ type: String,
+ })
+ @Delete(':extensionId')
+ async deleteExtension(@Param() params: DeleteExtensionParams): Promise<void> {
+ const extension = await this.extensionsService.findById(params.extensionId)
+
+ if (!extension) {
+ throw new NotFoundException('Extension not found.')
+ }
+
+ await this.extensionsService.delete(extension.id)
+ }
}
diff --git a/src/marketplace/extensions/extensions.service.ts b/src/marketplace/extensions/extensions.service.ts
index e2d3b22ba..1b11faae6 100644
--- a/src/marketplace/extensions/extensions.service.ts
+++ b/src/marketplace/extensions/extensions.service.ts
@@ -32,6 +32,10 @@ export class ExtensionsService {
return await this.findOne({ where: { id } })
}
+ async delete(id: number): Promise<void> {
+ await this.extensionRepository.delete({ id })
+ }
+
async findAndCount(
options: FindManyOptions<Extension>,
): Promise<[Extension[], number]> {