-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix/performance-issues: updated listing pages to use front end cache …
…& updated api urls
- Loading branch information
1 parent
25a6539
commit 7164941
Showing
26 changed files
with
784 additions
and
332 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use server' | ||
export const getAllProjects = async (queryParams: any, currentPage: number, limit = 0) => { | ||
const requestOptions: RequestInit = { method: "GET", cache: 'force-cache', next: { tags: ['project-list']}}; | ||
const response = await fetch( | ||
`${process.env.DIRECTORY_API_URL}/v1/projects?page=${currentPage}&limit=${limit}&${new URLSearchParams(queryParams)}`, | ||
requestOptions | ||
); | ||
const result = await response.json(); | ||
if (!response?.ok) { | ||
return { error: { statusText: response?.statusText } }; | ||
} | ||
const formattedData = result?.projects?.map((project: any) => { | ||
return { | ||
id: project?.uid, | ||
name: project?.name, | ||
logo: project?.logo?.url, | ||
description: project?.description, | ||
maintainingTeam: project?.maintainingTeam, | ||
lookingForFunding: project?.lookingForFunding, | ||
tagline: project?.tagline, | ||
}; | ||
}); | ||
return { data: { formattedData, totalProjects: result?.count } }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"use server"; | ||
|
||
import { ITeamResponse } from "@/types/teams.types"; | ||
import { getHeader } from "@/utils/common.utils"; | ||
|
||
const teamsAPI = `${process.env.DIRECTORY_API_URL}/v1/teams`; | ||
|
||
export const getTeamList = async (queryParams: any, currentPage = 1, limit = 50) => { | ||
const requestOptions: RequestInit = { method: 'GET', headers: getHeader(''), cache: 'force-cache', next: { tags: ['team-list'] } }; | ||
const response = await fetch(`${teamsAPI}?page=${currentPage}&limit=${limit}&${new URLSearchParams(queryParams)}`, requestOptions); | ||
const result = await response.json(); | ||
if (!response?.ok) { | ||
return { isError: true }; | ||
} | ||
const formattedData = result?.teams?.map((team: ITeamResponse) => { | ||
return { | ||
id: team?.uid, | ||
name: team?.name, | ||
logo: team?.logo?.url, | ||
shortDescription: team?.shortDescription, | ||
industryTags: team?.industryTags || [], | ||
}; | ||
}); | ||
return { data: formattedData, totalItems: result?.count }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { revalidateTag } from "next/cache"; | ||
import { NextRequest } from "next/server"; | ||
|
||
const BEARER_REGEX:any= /Bearer\s+(.+)/; | ||
|
||
export async function POST(request: NextRequest) { | ||
const body = await request.json(); | ||
const authToken = request.headers.get("Authorization"); | ||
const matcheResult = authToken?.match(BEARER_REGEX); | ||
const token = matcheResult ? matcheResult[1] : null; | ||
if (process.env.REVALIDATE_TOKEN !== token) { | ||
return Response.json({ message: "UnAuthorized" }, { status: 401 }); | ||
} | ||
if (!Array.isArray(body.tags)) { | ||
return Response.json(null, { status: 400 }); | ||
} | ||
body?.tags?.map((tag: string) => { | ||
revalidateTag(tag); | ||
}); | ||
return Response.json({ message: "Success" }, { status: 200 }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.