Increase rate limit range, fix bug with content search if no summary is present

This commit is contained in:
austinkelsay 2024-10-05 19:11:19 -05:00
parent b5d66e8de3
commit 094d2eaa37
3 changed files with 15 additions and 15 deletions

View File

@ -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"
}

View File

@ -19,16 +19,16 @@ const ContentDropdownItem = ({ content, onSelect }) => {
className="w-[100px] h-[100px] object-cover object-center border-round"
/>
<div className="flex-1 max-w-[80vw]">
<div className="text-lg text-900 font-bold">{content.title || content.name}</div>
<div className="w-full text-sm text-600 text-wrap line-clamp-2">{content.summary || content.description && (
<div className="text-lg text-900 font-bold">{content?.title || content?.name}</div>
<div className="w-full text-sm text-600 text-wrap line-clamp-2">{content?.summary || content?.description && (
<div className="text-xl mt-4">
{content.summary.split('\n').map((line, index) => (
{content?.summary?.split('\n').map((line, index) => (
<p key={index}>{line}</p>
))}
</div>
)}
</div>
{content.price && <div className="text-sm pt-6 text-gray-500">Price: {content.price}</div>}
{content?.price && <div className="text-sm pt-6 text-gray-500">Price: {content.price}</div>}
{content?.topics?.length > 0 && (
<div className="text-sm pt-6 text-gray-500">
{content.topics.map((topic) => (
@ -37,7 +37,7 @@ const ContentDropdownItem = ({ content, onSelect }) => {
</div>
)}
<div className="text-sm pt-6 text-gray-500">
{(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"}
</div>
</div>
<div className="flex flex-col justify-end">

View File

@ -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,
})