From 094d2eaa37ac50466d7e6ac828150b8d99741131 Mon Sep 17 00:00:00 2001 From: austinkelsay Date: Sat, 5 Oct 2024 19:11:19 -0500 Subject: [PATCH] Increase rate limit range, fix bug with content search if no summary is present --- prisma/schema.prisma | 16 ++++++++-------- .../content/dropdowns/ContentDropdownItem.js | 10 +++++----- src/middleware.js | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 61d1bc5..729ad31 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,14 +1,14 @@ -// datasource db { -// provider = "postgresql" -// url = env("DATABASE_URL") -// } - datasource db { - provider = "postgresql" - url = env("POSTGRES_PRISMA_URL") - directUrl = env("POSTGRES_URL_NON_POOLING") + provider = "postgresql" + url = env("DATABASE_URL") } +// datasource db { +// provider = "postgresql" +// url = env("POSTGRES_PRISMA_URL") +// directUrl = env("POSTGRES_URL_NON_POOLING") +// } + generator client { provider = "prisma-client-js" } diff --git a/src/components/content/dropdowns/ContentDropdownItem.js b/src/components/content/dropdowns/ContentDropdownItem.js index da8e56b..3476b88 100644 --- a/src/components/content/dropdowns/ContentDropdownItem.js +++ b/src/components/content/dropdowns/ContentDropdownItem.js @@ -19,16 +19,16 @@ const ContentDropdownItem = ({ content, onSelect }) => { className="w-[100px] h-[100px] object-cover object-center border-round" />
-
{content.title || content.name}
-
{content.summary || content.description && ( +
{content?.title || content?.name}
+
{content?.summary || content?.description && (
- {content.summary.split('\n').map((line, index) => ( + {content?.summary?.split('\n').map((line, index) => (

{line}

))}
)}
- {content.price &&
Price: {content.price}
} + {content?.price &&
Price: {content.price}
} {content?.topics?.length > 0 && (
{content.topics.map((topic) => ( @@ -37,7 +37,7 @@ const ContentDropdownItem = ({ content, onSelect }) => {
)}
- {(content.published_at || content.created_at) ? `Published: ${formatUnixTimestamp(content.published_at || content.created_at)}` : "not yet published"} + {(content?.published_at || content?.created_at) ? `Published: ${formatUnixTimestamp(content?.published_at || content?.created_at)}` : "not yet published"}
diff --git a/src/middleware.js b/src/middleware.js index e4fefaf..b30b280 100644 --- a/src/middleware.js +++ b/src/middleware.js @@ -10,7 +10,7 @@ const localRatelimit = { limit: async (key) => { const now = Date.now(); const windowMs = 10 * 1000; // 10 seconds - const maxRequests = 25; + const maxRequests = 40; const requestLog = inMemoryStore.get(key) || []; const windowStart = now - windowMs; @@ -36,7 +36,7 @@ const localRatelimit = { const ratelimit = process.env.NODE_ENV === 'production' ? new Ratelimit({ redis: kv, - limiter: Ratelimit.slidingWindow(25, '10 s'), + limiter: Ratelimit.slidingWindow(40, '10 s'), analytics: true, timeout: 1000, })