- Move secrets to Astro's typed astro:env/server (schema in astro.config.mjs);
removes process.env usage and the 3 TS2580 "Cannot find name 'process'" errors
without adding @types/node.
- Replace deprecated contacts.create({ audienceId }) with segments: [{ id }]
(env var RESEND_AUDIENCE_ID -> RESEND_SEGMENT_ID).
- Check the { error } return on both Resend calls: contact add is best-effort
(non-fatal); a failed confirmation send now returns 502 instead of a false 200.
- Type the waitlist fetch result in WaitlistForm.astro.
- Add @astrojs/check + typescript devDeps and an `npm run check` script.
Verified: npm run check (0 errors), npm run build, secret not inlined into the
build output, and a runtime smoke test of the validation/honeypot/GET paths.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
// @ts-check
|
|
import { defineConfig, envField } from 'astro/config';
|
|
import vercel from '@astrojs/vercel';
|
|
|
|
// Static by default (every page prerenders to HTML, zero client JS).
|
|
// The Vercel adapter is wired in so any single route can opt into
|
|
// per-request SSR later with `export const prerender = false;`.
|
|
// See README.md ("SSR per route") for how.
|
|
export default defineConfig({
|
|
output: 'static',
|
|
adapter: vercel(),
|
|
// Prefetch linked pages so SPA-style navigation feels instant.
|
|
prefetch: { prefetchAll: true, defaultStrategy: 'viewport' },
|
|
// Typed, validated server secrets for the waitlist endpoint. All optional so
|
|
// the build never requires them and the endpoint degrades gracefully when a
|
|
// key is absent (see src/pages/api/waitlist.ts). The @astrojs/vercel adapter
|
|
// reads these from process.env at runtime — never inlined into the bundle.
|
|
env: {
|
|
schema: {
|
|
RESEND_API_KEY: envField.string({ context: 'server', access: 'secret', optional: true }),
|
|
RESEND_SEGMENT_ID: envField.string({ context: 'server', access: 'secret', optional: true }),
|
|
WAITLIST_FROM_EMAIL: envField.string({
|
|
context: 'server',
|
|
access: 'secret',
|
|
optional: true,
|
|
default: 'PCBJam <hello@pcbjam.com>',
|
|
}),
|
|
},
|
|
},
|
|
});
|