diff --git a/apps/contact/app/api/contact/route.ts b/apps/contact/app/api/contact/route.ts index 0a796290..d8edb665 100644 --- a/apps/contact/app/api/contact/route.ts +++ b/apps/contact/app/api/contact/route.ts @@ -1,6 +1,5 @@ import { Client, isFullPage } from "@notionhq/client"; -import { Ratelimit } from "@upstash/ratelimit"; -import { Redis } from "@upstash/redis"; + import { nanoid } from "nanoid"; import z from "zod"; @@ -25,18 +24,12 @@ const { MENTION_EMAILS, MENTION_IDS, NOTION_DATABASE_ID, - UPSTASH_REDIS_REST_URL, - UPSTASH_REDIS_REST_TOKEN, + IS_OFFLINE, } = process.env; const notion = new Client({ auth: NOTION_TOKEN }); -const redis = new Redis({ - url: UPSTASH_REDIS_REST_URL, - token: UPSTASH_REDIS_REST_TOKEN, -}); - const createPayload = (name: string, email: string, url: string) => ({ channel: SLACK_CHANNEL, blocks: [ @@ -137,16 +130,25 @@ const mentionPerson = ({ id, email }: { id: string; email: string }) => [ ]; const getMentions = () => { - if (MENTION_EMAILS && MENTION_IDS) { - const emails = MENTION_EMAILS.split(","); - const ids = MENTION_IDS.split(","); - - if (emails.length && ids.length) { - return ids.map((id, i) => ({ - id, - email: emails[i], - })); + try { + if ( + MENTION_EMAILS && + MENTION_IDS && + typeof MENTION_EMAILS === "string" && + typeof MENTION_IDS === "string" + ) { + const emails = MENTION_EMAILS.split(",").filter(Boolean); + const ids = MENTION_IDS.split(",").filter(Boolean); + + if (emails.length && ids.length) { + return ids.map((id, i) => ({ + id: id.trim(), + email: emails[i]?.trim() || "", + })); + } } + } catch (error) { + console.error("Error in getMentions:", error); } return []; }; @@ -265,32 +267,6 @@ const processContact = async (event: { } }; -const allowRequest = async (request: Request & { ip?: string }) => { - try { - const ip = request.ip ?? "127.0.0.1"; - - const ratelimit = new Ratelimit({ - limiter: Ratelimit.fixedWindow(1, "30 s"), - /** Use fromEnv() to automatically load connection secrets from your environment - * variables. For instance when using the Vercel integration. - * - * This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from - * your environment using `import.meta.env`. - */ - redis, - }); - - const response = await ratelimit.limit(ip); - return response; - } catch (error) { - throw { - body: { - message: error, - }, - }; - } -}; - export async function OPTIONS() { return new Response(null, { status: 200, @@ -318,8 +294,7 @@ export async function POST(request: Request) { if (!body || bodyValidationResult.error) { return new Response( JSON.stringify({ - message: - bodyValidationResult.error?.message || "No body was found", + message: bodyValidationResult.error?.message || "No body was found", }), { status: 400, @@ -333,31 +308,12 @@ export async function POST(request: Request) { const { name, email, message, hasConsent } = body; if (!hasConsent) { - return new Response( - JSON.stringify({ message: "No consent by user" }), - { - status: 403, - headers: { - ...corsHeaders, - }, - }, - ); - } - - const { success, limit, reset, remaining } = await allowRequest(request); - - if (!success) { - return new Response( - JSON.stringify({ - message: "Too many requests. Please try again in a minute", - }), - { - status: 429, - headers: { - ...corsHeaders, - }, + return new Response(JSON.stringify({ message: "No consent by user" }), { + status: 403, + headers: { + ...corsHeaders, }, - ); + }); } await processContact({ @@ -375,9 +331,6 @@ export async function POST(request: Request) { status: 200, headers: { ...corsHeaders, - "X-RateLimit-Limit": limit.toString(), - "X-RateLimit-Remaining": remaining.toString(), - "X-RateLimit-Reset": reset.toString(), }, }, ); diff --git a/apps/website/astro.config.mjs b/apps/website/astro.config.mjs index f8cbac61..b8594d23 100644 --- a/apps/website/astro.config.mjs +++ b/apps/website/astro.config.mjs @@ -1,7 +1,7 @@ import { defineConfig } from 'astro/config'; import tailwind from '@astrojs/tailwind'; import react from '@astrojs/react'; -import vercel from '@astrojs/vercel/serverless' +import vercel from '@astrojs/vercel' import createRemarkPlugin from '@crocoder-dev/remark-plugin'; import image from '@astrojs/image'; diff --git a/apps/website/package.json b/apps/website/package.json index 0936e73e..a1e85d8a 100644 --- a/apps/website/package.json +++ b/apps/website/package.json @@ -3,7 +3,6 @@ "module": "index.ts", "type": "module", "dependencies": { - "@astrojs/image": "^0.18.0", "@astrojs/react": "^4.1.2", "@astrojs/rss": "^4.0.11", "@astrojs/tailwind": "^6.0.2", diff --git a/bun.lockb b/bun.lockb index c677a859..20e35b32 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/packages/tailwind/package.json b/packages/tailwind/package.json index 6d8d88ef..7dd1548a 100644 --- a/packages/tailwind/package.json +++ b/packages/tailwind/package.json @@ -8,6 +8,7 @@ "dependencies": { "@tailwindcss/forms": "0.5.9", "@tailwindcss/typography": "0.5.15", - "tailwind-bootstrap-grid": "6.0.0" + "tailwind-bootstrap-grid": "6.0.0", + "@tailwindcss/postcss": "^4.1.11" } } diff --git a/packages/tailwind/postcss.config.js b/packages/tailwind/postcss.config.js index 12a703d9..5793c42c 100644 --- a/packages/tailwind/postcss.config.js +++ b/packages/tailwind/postcss.config.js @@ -1,6 +1,7 @@ module.exports = { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, + plugins: [ + require('@tailwindcss/postcss'), + require('autoprefixer'), + ], }; +