Skip to content
Snippets Groups Projects
Commit 1c281068 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

Merge branch 'feat/post-details' into 'dev'

feat(post-details) : add new endpoint (Get post by id)

See merge request web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server!41
parents 18a18c2c 42b9e2c5
No related branches found
No related tags found
3 merge requests!46Recette,!45Dev,!41feat(post-details) : add new endpoint (Get post by id)
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([
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment