commit 0f60ab69657677d24d5890cfcf774d062cff4490 Author: Korbs Date: Thu Mar 20 18:33:29 2025 -0400 :rocket: Init diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..c2d0201 --- /dev/null +++ b/.env.sample @@ -0,0 +1,3 @@ +SEND_TO="smithers@example.org" +SEND_FROM="Astro Test " +RESEND_API_KEY="re_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..016b59e --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# build output +dist/ + +# generated types +.astro/ + +# dependencies +node_modules/ + +# logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + +# environment variables +.env +.env.production + +# macOS-specific files +.DS_Store + +# jetbrains setting folder +.idea/ diff --git a/astro.config.mjs b/astro.config.mjs new file mode 100644 index 0000000..0dfb101 --- /dev/null +++ b/astro.config.mjs @@ -0,0 +1,11 @@ +// @ts-check +import { defineConfig } from 'astro/config'; + +import node from '@astrojs/node'; + +export default defineConfig({ + output: 'server', + adapter: node({ + mode: 'standalone' + }) +}); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..9d38770 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "form-while", + "type": "module", + "version": "0.0.1", + "scripts": { + "dev": "astro dev", + "build": "astro build", + "preview": "astro preview", + "astro": "astro" + }, + "dependencies": { + "@astrojs/node": "^9.1.3", + "astro": "^5.5.3", + "resend": "^4.1.2" + } +} \ No newline at end of file diff --git a/public/favicon.svg b/public/favicon.svg new file mode 100644 index 0000000..f157bd1 --- /dev/null +++ b/public/favicon.svg @@ -0,0 +1,9 @@ + + + + diff --git a/public/logo.png b/public/logo.png new file mode 100644 index 0000000..26dd79f Binary files /dev/null and b/public/logo.png differ diff --git a/src/actions/index.ts b/src/actions/index.ts new file mode 100644 index 0000000..a172525 --- /dev/null +++ b/src/actions/index.ts @@ -0,0 +1,33 @@ +import { ActionError, defineAction } from 'astro:actions' +import { z } from 'astro:schema' +import { Resend } from 'resend' + +const resend = new Resend(import.meta.env.RESEND_API_KEY) + +export const server = { + send: defineAction({ + input: z.object({ + email: z.string(), + name: z.string(), + message: z.string() + }), + accept: 'form', + handler: async (input, redirect) => { + const { data, error } = await resend.emails.send({ + from: import.meta.env.SEND_FROM, + to: [import.meta.env.SEND_TO], + subject: `From ${input.name} - ${input.email}`, + html: `${input.message}
From ${input.name} - ${input.email}` + }) + + if (error) { + throw new ActionError({ + code: 'BAD_REQUEST', + message: error.message + }) + } + + return data + } + }) +} \ No newline at end of file diff --git a/src/pages/index.astro b/src/pages/index.astro new file mode 100644 index 0000000..14436f9 --- /dev/null +++ b/src/pages/index.astro @@ -0,0 +1,130 @@ +--- +import { actions } from "astro:actions" +--- + + + + + + + + +
+ +
+

Contact Us

+
+
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ +
+
+
+
+
+

© 2025 Company Name LLC

+
+ + + + \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..8bf91d3 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "astro/tsconfigs/strict", + "include": [".astro/types.d.ts", "**/*"], + "exclude": ["dist"] +}