📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Implemented a route to get the project subscribers
Yevhenii Kulisidi8250ef036ab5
diff --git a/src/project/project.controller.ts b/src/project/project.controller.tsindex e294e1752..11d64c4a2 100644--- a/src/project/project.controller.ts+++ b/src/project/project.controller.ts@@ -882,11 +882,22 @@ export class ProjectController {}@Get(':projectId/subscribers')+ @Auth([UserType.ADMIN, UserType.CUSTOMER])async getSubscribers(@Param() params: GetSubscribersParamsDto,@Query() queries: GetSubscribersQueriesDto,- ): Promise<void> {- // TODO: Implement+ @CurrentUserId() userId: string,+ ) {+ const project = await this.projectService.getProject(+ params.projectId,+ userId,+ )++ if (!project) {+ throw new NotFoundException('Project not found.')+ }++ return await this.projectService.getSubscribers(params.projectId, queries)}@Patch(':projectId/subscribers/:subscriberId')diff --git a/src/project/project.service.ts b/src/project/project.service.tsindex 8142bad6f..2640fed61 100644--- a/src/project/project.service.ts+++ b/src/project/project.service.ts@@ -47,6 +47,7 @@ import { ActionTokenType } from 'src/action-tokens/action-token.entity'import { MailerService } from 'src/mailer/mailer.service'import { LetterTemplate } from 'src/mailer/letter'import { AddSubscriberType } from './types'+import { GetSubscribersQueriesDto } from './dto'dayjs.extend(utc)@@ -511,4 +512,15 @@ export class ProjectService {)await this.actionTokens.deleteActionToken(token)}++ async getSubscribers(projectId: string, queries: GetSubscribersQueriesDto) {+ const [subscribers, count] =+ await this.projectSubscriberRepository.findAndCount({+ skip: Number(queries.offset) || 0,+ take: Number(queries.limit) > 100 ? 100 : Number(queries.limit) || 100,+ where: { projectId },+ })++ return { subscribers, count }+ }}