Skip to content

Commit 287f404

Browse files
committed
feat: preview
1 parent 3d185ad commit 287f404

File tree

3 files changed

+278
-4
lines changed

3 files changed

+278
-4
lines changed
Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { Controller, Get, Param } from '@nestjs/common';
22
import { ApiTags } from '@nestjs/swagger';
33
import { AgenciesService } from '@gitroom/nestjs-libraries/database/prisma/agencies/agencies.service';
4+
import { PostsService } from '@gitroom/nestjs-libraries/database/prisma/posts/posts.service';
45

56
@ApiTags('Public')
67
@Controller('/public')
78
export class PublicController {
8-
constructor(private _agenciesService: AgenciesService) {}
9+
constructor(
10+
private _agenciesService: AgenciesService,
11+
private _postsService: PostsService
12+
) {}
913
@Get('/agencies-list')
1014
async getAgencyByUser() {
1115
return this._agenciesService.getAllAgencies();
@@ -17,14 +21,32 @@ export class PublicController {
1721
}
1822

1923
@Get('/agencies-information/:agency')
20-
async getAgencyInformation(
21-
@Param('agency') agency: string,
22-
) {
24+
async getAgencyInformation(@Param('agency') agency: string) {
2325
return this._agenciesService.getAgencyInformation(agency);
2426
}
2527

2628
@Get('/agencies-list-count')
2729
async getAgenciesCount() {
2830
return this._agenciesService.getCount();
2931
}
32+
33+
@Get(`/posts/:id`)
34+
async getPreview(@Param('id') id: string) {
35+
return (await this._postsService.getPostsRecursively(id, true)).map(
36+
({ childrenPost, ...p }) => ({
37+
...p,
38+
...(p.integration
39+
? {
40+
integration: {
41+
id: p.integration.id,
42+
name: p.integration.name,
43+
picture: p.integration.picture,
44+
providerIdentifier: p.integration.providerIdentifier,
45+
profile: p.integration.profile,
46+
},
47+
}
48+
: {}),
49+
})
50+
);
51+
}
3052
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { ReactNode } from 'react';
2+
3+
export default async function AppLayout({ children }: { children: ReactNode }) {
4+
return children;
5+
}

0 commit comments

Comments
 (0)