Skip to content

Commit

Permalink
notice issue with post-api, endpoint on cold start.
Browse files Browse the repository at this point in the history
  • Loading branch information
lokytech5 committed Sep 3, 2024
1 parent b07b5c7 commit a6ec9bf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
8 changes: 4 additions & 4 deletions backend/services/post-api/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ functions:
- Authorization
allowCredentials: true

getPostByHashtag:
getPostById:
handler: src/server.handler
events:
- http:
path: api/hashtags/{hashtag}/posts
path: api/posts/{postId}
method: get
cors:
origin: "http://localhost:3000"
Expand All @@ -101,11 +101,11 @@ functions:
- Authorization
allowCredentials: true

getPostById:
getPostByHashtag:
handler: src/server.handler
events:
- http:
path: api/posts/{postId}
path: api/hashtags/{hashtag}/posts
method: get
cors:
origin: "http://localhost:3000"
Expand Down
7 changes: 6 additions & 1 deletion frontend/app/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export interface RegisterData {
content: string;
}

export interface CommentResponse {
export interface Comment {
data: {
CommentID: string;
PostID: string;
Expand All @@ -156,4 +156,9 @@ export interface RegisterData {
},
meta: Record<string, never>;
}

export interface CommentResponse {
data: Comment[];
meta: Record<string, never>;
}

6 changes: 3 additions & 3 deletions frontend/app/hooks/useComments.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMutation } from '@tanstack/react-query'
import { CommentData, CommentResponse } from '../components/types';
import { CommentData, Comment } from '../components/types';
import { AxiosError } from 'axios';
import { postApiClient } from '../utils/apiClient';
import { showToastError, showToastSuccess } from '../utils/toastUtils';
Expand All @@ -9,9 +9,9 @@ interface ErrorResponse {
}

const useComments = (postId: string) => {
return useMutation <CommentResponse, AxiosError<ErrorResponse>, CommentData> (
return useMutation <Comment, AxiosError<ErrorResponse>, CommentData> (
async(commentData: CommentData) => {
const response = await postApiClient.post<CommentResponse>(`/api/posts/${postId}/comments`, commentData);
const response = await postApiClient.post<Comment>(`/api/posts/${postId}/comments`, commentData);
return response.data;
},
{
Expand Down
7 changes: 7 additions & 0 deletions frontend/app/hooks/usePostComments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

const usePostComments = () => {

}

export default usePostComments

0 comments on commit a6ec9bf

Please sign in to comment.