diff --git a/config/index.ts b/config/index.ts index f262fc47..96584c42 100644 --- a/config/index.ts +++ b/config/index.ts @@ -14,7 +14,7 @@ interface Config { const createConfig: () => Config = () => { if (!process.env.NEXT_PUBLIC_SERVER_URL) throw new Error("no api server url"); - if (!process.env.NODE_ENV) throw new Error("no node env "); + if (!process.env.NODE_ENV) throw new Error("no node env"); return { baseURL: process.env.NEXT_PUBLIC_SERVER_URL, diff --git a/pages/api/revalidate-portfolio.ts b/pages/api/revalidate-portfolio.ts deleted file mode 100644 index c37ba320..00000000 --- a/pages/api/revalidate-portfolio.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { NextApiRequest, NextApiResponse } from "next"; - -export default async function handler( - req: NextApiRequest, - res: NextApiResponse, -) { - if (req.method !== "POST") { - return res - .status(400) - .json({ error: "Invalid HTTP method. Only POST method is allowed." }); - } - - try { - await res.revalidate(`/portfolio/${req.body.portfolioId}`); - return res.json({ revalidated: true }); - } catch (err) { - return res.status(500).send(`Error revalidating: ${err}`); - } -} diff --git a/pages/portfolio/[portfolioId]/index.tsx b/pages/portfolio/[portfolioId]/index.tsx index 2f1b08ac..2977dc3a 100644 --- a/pages/portfolio/[portfolioId]/index.tsx +++ b/pages/portfolio/[portfolioId]/index.tsx @@ -6,7 +6,7 @@ import { PortfolioPlayer, AppSideMenu, } from "@/components"; -import type { GetStaticProps } from "next"; +import type { GetServerSideProps } from "next"; import httpClient from "@/apis"; import { Portfolio } from "@/types/portfolio.interface"; import { getFileDownloadUrl } from "@/utils/file"; @@ -106,15 +106,9 @@ export default function PortfolioIdPage({ ); } -export const getStaticPaths = async () => { - return { - paths: [], - fallback: "blocking", - }; -}; +export const getServerSideProps: GetServerSideProps = async (context) => { + const { portfolioId } = context.query; -export const getStaticProps: GetStaticProps = async (context) => { - const portfolioId = context.params ? context.params.portfolioId : 0; const { data: portfolio, is403 } = await httpClient.portfolio .getById({ params: { id: portfolioId }, @@ -128,6 +122,5 @@ export const getStaticProps: GetStaticProps = async (context) => { portfolioId, is403, }, - revalidate: 6000, }; }; diff --git a/utils/date.spec.ts b/utils/date.spec.ts index 006f8cdc..f0dcadd4 100644 --- a/utils/date.spec.ts +++ b/utils/date.spec.ts @@ -8,14 +8,6 @@ test("koreanDate test - after 2000", () => { expect(getKoreanDate(new Date("December 17, 2005"))).toBe("2005년 12월 17일"); }); -test("timeAgo test - before 2000", () => { - expect(getTimeAgo(new Date("December 17, 1995"))).toBe("27년 전"); -}); - -test("timeAgo test - after 2000", () => { - expect(getTimeAgo(new Date("December 17, 2005"))).toBe("17년 전"); -}); - test("timeAgo test - now", () => { expect(getTimeAgo(new Date())).toBe("방금"); });