Skip to content

Commit 87e579f

Browse files
feat: integrate Resend for email, add robust CSRF protection, modularize database access, and implement comprehensive Vitest/Playwright testing infrastructure.
1 parent be98a97 commit 87e579f

84 files changed

Lines changed: 6511 additions & 2459 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# === REQUIRED ===
2+
# Stripe secret key (starts with sk_live_ or sk_test_)
3+
STRIPE_SECRET_KEY="sk_test_..."
4+
5+
# Stripe webhook signing secret (from Stripe Dashboard > Webhooks)
6+
STRIPE_WEBHOOK_SECRET="whsec_..."
7+
8+
# Better Auth secret key (generate with: openssl rand -hex 32)
9+
BETTER_AUTH_SECRET="change-me-to-a-random-64-char-hex-string"
10+
11+
# Better Auth base URL (your app's public URL)
12+
BETTER_AUTH_URL="http://localhost:4321"
13+
14+
# === OPTIONAL ===
15+
# Stripe publishable key (starts with pk_live_ or pk_test_)
16+
STRIPE_PUBLISHABLE_KEY="pk_test_..."
17+
18+
# Admin email — used to identify the admin account
19+
ADMIN_EMAIL="admin@buffbook.com"
20+
21+
# Google Analytics 4 measurement ID (defaults to hardcoded ID if not set)
22+
GA_MEASUREMENT_ID="G-NG1D7QNQS7"
23+
24+
# Resend API key for transactional emails (password reset, verification)
25+
# Get it from https://resend.com — emails only send if this is configured
26+
RESEND_API_KEY="re_..."
27+

.github/workflows/test.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
unit:
11+
name: Unit & Component Tests
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 22
18+
cache: "npm"
19+
- run: npm ci
20+
- run: npm run test:coverage
21+
22+
e2e:
23+
name: E2E Tests
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 10
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: actions/setup-node@v4
29+
with:
30+
node-version: 22
31+
cache: "npm"
32+
- run: npm ci
33+
- run: npx playwright install --with-deps chromium
34+
- name: Run Playwright tests
35+
run: npm run test:e2e
36+
- uses: actions/upload-artifact@v4
37+
if: failure()
38+
with:
39+
name: playwright-report
40+
path: playwright-report/
41+
retention-days: 7
42+
43+
build:
44+
name: Build Check
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v4
48+
- uses: actions/setup-node@v4
49+
with:
50+
node-version: 22
51+
cache: "npm"
52+
- run: npm ci
53+
- run: npm run build

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pnpm-debug.log*
1414

1515
# ── Environment variables ──────────────────────────────────────────────────
1616
.env
17+
.env.local
1718
.env.production
1819
.dev.vars
1920

@@ -32,3 +33,8 @@ Thumbs.db
3233

3334
# ── Logs ───────────────────────────────────────────────────────────────────
3435
*.log
36+
37+
# ── Testing ─────────────────────────────────────────────────────────────────
38+
test-results/
39+
playwright-report/
40+
coverage/

astro.config.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ export default defineConfig({
279279
}), sitemap({
280280
filter: (page) =>
281281
page !== "https://buffbook.org/admin" &&
282-
page !== "https://buffbook.org/api/admin/setup" &&
282+
page !== "https://buffbook.org/api/admin/create-admin" &&
283283
page !== "https://buffbook.org/api/admin/upload-plan"
284284
}), react()],
285285

@@ -289,6 +289,11 @@ export default defineConfig({
289289
resolve: {
290290
alias: {
291291
'@components': resolve(__dirname, './src/components'),
292+
'@lib': resolve(__dirname, './src/lib'),
293+
'@db': resolve(__dirname, './src/db'),
294+
'@pages': resolve(__dirname, './src/pages'),
295+
'@layouts': resolve(__dirname, './src/layouts'),
296+
'@data': resolve(__dirname, './src/data'),
292297
},
293298
},
294299
plugins: [tailwindcss()],
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE `user` ADD `admin` integer DEFAULT false NOT NULL;

drizzle/0006_omniscient_speed.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ALTER TABLE `plan_requests` ADD `sex` text;--> statement-breakpoint
2+
ALTER TABLE `plan_requests` ADD `steps` integer;--> statement-breakpoint
3+
ALTER TABLE `plan_requests` ADD `jobType` text;--> statement-breakpoint
4+
ALTER TABLE `plan_requests` ADD `jobDescription` text;--> statement-breakpoint
5+
ALTER TABLE `plan_requests` ADD `hasCardio` text;--> statement-breakpoint
6+
ALTER TABLE `plan_requests` ADD `cardioDetails` text;

0 commit comments

Comments
 (0)