Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
RESEND_API_KEY=your_resend_api_key_here
ROUTER_EMAIL_FROM=info@router.so
ROUTER_APP_URL=http://localhost:3000
AUTH_SECRET=your_nextauth_secret_here
FORM_SUBMISSION_SECRET=replace_with_a_long_random_secret
CRON_SECRET=replace_with_a_long_random_secret
FORMS_NAV_ENABLED=false
FORMS_PUBLIC_ENABLED=true
NODE_ENV=development

# optional if you want to do GitHub OAuth
Expand All @@ -9,7 +15,21 @@ AUTH_GITHUB_SECRET=github_app_secret
# Production database
POSTGRES_URL="postgres://user:password@host:port/database?sslmode=require"

# Local development against a plain PostgreSQL server (optional).
# @vercel/postgres needs Neon's wsproxy in front of a non-Neon database:
# docker run -d -p 5433:80 -e ALLOW_ADDR_REGEX='.*' ghcr.io/neondatabase/wsproxy:latest
# POSTGRES_WS_PROXY=localhost:5433
# POSTGRES_WS_TARGET=host.docker.internal:5432

# PostHog
# You can get your PostHog key from https://app.posthog.com/organization/settings
NEXT_PUBLIC_POSTHOG_KEY=your_posthog_key_here
NEXT_PUBLIC_POSTHOG_HOST=app.posthog.com
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com

# Stripe is optional for credential-free builds. Configure these only when enabling billing.
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_PRO_MONTHLY_PRICE_ID=price_...
STRIPE_PRO_ANNUAL_PRICE_ID=price_...
STRIPE_BUSINESS_MONTHLY_PRICE_ID=price_...
STRIPE_BUSINESS_ANNUAL_PRICE_ID=price_...
132 changes: 132 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: CI

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
application:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Comment thread
brijr marked this conversation as resolved.
with:
persist-credentials: false
- uses: pnpm/action-setup@v4
with:
version: 9.15.9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm lint
- run: pnpm typecheck
- run: pnpm test:unit
- name: Credential-free production build
run: pnpm build
env:
AUTH_SECRET: credential-free-build-secret-for-ci-only
FORM_SUBMISSION_SECRET: credential-free-form-secret-for-ci-only
FORM_RATE_LIMIT_SECRET: credential-free-rate-secret-for-ci-only
- run: pnpm check:server-actions

postgres:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: router_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: pnpm/action-setup@v4
with:
version: 9.15.9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Apply forward migrations
env:
PGURL: postgresql://postgres:postgres@localhost:5432/router_test
run: |
chmod +x scripts/test-forward-migrations.sh
scripts/test-forward-migrations.sh
- run: pnpm test:db
env:
TEST_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/router_test

browser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: pnpm/action-setup@v4
with:
version: 9.15.9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm exec playwright install --with-deps chromium
- run: pnpm test:browser

wordpress:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
- run: chmod +x integrations/wordpress/check.sh integrations/wordpress/package.sh
- run: integrations/wordpress/check.sh

wordpress-runtime:
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
config: [".wp-env.6.6.json", ".wp-env.latest.json"]
theme: ["twentytwentyfour", "twentytwentyone"]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: pnpm/action-setup@v4
with:
version: 9.15.9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm exec playwright install --with-deps chromium
- run: pnpm exec wp-env start --config="${{ matrix.config }}" --update
- run: chmod +x integrations/wordpress/test-matrix.sh
- run: integrations/wordpress/test-matrix.sh "${{ matrix.config }}" "${{ matrix.theme }}"
- if: always()
run: pnpm exec wp-env stop --config="${{ matrix.config }}"
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

# testing
/coverage
/playwright-report/
/test-results/

# next.js
/.next/
Expand All @@ -34,7 +36,9 @@ yarn-error.log*

# typescript
*.tsbuildinfo
next-env.d.ts

.vscode
.zshrc
.zshrc

# generated WordPress release artifacts (the public release ZIP is tracked)
/integrations/wordpress/dist/
11 changes: 11 additions & 0 deletions .wp-env.6.6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
"core": "WordPress/WordPress#6.6",
"phpVersion": "8.2",
"plugins": [
"./integrations/wordpress/router-forms",
"./integrations/wordpress/test-fixtures/router-forms-test-api"
],
"testsEnvironment": false,
"port": 8888
}
11 changes: 11 additions & 0 deletions .wp-env.latest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
"core": null,
"phpVersion": "8.2",
"plugins": [
"./integrations/wordpress/router-forms",
"./integrations/wordpress/test-fixtures/router-forms-test-api"
],
"testsEnvironment": false,
"port": 8888
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

This is a simple router for forms. [Watch a Demo](https://x.com/youngbloodcyb/status/1831808232966516972)

Router supports optional first-class forms without changing its headless endpoint contract. Forms can be published on `forms.router.so`, embedded in an approved website, or rendered through the included WordPress block and shortcode. See [the Forms implementation notes](docs/forms/README.md) and [release runbook](docs/forms/release-runbook.md).

# Self-Hosting router

## Prerequisites
Expand Down
22 changes: 22 additions & 0 deletions __tests__/analytics.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { describe, expect, it } from "vitest";
import { normalizePostHogHost } from "../lib/analytics/server";

describe("PostHog server analytics", () => {
it("normalizes a documented bare host to an absolute HTTPS URL", () => {
expect(normalizePostHogHost("app.posthog.com")).toBe(
"https://app.posthog.com"
);
});

it("preserves an explicit protocol and proxy path", () => {
expect(normalizePostHogHost("http://localhost:3000/ingest/")).toBe(
"http://localhost:3000/ingest"
);
});

it("rejects unsupported protocols", () => {
expect(() => normalizePostHogHost("ftp://posthog.example")).toThrow(
"HTTP or HTTPS"
);
});
});
15 changes: 15 additions & 0 deletions __tests__/cron-config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";

describe("scheduled maintenance", () => {
it("runs form rate-bucket pruning at least hourly", () => {
const config = JSON.parse(readFileSync("vercel.json", "utf8")) as {
crons: Array<{ path: string; schedule: string }>;
};

expect(config.crons).toContainEqual({
path: "/api/cron/forms-maintenance",
schedule: "17 * * * *",
});
});
});
Loading
Loading