@oaklandzoo/ostup 0.9.1 → 0.11.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.
Files changed (67) hide show
  1. package/README.md +15 -0
  2. package/bin/cli.mjs +28 -2
  3. package/package.json +1 -1
  4. package/scripts/verify-profile.sh +46 -0
  5. package/src/brief/profile-router.mjs +63 -28
  6. package/src/doctor-privacy.mjs +103 -0
  7. package/src/doctor.mjs +7 -1
  8. package/src/mvp-flow.mjs +10 -0
  9. package/src/private-cmd.mjs +35 -0
  10. package/src/private.mjs +215 -0
  11. package/templates/.claude/commands/add-storage.md +31 -1
  12. package/templates/START_HERE.md +1 -1
  13. package/templates/private/CLAUDE_PART_20.md +30 -0
  14. package/templates/private/api-audit-health.ts +9 -0
  15. package/templates/private/api-blob-proxy.ts +40 -0
  16. package/templates/private/lib-audit.ts +18 -0
  17. package/templates/private/lib-rate-limit-kv.ts +21 -0
  18. package/templates/private/lib-rate-limit-memory.ts +25 -0
  19. package/templates/private/middleware.ts +60 -0
  20. package/templates/private/next.config.ts +14 -0
  21. package/templates/profiles/blog/README.md +45 -40
  22. package/templates/profiles/blog/app/feed.xml/route.ts +41 -0
  23. package/templates/profiles/blog/app/page.tsx +30 -0
  24. package/templates/profiles/blog/app/posts/[slug]/page.tsx +51 -0
  25. package/templates/profiles/blog/app/sitemap.xml/route.ts +21 -0
  26. package/templates/profiles/blog/content/posts/getting-started.mdx +16 -0
  27. package/templates/profiles/blog/content/posts/intro.mdx +14 -0
  28. package/templates/profiles/blog/content/posts/welcome.mdx +12 -0
  29. package/templates/profiles/blog/lib/posts.ts +43 -0
  30. package/templates/profiles/blog/next.config.mjs.additions +9 -0
  31. package/templates/profiles/blog/package.json.additions +6 -0
  32. package/templates/profiles/booking/.env.example.additions +3 -11
  33. package/templates/profiles/booking/README.md +26 -21
  34. package/templates/profiles/booking/app/api/booking/request/route.ts +76 -0
  35. package/templates/profiles/booking/app/page.tsx +38 -0
  36. package/templates/profiles/booking/components/BookingForm.tsx +130 -0
  37. package/templates/profiles/booking/components/Hero.tsx +20 -0
  38. package/templates/profiles/booking/components/ServiceList.tsx +19 -0
  39. package/templates/profiles/booking/lib/resend.ts +33 -0
  40. package/templates/profiles/booking/lib/storage.ts +44 -0
  41. package/templates/profiles/booking/package.json.additions +5 -0
  42. package/templates/profiles/booking/section-prompts.md +10 -8
  43. package/templates/profiles/lead-gen/.env.example.additions +2 -2
  44. package/templates/profiles/lead-gen/README.md +35 -27
  45. package/templates/profiles/lead-gen/app/api/contact/route.ts +49 -0
  46. package/templates/profiles/lead-gen/app/layout.tsx +29 -0
  47. package/templates/profiles/lead-gen/app/page.tsx +79 -0
  48. package/templates/profiles/lead-gen/components/ContactForm.tsx +89 -0
  49. package/templates/profiles/lead-gen/components/FAQ.tsx +12 -0
  50. package/templates/profiles/lead-gen/components/Hero.tsx +20 -0
  51. package/templates/profiles/lead-gen/components/ServiceCard.tsx +8 -0
  52. package/templates/profiles/lead-gen/lib/resend.ts +33 -0
  53. package/templates/profiles/lead-gen/package.json.additions +5 -0
  54. package/templates/profiles/saas-dashboard/.env.example.additions +5 -16
  55. package/templates/profiles/saas-dashboard/README.md +43 -36
  56. package/templates/profiles/saas-dashboard/app/(auth)/sign-in/page.tsx +75 -0
  57. package/templates/profiles/saas-dashboard/app/(auth)/sign-up/page.tsx +86 -0
  58. package/templates/profiles/saas-dashboard/app/api/auth/[...all]/route.ts +4 -0
  59. package/templates/profiles/saas-dashboard/app/dashboard/layout.tsx +36 -0
  60. package/templates/profiles/saas-dashboard/app/dashboard/page.tsx +18 -0
  61. package/templates/profiles/saas-dashboard/app/dashboard/settings/page.tsx +60 -0
  62. package/templates/profiles/saas-dashboard/app/pricing/page.tsx +11 -0
  63. package/templates/profiles/saas-dashboard/db/schema.sql +13 -0
  64. package/templates/profiles/saas-dashboard/lib/auth.ts +15 -0
  65. package/templates/profiles/saas-dashboard/lib/db.ts +20 -0
  66. package/templates/profiles/saas-dashboard/middleware.ts +19 -0
  67. package/templates/profiles/saas-dashboard/package.json.additions +9 -0
