create-ailk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +39 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +80 -0
- package/dist/copy.d.ts +8 -0
- package/dist/copy.js +109 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/lib/pro-callout.d.ts +12 -0
- package/dist/lib/pro-callout.js +20 -0
- package/dist/parse-args.d.ts +13 -0
- package/dist/parse-args.js +81 -0
- package/dist/programmatic.d.ts +49 -0
- package/dist/programmatic.js +89 -0
- package/dist/substitute.d.ts +31 -0
- package/dist/substitute.js +45 -0
- package/dist/validate.d.ts +8 -0
- package/dist/validate.js +70 -0
- package/package.json +47 -0
- package/templates/.claude/.gitkeep +0 -0
- package/templates/.claude/agents/web.md +80 -0
- package/templates/.claude/rules/architecture.md +62 -0
- package/templates/.claude/rules/preserve-existing-style.md +51 -0
- package/templates/.claude/skills/README.md +43 -0
- package/templates/.claude/skills/add-schema/SKILL.md +270 -0
- package/templates/.claude/skills/add-schema/references/conflict-handling.md +200 -0
- package/templates/.claude/skills/add-schema/references/file-finding.md +123 -0
- package/templates/.claude/skills/add-schema/references/schema-types.md +131 -0
- package/templates/.claude/skills/audit-site/SKILL.md +213 -0
- package/templates/.claude/skills/audit-site/references/common-errors.md +113 -0
- package/templates/.claude/skills/audit-site/references/findings-glossary.md +138 -0
- package/templates/.claude/skills/audit-site/references/severity-levels.md +114 -0
- package/templates/.claude/skills/provision-config/SKILL.md +243 -0
- package/templates/.claude/skills/provision-config/references/env-vars-template.md +184 -0
- package/templates/.claude/skills/provision-config/references/runbook-template.md +248 -0
- package/templates/.claude/skills/provision-config/references/vercel-json-template.md +98 -0
- package/templates/.claude/skills/scaffold-auth/SKILL.md +261 -0
- package/templates/.claude/skills/scaffold-auth/references/env-vars.md +91 -0
- package/templates/.claude/skills/scaffold-auth/references/oauth-app-setup.md +171 -0
- package/templates/.claude/skills/scaffold-commerce/SKILL.md +310 -0
- package/templates/.claude/skills/scaffold-commerce/references/lookup-keys-template.md +71 -0
- package/templates/.claude/skills/scaffold-commerce/references/marketplace-brand-pages.md +83 -0
- package/templates/.claude/skills/scaffold-commerce/templates/marketplace-cta-route.tsx.tmpl +72 -0
- package/templates/.claude/skills/scaffold-page/SKILL.md +243 -0
- package/templates/.claude/skills/scaffold-page/references/page-types.md +169 -0
- package/templates/.claude/skills/scaffold-page/templates/content.mdx.tmpl +28 -0
- package/templates/.claude/skills/scaffold-page/templates/route.tsx.tmpl +28 -0
- package/templates/.claude/skills/suggest-site-pages/SKILL.md +242 -0
- package/templates/.claude/skills/suggest-site-pages/references/categories.md +287 -0
- package/templates/.env.example +205 -0
- package/templates/.gitkeep +2 -0
- package/templates/CLAUDE.md +142 -0
- package/templates/CONVENTIONS.md +222 -0
- package/templates/README.md +110 -0
- package/templates/apps/api/.env.example +40 -0
- package/templates/apps/api/CLAUDE.md +63 -0
- package/templates/apps/api/api/index.ts +144 -0
- package/templates/apps/api/jest.config.cjs +74 -0
- package/templates/apps/api/package.json +54 -0
- package/templates/apps/api/src/__tests__/factories/content-fixture.ts +138 -0
- package/templates/apps/api/src/__tests__/factories/index.ts +70 -0
- package/templates/apps/api/src/__tests__/factories/lead-fixture.ts +82 -0
- package/templates/apps/api/src/__tests__/index.test.ts +118 -0
- package/templates/apps/api/src/__tests__/server.test.ts +207 -0
- package/templates/apps/api/src/__tests__/services/enrichment-shim.test.ts +126 -0
- package/templates/apps/api/src/__tests__/setup.ts +24 -0
- package/templates/apps/api/src/cli.ts +30 -0
- package/templates/apps/api/src/config/__tests__/index.test.ts +97 -0
- package/templates/apps/api/src/config/index.ts +56 -0
- package/templates/apps/api/src/index.ts +32 -0
- package/templates/apps/api/src/lib/__mocks__/prisma-client.js +15 -0
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +45 -0
- package/templates/apps/api/src/lib/__tests__/content-adapter.test.ts +178 -0
- package/templates/apps/api/src/lib/__tests__/error-serializer.test.ts +100 -0
- package/templates/apps/api/src/lib/__tests__/errors.test.ts +94 -0
- package/templates/apps/api/src/lib/__tests__/file-fallback.test.ts +144 -0
- package/templates/apps/api/src/lib/__tests__/fixtures/HomePage/home.mdx +8 -0
- package/templates/apps/api/src/lib/__tests__/lead-capture-store.test.ts +227 -0
- package/templates/apps/api/src/lib/__tests__/outbound-http.test.ts +125 -0
- package/templates/apps/api/src/lib/__tests__/prisma.test.ts +165 -0
- package/templates/apps/api/src/lib/__tests__/require-paid-tier.test.ts +129 -0
- package/templates/apps/api/src/lib/__tests__/stripe.test.ts +74 -0
- package/templates/apps/api/src/lib/content-adapter.ts +86 -0
- package/templates/apps/api/src/lib/error-serializer.ts +77 -0
- package/templates/apps/api/src/lib/errors.ts +95 -0
- package/templates/apps/api/src/lib/file-fallback.ts +87 -0
- package/templates/apps/api/src/lib/lead-capture-store.ts +110 -0
- package/templates/apps/api/src/lib/locales.ts +201 -0
- package/templates/apps/api/src/lib/outbound-http.ts +122 -0
- package/templates/apps/api/src/lib/prisma.ts +21 -0
- package/templates/apps/api/src/lib/require-paid-tier.ts +53 -0
- package/templates/apps/api/src/lib/stripe.ts +30 -0
- package/templates/apps/api/src/lib/webhook-idempotency.ts +92 -0
- package/templates/apps/api/src/middleware/__tests__/adversarial/bearer-token-format.test.ts +111 -0
- package/templates/apps/api/src/middleware/__tests__/adversarial/cookie-or-bearer-precedence.test.ts +172 -0
- package/templates/apps/api/src/middleware/__tests__/adversarial/csrf-bearer-skip.test.ts +119 -0
- package/templates/apps/api/src/middleware/__tests__/adversarial/csrf-cookie-path.test.ts +138 -0
- package/templates/apps/api/src/middleware/__tests__/adversarial/session-fixation.test.ts +149 -0
- package/templates/apps/api/src/middleware/__tests__/adversarial/session-timeout.test.ts +139 -0
- package/templates/apps/api/src/middleware/__tests__/auth.bearer-path.test.ts +175 -0
- package/templates/apps/api/src/middleware/__tests__/auth.both-present-precedence.test.ts +76 -0
- package/templates/apps/api/src/middleware/__tests__/auth.cookie-path.test.ts +153 -0
- package/templates/apps/api/src/middleware/__tests__/auth.neither-present.test.ts +72 -0
- package/templates/apps/api/src/middleware/__tests__/rate-limit.test.ts +292 -0
- package/templates/apps/api/src/middleware/auth.ts +246 -0
- package/templates/apps/api/src/middleware/rate-limit.ts +132 -0
- package/templates/apps/api/src/openapi/__tests__/openapi.test.ts +129 -0
- package/templates/apps/api/src/openapi/index.ts +12 -0
- package/templates/apps/api/src/openapi/spec.ts +408 -0
- package/templates/apps/api/src/routes/auth/__tests__/auth-tokens.functional.test.ts +193 -0
- package/templates/apps/api/src/routes/auth/__tests__/auth-user.functional.test.ts +201 -0
- package/templates/apps/api/src/routes/auth/__tests__/tokens.test.ts +294 -0
- package/templates/apps/api/src/routes/auth/__tests__/user.test.ts +486 -0
- package/templates/apps/api/src/routes/auth/tokens.ts +199 -0
- package/templates/apps/api/src/routes/auth/user.ts +244 -0
- package/templates/apps/api/src/routes/checkout/__tests__/sessions.test.ts +588 -0
- package/templates/apps/api/src/routes/checkout/index.ts +13 -0
- package/templates/apps/api/src/routes/checkout/sessions.ts +185 -0
- package/templates/apps/api/src/routes/content/__tests__/create.test.ts +239 -0
- package/templates/apps/api/src/routes/content/__tests__/delete.test.ts +201 -0
- package/templates/apps/api/src/routes/content/__tests__/get-page.test.ts +141 -0
- package/templates/apps/api/src/routes/content/__tests__/list-pages.test.ts +122 -0
- package/templates/apps/api/src/routes/content/__tests__/list-types.test.ts +44 -0
- package/templates/apps/api/src/routes/content/__tests__/locale.test.ts +118 -0
- package/templates/apps/api/src/routes/content/__tests__/rate-limit.test.ts +51 -0
- package/templates/apps/api/src/routes/content/__tests__/update.test.ts +252 -0
- package/templates/apps/api/src/routes/content/create.ts +114 -0
- package/templates/apps/api/src/routes/content/delete.ts +81 -0
- package/templates/apps/api/src/routes/content/get-page.ts +98 -0
- package/templates/apps/api/src/routes/content/index.ts +32 -0
- package/templates/apps/api/src/routes/content/list-pages.ts +83 -0
- package/templates/apps/api/src/routes/content/list-types.ts +19 -0
- package/templates/apps/api/src/routes/content/rate-limit.ts +13 -0
- package/templates/apps/api/src/routes/content/slug.ts +9 -0
- package/templates/apps/api/src/routes/content/update.ts +111 -0
- package/templates/apps/api/src/routes/leads/__tests__/index.test.ts +415 -0
- package/templates/apps/api/src/routes/leads/__tests__/track.test.ts +165 -0
- package/templates/apps/api/src/routes/leads/index.ts +130 -0
- package/templates/apps/api/src/routes/test/auth/__tests__/session.test.ts +296 -0
- package/templates/apps/api/src/routes/test/auth/session.ts +141 -0
- package/templates/apps/api/src/routes/webhooks/README.md +57 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-idempotency.test.ts +247 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe-rate-limit.test.ts +198 -0
- package/templates/apps/api/src/routes/webhooks/__tests__/stripe.test.ts +633 -0
- package/templates/apps/api/src/routes/webhooks/index.ts +41 -0
- package/templates/apps/api/src/routes/webhooks/stripe.ts +253 -0
- package/templates/apps/api/src/server.ts +157 -0
- package/templates/apps/api/src/services/__tests__/lead-routing.test.ts +395 -0
- package/templates/apps/api/src/services/enrichment-shim.ts +53 -0
- package/templates/apps/api/src/services/lead-routing.ts +338 -0
- package/templates/apps/api/tsconfig.json +34 -0
- package/templates/apps/api/vercel.json +17 -0
- package/templates/apps/mcp/.env.example +52 -0
- package/templates/apps/mcp/CLAUDE.md +84 -0
- package/templates/apps/mcp/__tests__/abuse/daily-cap.test.ts +52 -0
- package/templates/apps/mcp/__tests__/abuse/email-validator.test.ts +46 -0
- package/templates/apps/mcp/__tests__/abuse/honeypot.test.ts +36 -0
- package/templates/apps/mcp/__tests__/abuse/user-agent-deny.test.ts +54 -0
- package/templates/apps/mcp/__tests__/aeo-cli-parity.test.ts +110 -0
- package/templates/apps/mcp/__tests__/audit-single-page.test.ts +213 -0
- package/templates/apps/mcp/__tests__/audit.test.ts +217 -0
- package/templates/apps/mcp/__tests__/catalog-drift.test.ts +52 -0
- package/templates/apps/mcp/__tests__/create_page.test.ts +201 -0
- package/templates/apps/mcp/__tests__/delete_page.test.ts +176 -0
- package/templates/apps/mcp/__tests__/get_business_hours.test.ts +82 -0
- package/templates/apps/mcp/__tests__/get_faq.test.ts +80 -0
- package/templates/apps/mcp/__tests__/get_locations.test.ts +65 -0
- package/templates/apps/mcp/__tests__/get_offerings.test.ts +90 -0
- package/templates/apps/mcp/__tests__/get_pricing.test.ts +80 -0
- package/templates/apps/mcp/__tests__/get_site_info.test.ts +81 -0
- package/templates/apps/mcp/__tests__/http-transport.test.ts +323 -0
- package/templates/apps/mcp/__tests__/lib/errors.test.ts +75 -0
- package/templates/apps/mcp/__tests__/lib/require-paid-tier.test.ts +75 -0
- package/templates/apps/mcp/__tests__/list_pages.test.ts +112 -0
- package/templates/apps/mcp/__tests__/locale.test.ts +135 -0
- package/templates/apps/mcp/__tests__/parity.test.ts +205 -0
- package/templates/apps/mcp/__tests__/purchase-disabled.test.ts +34 -0
- package/templates/apps/mcp/__tests__/read_content.test.ts +153 -0
- package/templates/apps/mcp/__tests__/request_callback.test.ts +163 -0
- package/templates/apps/mcp/__tests__/search_content.test.ts +153 -0
- package/templates/apps/mcp/__tests__/server.test.ts +115 -0
- package/templates/apps/mcp/__tests__/submit_lead.test.ts +165 -0
- package/templates/apps/mcp/__tests__/subscribe_newsletter.test.ts +161 -0
- package/templates/apps/mcp/__tests__/tools/purchase.test.ts +227 -0
- package/templates/apps/mcp/__tests__/tools/scaffold.test.ts +237 -0
- package/templates/apps/mcp/__tests__/update_page.test.ts +195 -0
- package/templates/apps/mcp/jest.config.cjs +82 -0
- package/templates/apps/mcp/package.json +37 -0
- package/templates/apps/mcp/src/abuse/daily-cap.ts +47 -0
- package/templates/apps/mcp/src/abuse/email-validator.ts +25 -0
- package/templates/apps/mcp/src/abuse/honeypot.ts +21 -0
- package/templates/apps/mcp/src/abuse/index.ts +111 -0
- package/templates/apps/mcp/src/abuse/user-agent-deny.ts +58 -0
- package/templates/apps/mcp/src/http-transport.ts +303 -0
- package/templates/apps/mcp/src/index.ts +67 -0
- package/templates/apps/mcp/src/lib/audit-single-page.ts +194 -0
- package/templates/apps/mcp/src/lib/errors.ts +61 -0
- package/templates/apps/mcp/src/lib/locales.ts +171 -0
- package/templates/apps/mcp/src/lib/require-paid-tier.ts +44 -0
- package/templates/apps/mcp/src/lib/resolve-locale.ts +30 -0
- package/templates/apps/mcp/src/server.ts +139 -0
- package/templates/apps/mcp/src/tools/audit.ts +103 -0
- package/templates/apps/mcp/src/tools/capture_lead.ts +52 -0
- package/templates/apps/mcp/src/tools/create_page.ts +95 -0
- package/templates/apps/mcp/src/tools/delete_page.ts +73 -0
- package/templates/apps/mcp/src/tools/get_business_hours.ts +66 -0
- package/templates/apps/mcp/src/tools/get_faq.ts +69 -0
- package/templates/apps/mcp/src/tools/get_locations.ts +85 -0
- package/templates/apps/mcp/src/tools/get_offerings.ts +66 -0
- package/templates/apps/mcp/src/tools/get_pricing.ts +74 -0
- package/templates/apps/mcp/src/tools/get_site_info.ts +84 -0
- package/templates/apps/mcp/src/tools/index.ts +125 -0
- package/templates/apps/mcp/src/tools/list_pages.ts +72 -0
- package/templates/apps/mcp/src/tools/purchase.ts +89 -0
- package/templates/apps/mcp/src/tools/read_content.ts +61 -0
- package/templates/apps/mcp/src/tools/request_callback.ts +51 -0
- package/templates/apps/mcp/src/tools/scaffold.ts +119 -0
- package/templates/apps/mcp/src/tools/search_content.ts +59 -0
- package/templates/apps/mcp/src/tools/subscribe_newsletter.ts +47 -0
- package/templates/apps/mcp/src/tools/update_page.ts +91 -0
- package/templates/apps/mcp/tsconfig.json +19 -0
- package/templates/apps/web/.env.example +47 -0
- package/templates/apps/web/CLAUDE.md +81 -0
- package/templates/apps/web/__tests__/auth/adversarial/cookie-attributes.test.ts +94 -0
- package/templates/apps/web/__tests__/auth/adversarial/oauth-state-parameter.test.ts +75 -0
- package/templates/apps/web/__tests__/auth/adversarial/redirect-uri-allowlist.test.ts +82 -0
- package/templates/apps/web/__tests__/auth/env-helpers.test.ts +168 -0
- package/templates/apps/web/__tests__/authority-list-routes.test.tsx +208 -0
- package/templates/apps/web/__tests__/better-stack.test.ts +66 -0
- package/templates/apps/web/__tests__/blog-dir-resolution.test.ts +87 -0
- package/templates/apps/web/__tests__/blog-source-populated.test.ts +130 -0
- package/templates/apps/web/__tests__/data-testid-coverage.test.tsx +60 -0
- package/templates/apps/web/__tests__/google-analytics.test.tsx +104 -0
- package/templates/apps/web/__tests__/i18n/middleware.test.ts +119 -0
- package/templates/apps/web/__tests__/i18n/routing.test.ts +114 -0
- package/templates/apps/web/__tests__/i18n/translations.test.ts +191 -0
- package/templates/apps/web/__tests__/json-ld.test.ts +98 -0
- package/templates/apps/web/__tests__/knowledge-events-routes.test.tsx +580 -0
- package/templates/apps/web/__tests__/layout-stealth.test.ts +39 -0
- package/templates/apps/web/__tests__/lighthouse-fixtures/improvement-image-shrink.tsx +103 -0
- package/templates/apps/web/__tests__/lighthouse-fixtures/override-fixture.md +114 -0
- package/templates/apps/web/__tests__/lighthouse-fixtures/regression-bloat.tsx +94 -0
- package/templates/apps/web/__tests__/page.test.tsx +230 -0
- package/templates/apps/web/__tests__/products-services-phase1.test.tsx +321 -0
- package/templates/apps/web/__tests__/projects-routes.test.tsx +392 -0
- package/templates/apps/web/__tests__/resources-downloads-integrations-phase2.test.tsx +475 -0
- package/templates/apps/web/__tests__/routes/ai-plugin-json.test.ts +53 -0
- package/templates/apps/web/__tests__/routes/blog-route.test.tsx +191 -0
- package/templates/apps/web/__tests__/routes/llms-txt.test.ts +123 -0
- package/templates/apps/web/__tests__/routes/robots-txt.test.ts +52 -0
- package/templates/apps/web/__tests__/routes/sitemap-xml.test.ts +78 -0
- package/templates/apps/web/__tests__/routes/well-known-mcp.test.ts +203 -0
- package/templates/apps/web/__tests__/section-routes.test.tsx +693 -0
- package/templates/apps/web/__tests__/security-headers.test.ts +201 -0
- package/templates/apps/web/__tests__/sentry-config.test.ts +116 -0
- package/templates/apps/web/__tests__/setup.ts +82 -0
- package/templates/apps/web/__tests__/sitemap-locales.test.ts +415 -0
- package/templates/apps/web/__tests__/standalone-informational-routes.test.tsx +844 -0
- package/templates/apps/web/app/.well-known/ai-plugin.json/route.ts +81 -0
- package/templates/apps/web/app/.well-known/mcp.json/build-manifest.ts +110 -0
- package/templates/apps/web/app/.well-known/mcp.json/route.ts +58 -0
- package/templates/apps/web/app/[locale]/__tests__/layout.test.tsx +120 -0
- package/templates/apps/web/app/[locale]/__tests__/page-renderer-migration.test.tsx +202 -0
- package/templates/apps/web/app/[locale]/about/page.tsx +31 -0
- package/templates/apps/web/app/[locale]/blog/[[...slug]]/page.tsx +173 -0
- package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +45 -0
- package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +117 -0
- package/templates/apps/web/app/[locale]/careers/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +44 -0
- package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +113 -0
- package/templates/apps/web/app/[locale]/case-studies/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +63 -0
- package/templates/apps/web/app/[locale]/clients/page.tsx +27 -0
- package/templates/apps/web/app/[locale]/contact/ContactForm.tsx +130 -0
- package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +152 -0
- package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +92 -0
- package/templates/apps/web/app/[locale]/contact/contact.actions.ts +79 -0
- package/templates/apps/web/app/[locale]/contact/error.tsx +24 -0
- package/templates/apps/web/app/[locale]/contact/page.tsx +38 -0
- package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +34 -0
- package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +119 -0
- package/templates/apps/web/app/[locale]/courses/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/dev/purchase/__tests__/actions.test.ts +160 -0
- package/templates/apps/web/app/[locale]/dev/purchase/error.tsx +25 -0
- package/templates/apps/web/app/[locale]/dev/purchase/page.tsx +117 -0
- package/templates/apps/web/app/[locale]/dev/purchase/purchase.actions.ts +58 -0
- package/templates/apps/web/app/[locale]/docs/[[...slug]]/page.tsx +118 -0
- package/templates/apps/web/app/[locale]/downloads/__tests__/page-renderer-migration.test.tsx +72 -0
- package/templates/apps/web/app/[locale]/downloads/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +47 -0
- package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +130 -0
- package/templates/apps/web/app/[locale]/events/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/faq/page.tsx +36 -0
- package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +34 -0
- package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +78 -0
- package/templates/apps/web/app/[locale]/how-to/page.tsx +40 -0
- package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +43 -0
- package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +129 -0
- package/templates/apps/web/app/[locale]/integrations/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/launch-service/page.tsx +31 -0
- package/templates/apps/web/app/[locale]/layout.tsx +241 -0
- package/templates/apps/web/app/[locale]/page.tsx +41 -0
- package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +44 -0
- package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +113 -0
- package/templates/apps/web/app/[locale]/partners/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +43 -0
- package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +129 -0
- package/templates/apps/web/app/[locale]/products/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +39 -0
- package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +138 -0
- package/templates/apps/web/app/[locale]/projects/page.tsx +30 -0
- package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +51 -0
- package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +117 -0
- package/templates/apps/web/app/[locale]/resources/page.tsx +27 -0
- package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +43 -0
- package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +129 -0
- package/templates/apps/web/app/[locale]/services/page.tsx +25 -0
- package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +34 -0
- package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +81 -0
- package/templates/apps/web/app/[locale]/software/page.tsx +39 -0
- package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +34 -0
- package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +82 -0
- package/templates/apps/web/app/[locale]/tech-articles/page.tsx +39 -0
- package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +63 -0
- package/templates/apps/web/app/[locale]/testimonials/page.tsx +27 -0
- package/templates/apps/web/app/[locale]/use-cases/__tests__/page-renderer-migration.test.tsx +63 -0
- package/templates/apps/web/app/[locale]/use-cases/page.tsx +27 -0
- package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +34 -0
- package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +82 -0
- package/templates/apps/web/app/[locale]/whitepapers/page.tsx +39 -0
- package/templates/apps/web/app/__tests__/error-boundaries.test.tsx +152 -0
- package/templates/apps/web/app/api/auth/[...all]/route.ts +16 -0
- package/templates/apps/web/app/error-fallback.tsx +75 -0
- package/templates/apps/web/app/error.tsx +23 -0
- package/templates/apps/web/app/layout.tsx +18 -0
- package/templates/apps/web/app/llms.txt/route.ts +101 -0
- package/templates/apps/web/app/not-found.tsx +48 -0
- package/templates/apps/web/app/og/__tests__/route.test.ts +164 -0
- package/templates/apps/web/app/og/route.tsx +135 -0
- package/templates/apps/web/app/robots.txt/route.ts +36 -0
- package/templates/apps/web/app/sitemap.xml/route.ts +146 -0
- package/templates/apps/web/auth.ts +141 -0
- package/templates/apps/web/components/ThemeToggle.tsx +60 -0
- package/templates/apps/web/components/google-analytics.tsx +34 -0
- package/templates/apps/web/content/en/blog/index.mdx +15 -0
- package/templates/apps/web/content/en/blog/launching-ailk.mdx +20 -0
- package/templates/apps/web/content/en/docs/getting-started.mdx +30 -0
- package/templates/apps/web/i18n/request.ts +36 -0
- package/templates/apps/web/jest.config.cjs +100 -0
- package/templates/apps/web/lib/__mocks__/next-mdx-remote-rsc.js +12 -0
- package/templates/apps/web/lib/__mocks__/source-server.js +31 -0
- package/templates/apps/web/lib/__tests__/og.test.ts +65 -0
- package/templates/apps/web/lib/auth-env.ts +66 -0
- package/templates/apps/web/lib/blog-list-data.ts +95 -0
- package/templates/apps/web/lib/blog-post-data.ts +79 -0
- package/templates/apps/web/lib/nav-config.ts +13 -0
- package/templates/apps/web/lib/observability/better-stack.ts +27 -0
- package/templates/apps/web/lib/og.ts +23 -0
- package/templates/apps/web/lib/prisma-for-auth.ts +34 -0
- package/templates/apps/web/lib/source.ts +34 -0
- package/templates/apps/web/messages/en.json +131 -0
- package/templates/apps/web/middleware.ts +80 -0
- package/templates/apps/web/next.config.mjs +167 -0
- package/templates/apps/web/package.json +62 -0
- package/templates/apps/web/public/.well-known/security.txt +17 -0
- package/templates/apps/web/public/android-chrome-192x192.png +0 -0
- package/templates/apps/web/public/android-chrome-512x512.png +0 -0
- package/templates/apps/web/public/apple-touch-icon.png +0 -0
- package/templates/apps/web/public/favicon-16x16.png +0 -0
- package/templates/apps/web/public/favicon-32x32.png +0 -0
- package/templates/apps/web/public/favicon.ico +0 -0
- package/templates/apps/web/public/favicon.svg +4 -0
- package/templates/apps/web/public/logo-dark.svg +21 -0
- package/templates/apps/web/public/logo-light.svg +21 -0
- package/templates/apps/web/public/logomark-dark.svg +4 -0
- package/templates/apps/web/public/logomark-light.svg +4 -0
- package/templates/apps/web/public/og-default.png +0 -0
- package/templates/apps/web/public/site.webmanifest +19 -0
- package/templates/apps/web/scripts/assert-content-bundled.ts +55 -0
- package/templates/apps/web/security-headers.config.ts +132 -0
- package/templates/apps/web/sentry.client.config.ts +27 -0
- package/templates/apps/web/sentry.edge.config.ts +15 -0
- package/templates/apps/web/sentry.server.config.ts +20 -0
- package/templates/apps/web/source.config.ts +78 -0
- package/templates/apps/web/src/components/SiteNav.tsx +21 -0
- package/templates/apps/web/src/lib/routes.ts +37 -0
- package/templates/apps/web/tsconfig.json +35 -0
- package/templates/apps/web/types/messages.d.ts +19 -0
- package/templates/content/.gitkeep +0 -0
- package/templates/content/CLAUDE.md +85 -0
- package/templates/content/_site.mdx +38 -0
- package/templates/content/ar/HomePage/home.mdx +123 -0
- package/templates/content/ar/_site.mdx +35 -0
- package/templates/content/de/_site.mdx +29 -0
- package/templates/content/en/.gitkeep +0 -0
- package/templates/content/en/AboutPage/about.mdx +19 -0
- package/templates/content/en/AboutPage/about.schema.json +82 -0
- package/templates/content/en/BookCall/book-call.mdx +19 -0
- package/templates/content/en/BookCall/book-call.schema.json +121 -0
- package/templates/content/en/BreadcrumbList/site-breadcrumbs.mdx +20 -0
- package/templates/content/en/CareersList/careers.mdx +24 -0
- package/templates/content/en/CaseStudiesList/case-studies.mdx +22 -0
- package/templates/content/en/CaseStudiesList/showcase.mdx +8 -0
- package/templates/content/en/CaseStudy/ailk-aeo-rollout.mdx +32 -0
- package/templates/content/en/CaseStudy/schema-builder-migration.mdx +41 -0
- package/templates/content/en/ClientsList/clients.mdx +38 -0
- package/templates/content/en/ContactPage/contact.mdx +19 -0
- package/templates/content/en/ContactPage/contact.schema.json +100 -0
- package/templates/content/en/ContactPoint/primary.mdx +14 -0
- package/templates/content/en/Course/aeo-fundamentals.mdx +37 -0
- package/templates/content/en/Course/schema-builder-workshop.mdx +62 -0
- package/templates/content/en/CoursesList/courses.mdx +22 -0
- package/templates/content/en/DownloadsList/downloads.mdx +22 -0
- package/templates/content/en/Event/aeo-office-hours-may-2026.mdx +39 -0
- package/templates/content/en/Event/ailk-launch-day-2026.mdx +35 -0
- package/templates/content/en/EventsList/events.mdx +26 -0
- package/templates/content/en/FAQPage/faq.mdx +420 -0
- package/templates/content/en/FAQPage/faq.schema.json +231 -0
- package/templates/content/en/GlossaryList/glossary.mdx +19 -0
- package/templates/content/en/GlossaryList/glossary.schema.json +300 -0
- package/templates/content/en/HomePage/home.mdx +312 -0
- package/templates/content/en/HomePage/home.schema.json +88 -0
- package/templates/content/en/HomePage/launch-service.mdx +475 -0
- package/templates/content/en/HomePage/launch-service.schema.json +138 -0
- package/templates/content/en/HowTo/add-mdx-content.mdx +38 -0
- package/templates/content/en/HowTo/configure-aeo-scoring.mdx +35 -0
- package/templates/content/en/HowTo/set-up-json-ld.mdx +36 -0
- package/templates/content/en/Integration/github-actions.mdx +31 -0
- package/templates/content/en/Integration/openai-api.mdx +26 -0
- package/templates/content/en/Integration/vercel.mdx +32 -0
- package/templates/content/en/IntegrationsList/integrations.mdx +22 -0
- package/templates/content/en/JobPosting/content-strategist.mdx +46 -0
- package/templates/content/en/JobPosting/developer-advocate.mdx +47 -0
- package/templates/content/en/JobPosting/senior-fullstack-engineer.mdx +57 -0
- package/templates/content/en/LandingPage/aeo-audit.mdx +19 -0
- package/templates/content/en/LandingPage/aeo-audit.schema.json +92 -0
- package/templates/content/en/LandingPage/agency-waitlist.mdx +340 -0
- package/templates/content/en/LandingPage/agency-waitlist.schema.json +152 -0
- package/templates/content/en/LandingPage/developers.mdx +19 -0
- package/templates/content/en/LandingPage/developers.schema.json +109 -0
- package/templates/content/en/LandingPage/for-agencies.mdx +390 -0
- package/templates/content/en/LandingPage/for-agencies.schema.json +107 -0
- package/templates/content/en/LandingPage/for-ai-search-agencies.mdx +417 -0
- package/templates/content/en/LandingPage/for-ai-search-agencies.schema.json +105 -0
- package/templates/content/en/LandingPage/for-businesses.mdx +19 -0
- package/templates/content/en/LandingPage/for-businesses.schema.json +96 -0
- package/templates/content/en/LandingPage/platform.mdx +369 -0
- package/templates/content/en/LandingPage/platform.schema.json +166 -0
- package/templates/content/en/LandingPage/vs-ai-website-builders.mdx +19 -0
- package/templates/content/en/LandingPage/vs-ai-website-builders.schema.json +102 -0
- package/templates/content/en/LandingPage/vs-wordpress.mdx +19 -0
- package/templates/content/en/LandingPage/vs-wordpress.schema.json +53 -0
- package/templates/content/en/NewsletterSignup/newsletter.mdx +236 -0
- package/templates/content/en/NewsletterSignup/newsletter.schema.json +91 -0
- package/templates/content/en/Organization/site-owner.mdx +16 -0
- package/templates/content/en/Partner/prisma.mdx +31 -0
- package/templates/content/en/Partner/supabase.mdx +30 -0
- package/templates/content/en/Partner/vercel.mdx +28 -0
- package/templates/content/en/PartnersList/partners.mdx +22 -0
- package/templates/content/en/Person/founder.mdx +18 -0
- package/templates/content/en/Pricing/pricing.mdx +538 -0
- package/templates/content/en/Pricing/pricing.schema.json +209 -0
- package/templates/content/en/PrivacyPage/privacy.mdx +165 -0
- package/templates/content/en/PrivacyPage/privacy.schema.json +64 -0
- package/templates/content/en/Product/ailk.mdx +19 -0
- package/templates/content/en/Product/ailk.schema.json +94 -0
- package/templates/content/en/Product/api-launch-kit.mdx +26 -0
- package/templates/content/en/Product/launch-kit.mdx +28 -0
- package/templates/content/en/ProductsList/products.mdx +26 -0
- package/templates/content/en/Project/ailk-phase-2.mdx +54 -0
- package/templates/content/en/ProjectsList/projects.mdx +25 -0
- package/templates/content/en/ResourceDetail/aeo-scoring-guide.mdx +27 -0
- package/templates/content/en/ResourceDetail/content-model-whitepaper.mdx +28 -0
- package/templates/content/en/ResourceDetail/schema-org-quick-reference.mdx +39 -0
- package/templates/content/en/ResourcesHub/resources.mdx +22 -0
- package/templates/content/en/Service/consulting.mdx +22 -0
- package/templates/content/en/Service/implementation.mdx +30 -0
- package/templates/content/en/Service/launch-service.mdx +232 -0
- package/templates/content/en/Service/launch.mdx +228 -0
- package/templates/content/en/ServicesList/services.mdx +84 -0
- package/templates/content/en/SoftwareProduct/ailk-aeo.mdx +44 -0
- package/templates/content/en/SoftwareProduct/ailk-content-adapters.mdx +47 -0
- package/templates/content/en/SoftwareProduct/ailk-schema.mdx +49 -0
- package/templates/content/en/TeamList/team.mdx +63 -0
- package/templates/content/en/TeamMember/founder.mdx +72 -0
- package/templates/content/en/TermsPage/terms.mdx +19 -0
- package/templates/content/en/TermsPage/terms.schema.json +99 -0
- package/templates/content/en/TestimonialsList/testimonials.mdx +44 -0
- package/templates/content/en/UseCasesList/use-cases.mdx +30 -0
- package/templates/content/en/Whitepaper/ax-first-product-development.mdx +27 -0
- package/templates/content/en/Whitepaper/open-core-commercial-strategy.mdx +27 -0
- package/templates/content/en/Whitepaper/structured-data-for-answer-engines.mdx +31 -0
- package/templates/content/en-XA/AboutPage/about.mdx +8 -0
- package/templates/content/en-XA/FAQPage/faq.mdx +8 -0
- package/templates/content/en-XA/HomePage/home.mdx +8 -0
- package/templates/content/es/_site.mdx +30 -0
- package/templates/content/fr/_site.mdx +30 -0
- package/templates/content/ja/_site.mdx +30 -0
- package/templates/content/pt-BR/AboutPage/about.mdx +8 -0
- package/templates/content/pt-BR/FAQPage/faq.mdx +8 -0
- package/templates/content/pt-BR/HomePage/home.mdx +23 -0
- package/templates/database/CHANGELOG.md +5 -0
- package/templates/database/README.md +234 -0
- package/templates/database/__tests__/user-cascade.test.ts +125 -0
- package/templates/database/auth/.gitkeep +0 -0
- package/templates/database/config/.gitkeep +0 -0
- package/templates/database/content/.gitkeep +0 -0
- package/templates/database/inbox/.gitkeep +0 -0
- package/templates/database/inbox/README.md +3 -0
- package/templates/database/inbox/__tests__/schema.test.ts +40 -0
- package/templates/database/inbox/schema.prisma +52 -0
- package/templates/database/jest.config.cjs +29 -0
- package/templates/database/migrations/20260508000000_add_inbox_namespace/migration.sql +328 -0
- package/templates/database/migrations/20260513000000_better_auth_migration/migration.sql +100 -0
- package/templates/database/migrations/20260515000000_add_user_billing_fields/migration.sql +28 -0
- package/templates/database/migrations/20260516000000_add_user_tier_care_plan_seat/migration.sql +25 -0
- package/templates/database/migrations/20260518000000_add_telemetry_records/migration.sql +42 -0
- package/templates/database/migrations/20260525000000_theme_wiring/migration.sql +67 -0
- package/templates/database/migrations/20260710000000_retire_commercial_tier/migration.sql +21 -0
- package/templates/database/migrations/migration_lock.toml +3 -0
- package/templates/database/ops/.gitkeep +0 -0
- package/templates/database/package.json +45 -0
- package/templates/database/prisma.config.ts +20 -0
- package/templates/database/schema.prisma +487 -0
- package/templates/database/scripts/db-generate-locked.sh +80 -0
- package/templates/database/seed-test.ts +85 -0
- package/templates/database/tsconfig.build.json +16 -0
- package/templates/database/tsconfig.json +9 -0
- package/templates/package.json +125 -0
- package/templates/pnpm-workspace.yaml +6 -0
- package/templates/project.yaml +59 -0
- package/templates/tsconfig.base.json +18 -0
- package/templates/tsconfig.json +45 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Mock dotenv
|
|
2
|
+
jest.mock('dotenv', () => ({
|
|
3
|
+
config: jest.fn(),
|
|
4
|
+
}));
|
|
5
|
+
|
|
6
|
+
// Mock the observability logger so assertions don't depend on pino's stdout serialization.
|
|
7
|
+
const mockLoggerError = jest.fn();
|
|
8
|
+
jest.mock('@working-theory/observability', () => ({
|
|
9
|
+
logger: {
|
|
10
|
+
error: (...args: unknown[]) => mockLoggerError(...args),
|
|
11
|
+
warn: jest.fn(),
|
|
12
|
+
info: jest.fn(),
|
|
13
|
+
debug: jest.fn(),
|
|
14
|
+
},
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
describe('Config', () => {
|
|
18
|
+
const originalEnv = process.env;
|
|
19
|
+
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
jest.resetModules();
|
|
22
|
+
process.env = { ...originalEnv };
|
|
23
|
+
jest.clearAllMocks();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
process.env = originalEnv;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should load environment variables', () => {
|
|
31
|
+
// ARRANGE
|
|
32
|
+
process.env.DATABASE_URL = 'postgresql://test:test@localhost/test';
|
|
33
|
+
|
|
34
|
+
// ACT — require dotenv after resetModules so we observe the same mock
|
|
35
|
+
// instance the freshly-required config module will use.
|
|
36
|
+
const dotenv = require('dotenv');
|
|
37
|
+
const { config } = require('../index');
|
|
38
|
+
|
|
39
|
+
// ASSERT
|
|
40
|
+
expect(config.DATABASE_URL).toBe('postgresql://test:test@localhost/test');
|
|
41
|
+
expect(dotenv.config).toHaveBeenCalled();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should exit on missing DATABASE_URL', () => {
|
|
45
|
+
// ARRANGE
|
|
46
|
+
delete process.env.DATABASE_URL;
|
|
47
|
+
|
|
48
|
+
const exitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {
|
|
49
|
+
throw new Error('Process exit called');
|
|
50
|
+
});
|
|
51
|
+
mockLoggerError.mockClear();
|
|
52
|
+
|
|
53
|
+
// ACT & ASSERT
|
|
54
|
+
expect(() => {
|
|
55
|
+
require('../index');
|
|
56
|
+
}).toThrow('Process exit called');
|
|
57
|
+
|
|
58
|
+
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
59
|
+
expect(mockLoggerError).toHaveBeenCalled();
|
|
60
|
+
|
|
61
|
+
exitSpy.mockRestore();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should not require any external-platform forwarding env vars', () => {
|
|
65
|
+
// ARRANGE — only DATABASE_URL set; legacy forwarding vars explicitly absent
|
|
66
|
+
process.env.DATABASE_URL = 'postgresql://test:test@localhost/test';
|
|
67
|
+
const legacyVars = ['THEORY' + '_API_URL', 'THEORY' + '_API_KEY'];
|
|
68
|
+
legacyVars.forEach((k) => {
|
|
69
|
+
delete process.env[k];
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// ACT
|
|
73
|
+
const { config } = require('../index');
|
|
74
|
+
|
|
75
|
+
// ASSERT — config loads without error and exposes no legacy forwarding keys
|
|
76
|
+
expect(config.DATABASE_URL).toBe('postgresql://test:test@localhost/test');
|
|
77
|
+
legacyVars.forEach((k) => {
|
|
78
|
+
expect((config as Record<string, unknown>)[k]).toBeUndefined();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should set default values for optional config', () => {
|
|
83
|
+
// ARRANGE
|
|
84
|
+
process.env.DATABASE_URL = 'postgresql://test:test@localhost/test';
|
|
85
|
+
delete process.env.NODE_ENV;
|
|
86
|
+
delete process.env.PORT;
|
|
87
|
+
delete process.env.FRONTEND_URL;
|
|
88
|
+
|
|
89
|
+
// ACT
|
|
90
|
+
const { config } = require('../index');
|
|
91
|
+
|
|
92
|
+
// ASSERT
|
|
93
|
+
expect(config.NODE_ENV).toBe('development');
|
|
94
|
+
expect(config.PORT).toBe(3002);
|
|
95
|
+
expect(config.FRONTEND_URL).toBe('http://localhost:3000');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Launch Kit API Configuration
|
|
3
|
+
*
|
|
4
|
+
* Local-only backend (auth + sessions). External-platform forwarding has been
|
|
5
|
+
* removed; AILK-native routes will be added in subsequent issues.
|
|
6
|
+
*/
|
|
7
|
+
import { logger } from '@working-theory/observability';
|
|
8
|
+
import * as dotenv from 'dotenv';
|
|
9
|
+
|
|
10
|
+
dotenv.config();
|
|
11
|
+
|
|
12
|
+
export interface Config {
|
|
13
|
+
// Server
|
|
14
|
+
NODE_ENV: 'development' | 'production' | 'test';
|
|
15
|
+
PORT: number;
|
|
16
|
+
FRONTEND_URL: string;
|
|
17
|
+
|
|
18
|
+
// Local Database (for auth: User, Session, ApiToken, etc.)
|
|
19
|
+
DATABASE_URL: string;
|
|
20
|
+
|
|
21
|
+
// Stripe — consumed by apps/api/src/lib/stripe.ts via @working-theory/stripe-client wrapper
|
|
22
|
+
STRIPE_SECRET_KEY?: string;
|
|
23
|
+
STRIPE_WEBHOOK_SECRET?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function validateConfig(): Config {
|
|
27
|
+
const errors: string[] = [];
|
|
28
|
+
|
|
29
|
+
// Required: Local database for auth
|
|
30
|
+
if (!process.env.DATABASE_URL) {
|
|
31
|
+
errors.push('DATABASE_URL is required for authentication');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Exit on errors
|
|
35
|
+
if (errors.length > 0) {
|
|
36
|
+
logger.error({ errors }, '❌ Configuration validation failed');
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
NODE_ENV: (process.env.NODE_ENV || 'development') as Config['NODE_ENV'],
|
|
42
|
+
PORT: parseInt(process.env.PORT || '3002', 10),
|
|
43
|
+
FRONTEND_URL: process.env.FRONTEND_URL || 'http://localhost:3000',
|
|
44
|
+
|
|
45
|
+
DATABASE_URL: process.env.DATABASE_URL!,
|
|
46
|
+
|
|
47
|
+
...(process.env.STRIPE_SECRET_KEY !== undefined && {
|
|
48
|
+
STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY,
|
|
49
|
+
}),
|
|
50
|
+
...(process.env.STRIPE_WEBHOOK_SECRET !== undefined && {
|
|
51
|
+
STRIPE_WEBHOOK_SECRET: process.env.STRIPE_WEBHOOK_SECRET,
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const config = validateConfig();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Launch Kit API - Server Initialization
|
|
3
|
+
*
|
|
4
|
+
* Exports the start() function for starting the Fastify server.
|
|
5
|
+
* For CLI usage, see cli.ts
|
|
6
|
+
* For Vercel deployment, see api/index.ts which uses the build() function.
|
|
7
|
+
*/
|
|
8
|
+
import { logger } from '@working-theory/observability';
|
|
9
|
+
|
|
10
|
+
import { config } from './config/index.js';
|
|
11
|
+
import { build } from './server.js';
|
|
12
|
+
|
|
13
|
+
export async function start() {
|
|
14
|
+
try {
|
|
15
|
+
const server = await build();
|
|
16
|
+
|
|
17
|
+
// Start server
|
|
18
|
+
await server.listen({ port: config.PORT, host: '0.0.0.0' });
|
|
19
|
+
|
|
20
|
+
logger.info(
|
|
21
|
+
{
|
|
22
|
+
port: config.PORT,
|
|
23
|
+
env: config.NODE_ENV,
|
|
24
|
+
endpoints: { auth: '/v1/auth/tokens, /v1/user/*' },
|
|
25
|
+
},
|
|
26
|
+
'🚀 AI Launch Kit API listening',
|
|
27
|
+
);
|
|
28
|
+
} catch (err) {
|
|
29
|
+
logger.error({ err }, 'Failed to start server');
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock PrismaClient for testing
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const MockPrismaClient = jest.fn().mockImplementation((options) => ({
|
|
6
|
+
$connect: jest.fn(),
|
|
7
|
+
$disconnect: jest.fn(),
|
|
8
|
+
user: {},
|
|
9
|
+
apiToken: {},
|
|
10
|
+
userData: {},
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
PrismaClient: MockPrismaClient,
|
|
15
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manual mock for prisma.ts
|
|
3
|
+
* Used by Jest when jest.mock('../../lib/prisma.js') is called.
|
|
4
|
+
*
|
|
5
|
+
* Covers all models accessed in route tests:
|
|
6
|
+
* auth models (user, apiToken, userData) — used by auth route tests
|
|
7
|
+
* inbox models (lead, subscriber, callback) — used by leads route tests (#507)
|
|
8
|
+
*
|
|
9
|
+
* Per-test return values: import `prisma` from this module and call
|
|
10
|
+
* (prisma.lead.create as jest.Mock).mockResolvedValue({ id: "..." })
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const prisma = {
|
|
14
|
+
// ── Auth namespace ──────────────────────────────────────────────────────────
|
|
15
|
+
user: {
|
|
16
|
+
findUnique: jest.fn(),
|
|
17
|
+
findFirst: jest.fn(),
|
|
18
|
+
update: jest.fn(),
|
|
19
|
+
create: jest.fn(),
|
|
20
|
+
},
|
|
21
|
+
apiToken: {
|
|
22
|
+
create: jest.fn(),
|
|
23
|
+
findMany: jest.fn(),
|
|
24
|
+
updateMany: jest.fn(),
|
|
25
|
+
},
|
|
26
|
+
userData: {
|
|
27
|
+
findUnique: jest.fn(),
|
|
28
|
+
upsert: jest.fn(),
|
|
29
|
+
deleteMany: jest.fn(),
|
|
30
|
+
},
|
|
31
|
+
// ── Inbox namespace (Lead, Subscriber, Callback) ─────────────────────────
|
|
32
|
+
lead: {
|
|
33
|
+
create: jest.fn(),
|
|
34
|
+
},
|
|
35
|
+
subscriber: {
|
|
36
|
+
create: jest.fn(),
|
|
37
|
+
findUnique: jest.fn(),
|
|
38
|
+
},
|
|
39
|
+
callback: {
|
|
40
|
+
create: jest.fn(),
|
|
41
|
+
},
|
|
42
|
+
// ── Lifecycle ────────────────────────────────────────────────────────────
|
|
43
|
+
$connect: jest.fn(),
|
|
44
|
+
$disconnect: jest.fn(),
|
|
45
|
+
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for apps/api/src/lib/content-adapter.ts factory.
|
|
3
|
+
*
|
|
4
|
+
* Covers:
|
|
5
|
+
* (a) CONTENT_ADAPTER unset → MDX adapter (existing behavior preserved)
|
|
6
|
+
* (b) CONTENT_ADAPTER=projection + valid manifest → projection adapter, read parity vs MDX
|
|
7
|
+
* (c) CONTENT_ADAPTER=projection + missing manifest → clear actionable error at construction
|
|
8
|
+
*/
|
|
9
|
+
import { join, resolve } from "node:path";
|
|
10
|
+
import { mkdirSync, writeFileSync, rmSync } from "node:fs";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
getContentAdapter,
|
|
15
|
+
getContentRoot,
|
|
16
|
+
resetContentAdapter,
|
|
17
|
+
} from "../content-adapter.js";
|
|
18
|
+
|
|
19
|
+
// Local fixture: a minimal content root with one HomePage page.
|
|
20
|
+
const FIXTURE_ROOT = resolve(__dirname, "fixtures");
|
|
21
|
+
|
|
22
|
+
// The matching manifest for the local fixture.
|
|
23
|
+
const FIXTURE_MANIFEST =
|
|
24
|
+
JSON.stringify(
|
|
25
|
+
{
|
|
26
|
+
HomePage: [
|
|
27
|
+
{
|
|
28
|
+
type: "HomePage",
|
|
29
|
+
slug: "home",
|
|
30
|
+
title: "AI Launch Kit",
|
|
31
|
+
description:
|
|
32
|
+
"AX-first OSS template for shipping software with API and MCP.",
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
null,
|
|
37
|
+
2,
|
|
38
|
+
) + "\n";
|
|
39
|
+
|
|
40
|
+
describe("getContentAdapter() factory", () => {
|
|
41
|
+
const savedEnv: Record<string, string | undefined> = {};
|
|
42
|
+
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
savedEnv.CONTENT_ADAPTER = process.env.CONTENT_ADAPTER;
|
|
45
|
+
savedEnv.CONTENT_ROOT = process.env.CONTENT_ROOT;
|
|
46
|
+
savedEnv.MANIFEST_PATH = process.env.MANIFEST_PATH;
|
|
47
|
+
resetContentAdapter();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
afterEach(() => {
|
|
51
|
+
if (savedEnv.CONTENT_ADAPTER === undefined) {
|
|
52
|
+
delete process.env.CONTENT_ADAPTER;
|
|
53
|
+
} else {
|
|
54
|
+
process.env.CONTENT_ADAPTER = savedEnv.CONTENT_ADAPTER;
|
|
55
|
+
}
|
|
56
|
+
if (savedEnv.CONTENT_ROOT === undefined) {
|
|
57
|
+
delete process.env.CONTENT_ROOT;
|
|
58
|
+
} else {
|
|
59
|
+
process.env.CONTENT_ROOT = savedEnv.CONTENT_ROOT;
|
|
60
|
+
}
|
|
61
|
+
if (savedEnv.MANIFEST_PATH === undefined) {
|
|
62
|
+
delete process.env.MANIFEST_PATH;
|
|
63
|
+
} else {
|
|
64
|
+
process.env.MANIFEST_PATH = savedEnv.MANIFEST_PATH;
|
|
65
|
+
}
|
|
66
|
+
resetContentAdapter();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe("(a) CONTENT_ADAPTER unset → MDX adapter", () => {
|
|
70
|
+
test("returns an adapter that reads fixture pages via MDX", async () => {
|
|
71
|
+
delete process.env.CONTENT_ADAPTER;
|
|
72
|
+
process.env.CONTENT_ROOT = FIXTURE_ROOT;
|
|
73
|
+
|
|
74
|
+
const adapter = getContentAdapter();
|
|
75
|
+
expect(adapter).toBeDefined();
|
|
76
|
+
const page = await adapter.getPageBySlug("HomePage", "home");
|
|
77
|
+
expect(page).not.toBeNull();
|
|
78
|
+
expect(page?.title).toBe("AI Launch Kit");
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe("(b) CONTENT_ADAPTER=projection + valid manifest → projection adapter", () => {
|
|
83
|
+
let tmpDir: string;
|
|
84
|
+
let manifestPath: string;
|
|
85
|
+
|
|
86
|
+
beforeEach(() => {
|
|
87
|
+
tmpDir = join(tmpdir(), `ailk-adapter-test-${Date.now()}`);
|
|
88
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
89
|
+
manifestPath = join(tmpDir, "manifest.json");
|
|
90
|
+
writeFileSync(manifestPath, FIXTURE_MANIFEST, "utf8");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
afterEach(() => {
|
|
94
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("returns projection adapter when CONTENT_ADAPTER=projection", async () => {
|
|
98
|
+
process.env.CONTENT_ADAPTER = "projection";
|
|
99
|
+
process.env.MANIFEST_PATH = manifestPath;
|
|
100
|
+
|
|
101
|
+
const adapter = getContentAdapter();
|
|
102
|
+
const page = await adapter.getPageBySlug("HomePage", "home");
|
|
103
|
+
expect(page).not.toBeNull();
|
|
104
|
+
expect(page?.title).toBe("AI Launch Kit");
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test("read parity: projection adapter listPages matches MDX adapter against same fixture", async () => {
|
|
108
|
+
// MDX adapter against local fixture
|
|
109
|
+
delete process.env.CONTENT_ADAPTER;
|
|
110
|
+
process.env.CONTENT_ROOT = FIXTURE_ROOT;
|
|
111
|
+
const mdxAdapter = getContentAdapter();
|
|
112
|
+
const mdxPages = await mdxAdapter.listPages("HomePage");
|
|
113
|
+
resetContentAdapter();
|
|
114
|
+
|
|
115
|
+
// Projection adapter backed by manifest matching same fixture
|
|
116
|
+
process.env.CONTENT_ADAPTER = "projection";
|
|
117
|
+
process.env.MANIFEST_PATH = manifestPath;
|
|
118
|
+
const projAdapter = getContentAdapter();
|
|
119
|
+
const projPages = await projAdapter.listPages("HomePage");
|
|
120
|
+
|
|
121
|
+
const sortBySlug = (a: { slug: string }, b: { slug: string }) =>
|
|
122
|
+
a.slug.localeCompare(b.slug);
|
|
123
|
+
expect(projPages.sort(sortBySlug)).toEqual(mdxPages.sort(sortBySlug));
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("projection adapter write methods throw read-only error", async () => {
|
|
127
|
+
process.env.CONTENT_ADAPTER = "projection";
|
|
128
|
+
process.env.MANIFEST_PATH = manifestPath;
|
|
129
|
+
|
|
130
|
+
const adapter = getContentAdapter();
|
|
131
|
+
await expect(
|
|
132
|
+
adapter.createPage("HomePage", "new", {
|
|
133
|
+
type: "HomePage",
|
|
134
|
+
slug: "new",
|
|
135
|
+
title: "New",
|
|
136
|
+
description: "Desc",
|
|
137
|
+
body: "body",
|
|
138
|
+
}),
|
|
139
|
+
).rejects.toThrow("read-only");
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe("(c) CONTENT_ADAPTER=projection + missing manifest → clear actionable error", () => {
|
|
144
|
+
test("throws at getContentAdapter() call time naming the missing path and instructing compile step", () => {
|
|
145
|
+
process.env.CONTENT_ADAPTER = "projection";
|
|
146
|
+
process.env.MANIFEST_PATH = "/nonexistent/path/manifest.json";
|
|
147
|
+
|
|
148
|
+
expect(() => getContentAdapter()).toThrow(
|
|
149
|
+
"/nonexistent/path/manifest.json",
|
|
150
|
+
);
|
|
151
|
+
expect(() => getContentAdapter()).toThrow("pnpm content:compile");
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe("getContentRoot()", () => {
|
|
157
|
+
const savedContentRoot = process.env.CONTENT_ROOT;
|
|
158
|
+
|
|
159
|
+
afterEach(() => {
|
|
160
|
+
if (savedContentRoot === undefined) {
|
|
161
|
+
delete process.env.CONTENT_ROOT;
|
|
162
|
+
} else {
|
|
163
|
+
process.env.CONTENT_ROOT = savedContentRoot;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("returns CONTENT_ROOT env when set", () => {
|
|
168
|
+
process.env.CONTENT_ROOT = "/explicit/content/root";
|
|
169
|
+
expect(getContentRoot()).toBe("/explicit/content/root");
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("returns a string path when env is unset", () => {
|
|
173
|
+
delete process.env.CONTENT_ROOT;
|
|
174
|
+
const root = getContentRoot();
|
|
175
|
+
expect(typeof root).toBe("string");
|
|
176
|
+
expect(root.length).toBeGreaterThan(0);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* error-serializer — Fastify error handler that prevents internal-error leaks.
|
|
3
|
+
*
|
|
4
|
+
* Internal exceptions (DB errors, third-party SDK errors, unhandled throws)
|
|
5
|
+
* must NOT echo their `.message` or stack trace to the client. Clients see a
|
|
6
|
+
* generic `internal_error`; the full detail goes to pino at error level.
|
|
7
|
+
*
|
|
8
|
+
* Validation errors (Fastify's built-in 400 with FST_ERR_VALIDATION) keep
|
|
9
|
+
* their structured detail because schemas are safe to surface.
|
|
10
|
+
*
|
|
11
|
+
* Explicitly-set HTTP statuses (`reply.code(404).send(...)`) flow through
|
|
12
|
+
* untouched.
|
|
13
|
+
*/
|
|
14
|
+
import Fastify, { type FastifyInstance } from "fastify";
|
|
15
|
+
|
|
16
|
+
import { registerErrorSerializer } from "../error-serializer.js";
|
|
17
|
+
|
|
18
|
+
describe("error-serializer", () => {
|
|
19
|
+
let server: FastifyInstance;
|
|
20
|
+
const logLines: Array<Record<string, unknown>> = [];
|
|
21
|
+
|
|
22
|
+
beforeEach(async () => {
|
|
23
|
+
logLines.length = 0;
|
|
24
|
+
server = Fastify({
|
|
25
|
+
logger: {
|
|
26
|
+
level: "error",
|
|
27
|
+
stream: {
|
|
28
|
+
write(msg: string) {
|
|
29
|
+
logLines.push(JSON.parse(msg) as Record<string, unknown>);
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
registerErrorSerializer(server);
|
|
36
|
+
|
|
37
|
+
server.get("/boom", async () => {
|
|
38
|
+
throw new Error(
|
|
39
|
+
"internal-detail: connection refused at db host secret.host.internal:5432",
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
server.get("/explicit-400", async (_req, reply) => {
|
|
44
|
+
await reply.code(400).send({ error: "validation-error" });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
server.get("/explicit-404", async (_req, reply) => {
|
|
48
|
+
await reply.code(404).send({ error: "not-found" });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
await server.ready();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
afterEach(async () => {
|
|
55
|
+
await server.close();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("returns generic internal_error on uncaught throw — no detail in body", async () => {
|
|
59
|
+
const response = await server.inject({ method: "GET", url: "/boom" });
|
|
60
|
+
|
|
61
|
+
expect(response.statusCode).toBe(500);
|
|
62
|
+
const body = JSON.parse(response.body) as Record<string, unknown>;
|
|
63
|
+
expect(body).toEqual({ error: "internal_error" });
|
|
64
|
+
expect(JSON.stringify(body)).not.toContain("connection refused");
|
|
65
|
+
expect(JSON.stringify(body)).not.toContain("secret.host.internal");
|
|
66
|
+
expect(JSON.stringify(body)).not.toContain("stack");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("logs full error detail to pino at error level", async () => {
|
|
70
|
+
await server.inject({ method: "GET", url: "/boom" });
|
|
71
|
+
|
|
72
|
+
const text = JSON.stringify(logLines);
|
|
73
|
+
expect(text).toContain("connection refused");
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("does NOT include stack traces in response body", async () => {
|
|
77
|
+
const response = await server.inject({ method: "GET", url: "/boom" });
|
|
78
|
+
|
|
79
|
+
expect(response.body).not.toMatch(/at\s+\w+\s+\(/); // typical stack frame
|
|
80
|
+
expect(response.body).not.toContain("Error:");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("leaves explicit 4xx replies untouched", async () => {
|
|
84
|
+
const r400 = await server.inject({ method: "GET", url: "/explicit-400" });
|
|
85
|
+
expect(r400.statusCode).toBe(400);
|
|
86
|
+
expect(JSON.parse(r400.body)).toEqual({ error: "validation-error" });
|
|
87
|
+
|
|
88
|
+
const r404 = await server.inject({ method: "GET", url: "/explicit-404" });
|
|
89
|
+
expect(r404.statusCode).toBe(404);
|
|
90
|
+
expect(JSON.parse(r404.body)).toEqual({ error: "not-found" });
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("doesn't leak the Error.message via the default 'message' field", async () => {
|
|
94
|
+
const response = await server.inject({ method: "GET", url: "/boom" });
|
|
95
|
+
const body = JSON.parse(response.body) as Record<string, unknown>;
|
|
96
|
+
|
|
97
|
+
expect(body["message"]).toBeUndefined();
|
|
98
|
+
expect(body["statusCode"]).toBeUndefined();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for the canonical error helpers used by D14a content-write
|
|
3
|
+
* routes. Asserts each helper returns the right status + canonical body shape
|
|
4
|
+
* with the correct machine code.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
conflictError,
|
|
9
|
+
notFoundError,
|
|
10
|
+
paymentRequiredError,
|
|
11
|
+
unauthorizedError,
|
|
12
|
+
validationError,
|
|
13
|
+
} from "../errors.js";
|
|
14
|
+
|
|
15
|
+
describe("apps/api/lib/errors", () => {
|
|
16
|
+
describe("validationError", () => {
|
|
17
|
+
it("returns status 400 with validation_failed code", () => {
|
|
18
|
+
const err = validationError("Invalid input");
|
|
19
|
+
expect(err.status).toBe(400);
|
|
20
|
+
expect(err.body).toEqual({
|
|
21
|
+
error: "validation_failed",
|
|
22
|
+
message: "Invalid input",
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("includes details when provided", () => {
|
|
27
|
+
const err = validationError("Invalid type or slug", {
|
|
28
|
+
field: "type",
|
|
29
|
+
received: "Unknown",
|
|
30
|
+
});
|
|
31
|
+
expect(err.body).toEqual({
|
|
32
|
+
error: "validation_failed",
|
|
33
|
+
message: "Invalid type or slug",
|
|
34
|
+
details: { field: "type", received: "Unknown" },
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("omits details key entirely when not provided", () => {
|
|
39
|
+
const err = validationError("Bad input");
|
|
40
|
+
expect("details" in err.body).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe("unauthorizedError", () => {
|
|
45
|
+
it("returns status 401 with unauthorized code", () => {
|
|
46
|
+
const err = unauthorizedError("Missing or invalid token");
|
|
47
|
+
expect(err.status).toBe(401);
|
|
48
|
+
expect(err.body).toEqual({
|
|
49
|
+
error: "unauthorized",
|
|
50
|
+
message: "Missing or invalid token",
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe("paymentRequiredError", () => {
|
|
56
|
+
it("returns status 402 with payment_required code", () => {
|
|
57
|
+
const err = paymentRequiredError("Pro license required");
|
|
58
|
+
expect(err.status).toBe(402);
|
|
59
|
+
expect(err.body).toEqual({
|
|
60
|
+
error: "payment_required",
|
|
61
|
+
message: "Pro license required",
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe("notFoundError", () => {
|
|
67
|
+
it("returns status 404 with not_found code", () => {
|
|
68
|
+
const err = notFoundError("Page not found");
|
|
69
|
+
expect(err.status).toBe(404);
|
|
70
|
+
expect(err.body).toEqual({
|
|
71
|
+
error: "not_found",
|
|
72
|
+
message: "Page not found",
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe("conflictError", () => {
|
|
78
|
+
it("returns status 409 with conflict code", () => {
|
|
79
|
+
const err = conflictError("Stale version token");
|
|
80
|
+
expect(err.status).toBe(409);
|
|
81
|
+
expect(err.body).toEqual({
|
|
82
|
+
error: "conflict",
|
|
83
|
+
message: "Stale version token",
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("includes details (e.g. existing version) when provided", () => {
|
|
88
|
+
const err = conflictError("Slug already exists", {
|
|
89
|
+
existingVersion: "abc123",
|
|
90
|
+
});
|
|
91
|
+
expect(err.body.details).toEqual({ existingVersion: "abc123" });
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|