diff --git a/src/posts/posts.controller.ts b/src/posts/posts.controller.ts index e01f92931c85584af88c6f77a0ee4b9b758fee2d..dbac88f835e0fb7ef5003369ddead24b3d86230f 100644 --- a/src/posts/posts.controller.ts +++ b/src/posts/posts.controller.ts @@ -1,4 +1,4 @@ -import { Controller, Get, HttpService, Query } from '@nestjs/common'; +import { Controller, Get, HttpService, Param, Query } from '@nestjs/common'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { ApiQuery } from '@nestjs/swagger'; @@ -35,6 +35,17 @@ export class PostsController { .pipe(map((response) => response.data)); } + @Get(':id') + public async getPostbyId(@Param('id') id: string): Promise<Observable<{ posts: Post }>> { + return this.httpService + .get(`${process.env.GHOST_HOST_AND_PORT}/ghost/api/v3/content/posts/` + id, { + params: { + key: process.env.GHOST_CONTENT_API_KEY, + include: 'tags,authors', + }, + }) + .pipe(map((response) => response.data)); + } @Get('tags') public async findAllTags(): Promise<{ public: Tag[]; commune: Tag[]; others: Tag[] }> { return Promise.all([