@@ -0,0 +1,60 @@
1
+ 'use client';
2
+
3
+ import { useState } from 'react';
4
+
5
+ export default function SettingsPage() {
6
+ const [email, setEmail] = useState('');
7
+ const [displayName, setDisplayName] = useState('');
8
+ const [status, setStatus] = useState<'idle' | 'saving' | 'saved' | 'error'>('idle');
9
+
10
+ async function onSubmit(e: React.FormEvent) {
11
+ e.preventDefault();
12
+ setStatus('saving');
13
+ try {
14
+ const res = await fetch('/api/account/settings', {
15
+ method: 'POST',
16
+ headers: { 'content-type': 'application/json' },
17
+ body: JSON.stringify({ email, displayName }),
18
+ });
19
+ if (!res.ok) throw new Error('Save failed');
20
+ setStatus('saved');
21
+ } catch {
22
+ setStatus('error');
23
+ }
24
+ }
25
+
26
+ return (
27
+ <div className="max-w-2xl">
28
+ <h1 className="text-3xl font-semibold tracking-tight">Settings</h1>
29
+ <p className="mt-2 text-slate-600">Update your account details. Single-user account. Team features are a Pro upgrade.</p>
30
+ <form onSubmit={onSubmit} className="mt-8 space-y-4">
31
+ <label className="block">
32
+ <span className="text-sm font-medium text-slate-700">Display name</span>
33
+ <input
34
+ value={displayName}
35
+ onChange={(e) => setDisplayName(e.target.value)}
36
+ className="mt-1 block w-full rounded-md border border-slate-300 px-3 py-2"
37
+ />
38
+ </label>
39
+ <label className="block">
40
+ <span className="text-sm font-medium text-slate-700">Email</span>
41
+ <input
42
+ type="email"
43
+ value={email}
44
+ onChange={(e) => setEmail(e.target.value)}
45
+ className="mt-1 block w-full rounded-md border border-slate-300 px-3 py-2"
46
+ />
47
+ </label>
48
+ {status === 'saved' && <div className="rounded-md bg-green-50 p-3 text-sm text-green-900">Saved.</div>}
49
+ {status === 'error' && <div className="rounded-md bg-red-50 p-3 text-sm text-red-900">Save failed.</div>}
50
+ <button
51
+ type="submit"
52
+ disabled={status === 'saving'}
53
+ className="rounded-md bg-slate-900 px-4 py-2 font-medium text-white hover:bg-slate-800 disabled:opacity-60"
54
+ >
55
+ {status === 'saving' ? 'Saving...' : 'Save'}
56
+ </button>
57
+ </form>
58
+ </div>
59
+ );
60
+ }
@@ -0,0 +1,11 @@
1
+ export default function PricingPage() {
2
+ return (
3
+ <main className="mx-auto max-w-4xl px-6 py-24">
4
+ <h1 className="text-4xl font-bold tracking-tight">Pricing</h1>
5
+ <p className="mt-4 text-lg text-slate-700">Coming soon.</p>
6
+ <p className="mt-2 text-slate-600">
7
+ Stripe subscription wiring ships in the Pro upgrade. v1 of {`{{DISPLAY_NAME}}`} is single-user and free to run.
8
+ </p>
9
+ </main>
10
+ );
11
+ }
@@ -0,0 +1,13 @@
1
+ -- Single-user schema. v1 ships one entity: users.
2
+ -- Better Auth manages its own session/account tables on top of this.
3
+
4
+ CREATE TABLE IF NOT EXISTS users (
5
+ id TEXT PRIMARY KEY,
6
+ email TEXT UNIQUE NOT NULL,
7
+ display_name TEXT,
8
+ password_hash TEXT NOT NULL,
9
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
10
+ );
11
+
12
+ -- v1 deliberately ships no teams, no organizations, no roles, no invites, no memberships.
13
+ -- Add them in a Pro/Studio iteration once a real customer asks for them.
@@ -0,0 +1,15 @@
1
+ // Better Auth init. Replace the database adapter to match your driver of choice.
2
+ // Verify against current better-auth docs if the API has shifted: https://www.better-auth.com
3
+ import { betterAuth } from 'better-auth';
4
+ import { Pool } from 'pg';
5
+
6
+ const pool = process.env.DATABASE_URL
7
+ ? new Pool({ connectionString: process.env.DATABASE_URL })
8
+ : undefined;
9
+
10
+ export const auth = betterAuth({
11
+ database: pool,
12
+ emailAndPassword: { enabled: true },
13
+ secret: process.env.BETTER_AUTH_SECRET,
14
+ baseURL: process.env.BETTER_AUTH_URL,
15
+ });
@@ -0,0 +1,20 @@
1
+ import { Pool, type QueryResult } from 'pg';
2
+
3
+ let _pool: Pool | undefined;
4
+
5
+ function getPool(): Pool {
6
+ if (!process.env.DATABASE_URL) {
7
+ throw new Error('DATABASE_URL is not set. Add it to .env.local before querying.');
8
+ }
9
+ if (!_pool) {
10
+ _pool = new Pool({ connectionString: process.env.DATABASE_URL });
11
+ }
12
+ return _pool;
13
+ }
14
+
15
+ export async function query<T extends Record<string, unknown>>(
16
+ sql: string,
17
+ params: unknown[] = [],
18
+ ): Promise<QueryResult<T>> {
19
+ return getPool().query<T>(sql, params);
20
+ }
@@ -0,0 +1,19 @@
1
+ import { NextResponse } from 'next/server';
2
+ import type { NextRequest } from 'next/server';
3
+
4
+ const SESSION_COOKIE_NAMES = ['better-auth.session_token', 'authjs.session-token'];
5
+
6
+ export function middleware(req: NextRequest) {
7
+ const hasSession = SESSION_COOKIE_NAMES.some((name) => req.cookies.get(name)?.value);
8
+ if (!hasSession) {
9
+ const url = req.nextUrl.clone();
10
+ url.pathname = '/sign-in';
11
+ url.searchParams.set('next', req.nextUrl.pathname);
12
+ return NextResponse.redirect(url);
13
+ }
14
+ return NextResponse.next();
15
+ }
16
+
17
+ export const config = {
18
+ matcher: ['/dashboard/:path*', '/api/account/:path*'],
19
+ };
@@ -0,0 +1,9 @@
1
+ {
2
+ "dependencies": {
3
+ "better-auth": "^1.0.0",
4
+ "pg": "^8.0.0"
5
+ },
6
+ "devDependencies": {
7
+ "@types/pg": "^8.0.0"
8
+ }
9
+ }