@oaklandzoo/ostup 0.9.0 → 0.10.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/README.md +8 -0
- package/package.json +1 -1
- package/scripts/verify-profile.sh +46 -0
- package/src/bootstrap.mjs +146 -0
- package/src/brief/profile-router.mjs +63 -28
- package/templates/START_HERE.md +1 -1
- package/templates/profiles/blog/README.md +45 -40
- package/templates/profiles/blog/app/feed.xml/route.ts +41 -0
- package/templates/profiles/blog/app/page.tsx +30 -0
- package/templates/profiles/blog/app/posts/[slug]/page.tsx +51 -0
- package/templates/profiles/blog/app/sitemap.xml/route.ts +21 -0
- package/templates/profiles/blog/content/posts/getting-started.mdx +16 -0
- package/templates/profiles/blog/content/posts/intro.mdx +14 -0
- package/templates/profiles/blog/content/posts/welcome.mdx +12 -0
- package/templates/profiles/blog/lib/posts.ts +43 -0
- package/templates/profiles/blog/next.config.mjs.additions +9 -0
- package/templates/profiles/blog/package.json.additions +6 -0
- package/templates/profiles/booking/.env.example.additions +3 -11
- package/templates/profiles/booking/README.md +26 -21
- package/templates/profiles/booking/app/api/booking/request/route.ts +76 -0
- package/templates/profiles/booking/app/page.tsx +38 -0
- package/templates/profiles/booking/components/BookingForm.tsx +130 -0
- package/templates/profiles/booking/components/Hero.tsx +20 -0
- package/templates/profiles/booking/components/ServiceList.tsx +19 -0
- package/templates/profiles/booking/lib/resend.ts +33 -0
- package/templates/profiles/booking/lib/storage.ts +44 -0
- package/templates/profiles/booking/package.json.additions +5 -0
- package/templates/profiles/booking/section-prompts.md +10 -8
- package/templates/profiles/lead-gen/.env.example.additions +2 -2
- package/templates/profiles/lead-gen/README.md +35 -27
- package/templates/profiles/lead-gen/app/api/contact/route.ts +49 -0
- package/templates/profiles/lead-gen/app/layout.tsx +29 -0
- package/templates/profiles/lead-gen/app/page.tsx +79 -0
- package/templates/profiles/lead-gen/components/ContactForm.tsx +89 -0
- package/templates/profiles/lead-gen/components/FAQ.tsx +12 -0
- package/templates/profiles/lead-gen/components/Hero.tsx +20 -0
- package/templates/profiles/lead-gen/components/ServiceCard.tsx +8 -0
- package/templates/profiles/lead-gen/lib/resend.ts +33 -0
- package/templates/profiles/lead-gen/package.json.additions +5 -0
- package/templates/profiles/saas-dashboard/.env.example.additions +5 -16
- package/templates/profiles/saas-dashboard/README.md +43 -36
- package/templates/profiles/saas-dashboard/app/(auth)/sign-in/page.tsx +75 -0
- package/templates/profiles/saas-dashboard/app/(auth)/sign-up/page.tsx +86 -0
- package/templates/profiles/saas-dashboard/app/api/auth/[...all]/route.ts +4 -0
- package/templates/profiles/saas-dashboard/app/dashboard/layout.tsx +36 -0
- package/templates/profiles/saas-dashboard/app/dashboard/page.tsx +18 -0
- package/templates/profiles/saas-dashboard/app/dashboard/settings/page.tsx +60 -0
- package/templates/profiles/saas-dashboard/app/pricing/page.tsx +11 -0
- package/templates/profiles/saas-dashboard/db/schema.sql +13 -0
- package/templates/profiles/saas-dashboard/lib/auth.ts +15 -0
- package/templates/profiles/saas-dashboard/lib/db.ts +20 -0
- package/templates/profiles/saas-dashboard/middleware.ts +19 -0
- package/templates/profiles/saas-dashboard/package.json.additions +9 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { useRouter } from 'next/navigation';
|
|
5
|
+
|
|
6
|
+
export default function SignUpPage() {
|
|
7
|
+
const router = useRouter();
|
|
8
|
+
const [email, setEmail] = useState('');
|
|
9
|
+
const [password, setPassword] = useState('');
|
|
10
|
+
const [name, setName] = useState('');
|
|
11
|
+
const [error, setError] = useState('');
|
|
12
|
+
const [pending, setPending] = useState(false);
|
|
13
|
+
|
|
14
|
+
async function onSubmit(e: React.FormEvent) {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
setPending(true);
|
|
17
|
+
setError('');
|
|
18
|
+
try {
|
|
19
|
+
const res = await fetch('/api/auth/sign-up/email', {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
headers: { 'content-type': 'application/json' },
|
|
22
|
+
body: JSON.stringify({ email, password, name }),
|
|
23
|
+
});
|
|
24
|
+
if (!res.ok) {
|
|
25
|
+
const data = (await res.json().catch(() => ({}))) as { error?: string };
|
|
26
|
+
throw new Error(data.error || 'Sign-up failed');
|
|
27
|
+
}
|
|
28
|
+
router.push('/dashboard');
|
|
29
|
+
router.refresh();
|
|
30
|
+
} catch (err) {
|
|
31
|
+
setError(err instanceof Error ? err.message : 'Sign-up failed');
|
|
32
|
+
} finally {
|
|
33
|
+
setPending(false);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<main className="mx-auto flex min-h-screen max-w-md flex-col justify-center px-6 py-12">
|
|
39
|
+
<h1 className="text-3xl font-semibold tracking-tight">Create account</h1>
|
|
40
|
+
<p className="mt-2 text-sm text-slate-600">Get started with {`{{DISPLAY_NAME}}`}.</p>
|
|
41
|
+
<form onSubmit={onSubmit} className="mt-8 space-y-4">
|
|
42
|
+
<label className="block">
|
|
43
|
+
<span className="text-sm font-medium text-slate-700">Display name</span>
|
|
44
|
+
<input
|
|
45
|
+
required
|
|
46
|
+
value={name}
|
|
47
|
+
onChange={(e) => setName(e.target.value)}
|
|
48
|
+
className="mt-1 block w-full rounded-md border border-slate-300 px-3 py-2"
|
|
49
|
+
/>
|
|
50
|
+
</label>
|
|
51
|
+
<label className="block">
|
|
52
|
+
<span className="text-sm font-medium text-slate-700">Email</span>
|
|
53
|
+
<input
|
|
54
|
+
required
|
|
55
|
+
type="email"
|
|
56
|
+
value={email}
|
|
57
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
58
|
+
className="mt-1 block w-full rounded-md border border-slate-300 px-3 py-2"
|
|
59
|
+
/>
|
|
60
|
+
</label>
|
|
61
|
+
<label className="block">
|
|
62
|
+
<span className="text-sm font-medium text-slate-700">Password</span>
|
|
63
|
+
<input
|
|
64
|
+
required
|
|
65
|
+
type="password"
|
|
66
|
+
value={password}
|
|
67
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
68
|
+
minLength={8}
|
|
69
|
+
className="mt-1 block w-full rounded-md border border-slate-300 px-3 py-2"
|
|
70
|
+
/>
|
|
71
|
+
</label>
|
|
72
|
+
{error && <div className="rounded-md bg-red-50 p-3 text-sm text-red-900">{error}</div>}
|
|
73
|
+
<button
|
|
74
|
+
type="submit"
|
|
75
|
+
disabled={pending}
|
|
76
|
+
className="w-full rounded-md bg-slate-900 px-4 py-2 font-medium text-white hover:bg-slate-800 disabled:opacity-60"
|
|
77
|
+
>
|
|
78
|
+
{pending ? 'Creating...' : 'Create account'}
|
|
79
|
+
</button>
|
|
80
|
+
</form>
|
|
81
|
+
<p className="mt-6 text-sm text-slate-600">
|
|
82
|
+
Already have an account? <a className="font-medium text-slate-900 underline" href="/sign-in">Sign in</a>.
|
|
83
|
+
</p>
|
|
84
|
+
</main>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useRouter } from 'next/navigation';
|
|
4
|
+
import Link from 'next/link';
|
|
5
|
+
|
|
6
|
+
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
|
|
7
|
+
const router = useRouter();
|
|
8
|
+
|
|
9
|
+
async function onSignOut() {
|
|
10
|
+
await fetch('/api/auth/sign-out', { method: 'POST' });
|
|
11
|
+
router.push('/sign-in');
|
|
12
|
+
router.refresh();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div className="min-h-screen bg-slate-50">
|
|
17
|
+
<header className="border-b border-slate-200 bg-white">
|
|
18
|
+
<div className="mx-auto flex max-w-6xl items-center justify-between px-6 py-4">
|
|
19
|
+
<Link href="/dashboard" className="text-lg font-semibold tracking-tight">
|
|
20
|
+
{`{{DISPLAY_NAME}}`}
|
|
21
|
+
</Link>
|
|
22
|
+
<nav className="flex items-center gap-4 text-sm">
|
|
23
|
+
<Link href="/dashboard/settings" className="text-slate-600 hover:text-slate-900">Settings</Link>
|
|
24
|
+
<button
|
|
25
|
+
onClick={onSignOut}
|
|
26
|
+
className="rounded-md border border-slate-200 px-3 py-1 text-slate-700 hover:bg-slate-50"
|
|
27
|
+
>
|
|
28
|
+
Sign out
|
|
29
|
+
</button>
|
|
30
|
+
</nav>
|
|
31
|
+
</div>
|
|
32
|
+
</header>
|
|
33
|
+
<main className="mx-auto max-w-6xl px-6 py-10">{children}</main>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default function DashboardPage() {
|
|
2
|
+
return (
|
|
3
|
+
<div>
|
|
4
|
+
<h1 className="text-3xl font-semibold tracking-tight">Welcome</h1>
|
|
5
|
+
<p className="mt-2 text-slate-600">
|
|
6
|
+
This is your starter dashboard. Replace the welcome card below with the metrics, lists, or widgets that matter to your product.
|
|
7
|
+
</p>
|
|
8
|
+
<section className="mt-8 rounded-lg border border-slate-200 bg-white p-6">
|
|
9
|
+
<h2 className="text-lg font-semibold">Getting started</h2>
|
|
10
|
+
<ul className="mt-4 list-inside list-disc space-y-1 text-slate-700">
|
|
11
|
+
<li>Edit <code>app/dashboard/page.tsx</code> to add real content.</li>
|
|
12
|
+
<li>Edit <code>db/schema.sql</code> to add your domain entities.</li>
|
|
13
|
+
<li>Edit <code>app/dashboard/settings/page.tsx</code> to add settings fields.</li>
|
|
14
|
+
</ul>
|
|
15
|
+
</section>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -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
|
+
};
|