anhedral 0.23.0 → 0.24.1
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 +3 -3
- package/assets/launch/AGENTS.md.txt +7 -0
- package/assets/launch/README.md.txt +40 -0
- package/assets/launch/application.server.ts.txt +19 -7
- package/assets/launch/application.test.mjs.txt +8 -0
- package/assets/launch/backend-vite.config.ts.txt +18 -0
- package/assets/launch/home.tsx.txt +25 -2
- package/assets/launch/minimal-application.server.ts.txt +2 -2
- package/assets/launch/root.tsx.txt +38 -5
- package/assets/launch/router.tsx.txt +3 -2
- package/assets/launch/sign-in.tsx.txt +68 -5
- package/assets/launch/storage-page.tsx.txt +57 -0
- package/assets/launch/styles.css.txt +55 -16
- package/assets/launch/styling-tokens.cjs +45 -0
- package/assets/launch/vite.config.ts.txt +13 -0
- package/assets/stack/api-eslint.config.mjs.txt +2 -0
- package/assets/stack/api-index.ts.txt +1 -0
- package/assets/stack/api-proxy.ts.txt +112 -0
- package/assets/stack/auth-routes.ts.txt +3 -1
- package/assets/stack/auth.ts.txt +5 -4
- package/assets/stack/backend.test.mjs.txt +10 -0
- package/assets/stack/base-eslint.js.txt +16 -0
- package/assets/stack/billing-mode.ts.txt +2 -0
- package/assets/stack/billing-providers.ts.txt +8 -0
- package/assets/stack/db-index.ts.txt +7 -0
- package/assets/stack/db-migrate.mjs.txt +23 -0
- package/assets/stack/drizzle.config.ts.txt +2 -0
- package/assets/stack/entitlement-guard.ts.txt +2 -0
- package/assets/stack/entitlements.ts.txt +3 -1
- package/assets/stack/payment.test.mjs.txt +61 -0
- package/assets/stack/security.ts.txt +2 -0
- package/assets/stack/shared-eslint.config.mjs.txt +6 -0
- package/assets/stack/storage.test.mjs.txt +47 -0
- package/assets/stack/storage.ts.txt +3 -1
- package/assets/stack/stripe.ts.txt +4 -2
- package/dist/bounded-file.d.ts +2 -1
- package/dist/bounded-file.js +3 -2
- package/dist/cli-output.js +1 -1
- package/dist/composition/command.js +5 -2
- package/dist/composition/composition.d.ts +1 -0
- package/dist/composition/composition.js +9 -0
- package/dist/composition/editor.d.ts +2 -1
- package/dist/composition/editor.js +15 -3
- package/dist/composition/recipes.d.ts +2 -2
- package/dist/composition/recipes.js +62 -52
- package/dist/composition/update.js +15 -15
- package/dist/dependencies.d.ts +5 -6
- package/dist/dependencies.js +9 -1
- package/dist/launch.d.ts +1 -1
- package/dist/launch.js +26 -91
- package/dist/platform/deploy.js +5 -13
- package/dist/platform/environment.js +10 -2
- package/dist/platform/source.d.ts +2 -0
- package/dist/platform/source.js +52 -11
- package/dist/platform/state.js +9 -2
- package/dist/pnpm-policy.d.ts +1 -0
- package/dist/pnpm-policy.js +27 -0
- package/dist/render.d.ts +0 -10
- package/dist/render.js +1 -38
- package/dist/scaffold/bootstrap.d.ts +1 -2
- package/dist/scaffold/bootstrap.js +4 -8
- package/dist/scaffold/files.d.ts +12 -24
- package/dist/scaffold/files.js +9 -103
- package/dist/scaffold/styling.d.ts +2 -4
- package/dist/scaffold/styling.js +46 -69
- package/dist/scaffold/tanstack.d.ts +2 -2
- package/dist/scaffold/tanstack.js +37 -39
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/capabilities.md +8 -0
- package/docs/software-factory.md +16 -7
- package/package.json +4 -2
- package/dist/api-proxy.d.ts +0 -1
- package/dist/api-proxy.js +0 -48
package/README.md
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
Build an app one addition at a time. Generated applications are editable source. Start with a TanStack Start web app and ShadCN components. Add a backend when you need an API, authentication, or a database. Then choose storage, payments, or both.
|
|
7
7
|
|
|
8
8
|
<picture>
|
|
9
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/anhedral/anhedral-cli/
|
|
10
|
-
<img src="https://raw.githubusercontent.com/anhedral/anhedral-cli/
|
|
9
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/anhedral/anhedral-cli/v0.24.1/docs/assets/anhedral-stack.png">
|
|
10
|
+
<img src="https://raw.githubusercontent.com/anhedral/anhedral-cli/v0.24.1/docs/assets/anhedral-stack-light.png" alt="The CLI creates a TanStack Start web app. The optional backend supports private file storage and subscription payments. An Expo client with Anhedral UI is upcoming.">
|
|
11
11
|
</picture>
|
|
12
12
|
|
|
13
13
|
**Upcoming** — `pnpm dlx anhedral@latest add cross-platform` will add an Expo client with Anhedral UI.
|
|
@@ -31,7 +31,7 @@ pnpm dlx anhedral@latest add storage
|
|
|
31
31
|
pnpm dlx anhedral@latest add payment
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
Run `pnpm dev` in the project directory to start the app. If you added services, configure them first. [Service setup](docs/capabilities.md) · [Source snapshot for each stage](https://github.com/anhedral/anhedral-cli/tree/
|
|
34
|
+
Run `pnpm dev` in the project directory to start the app. If you added services, configure them first. [Service setup](docs/capabilities.md) · [Source snapshot for each stage](https://github.com/anhedral/anhedral-cli/tree/v0.24.1/examples)
|
|
35
35
|
|
|
36
36
|
Upgrading from 0.22.1? Replace `add r2` with `add storage` and `add stripe` with `add payment`. Existing projects keep their R2 and Stripe configuration.
|
|
37
37
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Application conventions
|
|
2
|
+
|
|
3
|
+
- Edit product pages in `apps/web/src/routes` and shared UI in `apps/web/src/components/ui`. Keep the ShadCN license with its components.
|
|
4
|
+
- With the backend installed, put custom API routes in `apps/api/src/index.ts` and database schema in `packages/db/src`. Web server functions call the API through its service binding. Keep identity, secrets, and database and storage access in the API.
|
|
5
|
+
- Review auth configuration before enabling a sign-in method. Generate and review SQL before applying it to an explicitly selected database. Builds, tests, and startup must leave configured databases untouched.
|
|
6
|
+
- Preview changes to CLI-managed adapters with `pnpm dlx anhedral@latest stack update --dry-run --human`. Preserve existing application edits.
|
|
7
|
+
- Run `pnpm check` and `pnpm audit:deps` before shipping.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# __APP_NAME__
|
|
2
|
+
|
|
3
|
+
A TanStack Start web app with editable ShadCN components.
|
|
4
|
+
|
|
5
|
+
## Run locally
|
|
6
|
+
|
|
7
|
+
Use the Node.js and pnpm versions declared in `package.json`. If you skipped installation during setup, run `pnpm install` first.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Open http://localhost:3000. Edit `apps/web/src/routes/index.tsx` for the home page and `apps/web/src/routes/__root.tsx` for the shared layout. UI components live in `apps/web/src/components/ui`. You can use any UI library.
|
|
14
|
+
|
|
15
|
+
## Check your changes
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
pnpm check # Lint, typecheck, test, and build
|
|
19
|
+
pnpm audit:deps # Audit installed dependencies
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Add services
|
|
23
|
+
|
|
24
|
+
Run the backend command first, then add storage or payment as needed.
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
pnpm dlx anhedral@latest add backend # Hono, Better Auth, and Drizzle/D1
|
|
28
|
+
pnpm dlx anhedral@latest add storage # Private files on R2
|
|
29
|
+
pnpm dlx anhedral@latest add payment # Stripe subscriptions
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
After adding a service, follow the environment and migration instructions before running it locally. [Service setup](https://github.com/anhedral/anhedral-cli/blob/v__CLI_VERSION__/docs/capabilities.md#local-setup-and-validation)
|
|
33
|
+
|
|
34
|
+
## Update the stack
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
pnpm dlx anhedral@latest stack update --dry-run --human
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Review the diff and run the version-pinned apply command it prints. Then run `pnpm install` and `pnpm check`.
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import type { ApplicationContext } from './request-context';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
async function backendConnected(api: ApplicationContext['api']): Promise<boolean> {
|
|
4
|
+
if (!api) return false;
|
|
4
5
|
try {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
6
|
+
const request = new Request('https://api.internal/api/health', {
|
|
7
|
+
signal: AbortSignal.timeout(5000),
|
|
8
|
+
});
|
|
9
|
+
const response = await api.fetch(request);
|
|
10
|
+
if (!response.ok) return false;
|
|
11
|
+
const body: unknown = await response.json();
|
|
12
|
+
return typeof body === 'object' && body !== null && Reflect.get(body, 'ok') === true;
|
|
10
13
|
} catch {
|
|
11
|
-
return
|
|
14
|
+
return false;
|
|
12
15
|
}
|
|
13
16
|
}
|
|
17
|
+
|
|
18
|
+
export async function readApplicationStatus(context: ApplicationContext) {
|
|
19
|
+
return {
|
|
20
|
+
api: await backendConnected(context.api),
|
|
21
|
+
authentication: __AUTHENTICATION__,
|
|
22
|
+
storage: __STORAGE__,
|
|
23
|
+
payment: __PAYMENT__,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { readApplicationStatus } from '../src/lib/application.server.ts';
|
|
4
|
+
|
|
5
|
+
test('the starter renders when no API binding is available', async () => {
|
|
6
|
+
const status = await readApplicationStatus({});
|
|
7
|
+
assert.equal(status.api, status.authentication ? false : null);
|
|
8
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import { cloudflare } from '@cloudflare/vite-plugin';
|
|
4
|
+
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
|
|
5
|
+
import react from '@vitejs/plugin-react';
|
|
6
|
+
export default defineConfig(({ command }) => ({
|
|
7
|
+
resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } },
|
|
8
|
+
plugins: [
|
|
9
|
+
cloudflare({
|
|
10
|
+
viteEnvironment: { name: 'ssr' },
|
|
11
|
+
auxiliaryWorkers: command === 'serve' ? [{ configPath: '../api/wrangler.jsonc' }] : [],
|
|
12
|
+
persistState: { path: fileURLToPath(new URL('../api/.wrangler/state', import.meta.url)) },
|
|
13
|
+
remoteBindings: false,
|
|
14
|
+
}),
|
|
15
|
+
tanstackStart({ server: { entry: './server.ts' } }),
|
|
16
|
+
react(),
|
|
17
|
+
],
|
|
18
|
+
}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { starterTitle } from '../starter';
|
|
2
1
|
import { createFileRoute, useRouter } from '@tanstack/react-router';
|
|
3
2
|
import { createServerFn } from '@tanstack/react-start';
|
|
3
|
+
|
|
4
|
+
import { starterTitle } from '../starter';
|
|
4
5
|
import { Button } from '@/components/ui/button';
|
|
5
6
|
|
|
6
7
|
const applicationStatus = createServerFn({ method: 'GET' }).handler(async ({ context }) => {
|
|
@@ -16,5 +17,27 @@ export const Route = createFileRoute('/')({
|
|
|
16
17
|
function Home() {
|
|
17
18
|
const router = useRouter();
|
|
18
19
|
const status = Route.useLoaderData();
|
|
19
|
-
return
|
|
20
|
+
return (
|
|
21
|
+
<section className="stack">
|
|
22
|
+
<h1>{starterTitle}</h1>
|
|
23
|
+
<p>
|
|
24
|
+
Edit <code>apps/web/src/routes/index.tsx</code> to change this page.
|
|
25
|
+
</p>
|
|
26
|
+
<p data-rendering="server">
|
|
27
|
+
Rendered on the server.{' '}
|
|
28
|
+
{status.api === null
|
|
29
|
+
? 'Backend not added'
|
|
30
|
+
: status.api
|
|
31
|
+
? 'API: connected'
|
|
32
|
+
: 'API: unavailable'}
|
|
33
|
+
.
|
|
34
|
+
</p>
|
|
35
|
+
{status.authentication && <a href="/sign-in">Your account</a>}
|
|
36
|
+
{status.storage && <a href="/storage">Private files</a>}
|
|
37
|
+
{status.payment && <a href="/api/billing/status">Check subscription status</a>}
|
|
38
|
+
{status.api !== null && (
|
|
39
|
+
<Button onClick={() => void router.invalidate()}>Check connection</Button>
|
|
40
|
+
)}
|
|
41
|
+
</section>
|
|
42
|
+
);
|
|
20
43
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ApplicationContext } from './request-context';
|
|
2
2
|
|
|
3
|
-
export async function readApplicationStatus(_context: ApplicationContext)
|
|
4
|
-
return { api: null, authentication: false };
|
|
3
|
+
export async function readApplicationStatus(_context: ApplicationContext) {
|
|
4
|
+
return { api: null, authentication: false, storage: false, payment: false };
|
|
5
5
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { starterTitle } from '../starter';
|
|
2
1
|
import { createRootRoute, HeadContent, Link, Outlet, Scripts } from '@tanstack/react-router';
|
|
3
2
|
import type { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import { starterTitle } from '../starter';
|
|
5
|
+
|
|
4
6
|
import '../styles.css';
|
|
5
7
|
|
|
6
8
|
export const Route = createRootRoute({
|
|
@@ -13,14 +15,45 @@ export const Route = createRootRoute({
|
|
|
13
15
|
],
|
|
14
16
|
}),
|
|
15
17
|
component: Root,
|
|
16
|
-
notFoundComponent: () =>
|
|
17
|
-
|
|
18
|
+
notFoundComponent: () => (
|
|
19
|
+
<section className="stack">
|
|
20
|
+
<h1>Page not found</h1>
|
|
21
|
+
<Link to="/">Return home</Link>
|
|
22
|
+
</section>
|
|
23
|
+
),
|
|
24
|
+
errorComponent: ({ reset }) => (
|
|
25
|
+
<section className="stack">
|
|
26
|
+
<h1>Unable to load this page</h1>
|
|
27
|
+
<button type="button" onClick={reset}>
|
|
28
|
+
Try again
|
|
29
|
+
</button>
|
|
30
|
+
</section>
|
|
31
|
+
),
|
|
18
32
|
});
|
|
19
33
|
|
|
20
34
|
function Root() {
|
|
21
|
-
return
|
|
35
|
+
return (
|
|
36
|
+
<Document>
|
|
37
|
+
<main>
|
|
38
|
+
<nav aria-label="Main">
|
|
39
|
+
<Link to="/">Home</Link>
|
|
40
|
+
</nav>
|
|
41
|
+
<Outlet />
|
|
42
|
+
</main>
|
|
43
|
+
</Document>
|
|
44
|
+
);
|
|
22
45
|
}
|
|
23
46
|
|
|
24
47
|
function Document({ children }: { children: ReactNode }) {
|
|
25
|
-
return
|
|
48
|
+
return (
|
|
49
|
+
<html lang="en">
|
|
50
|
+
<head>
|
|
51
|
+
<HeadContent />
|
|
52
|
+
</head>
|
|
53
|
+
<body>
|
|
54
|
+
{children}
|
|
55
|
+
<Scripts />
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
|
58
|
+
);
|
|
26
59
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type {} from '@tanstack/react-start';
|
|
2
1
|
import { createRouter } from '@tanstack/react-router';
|
|
3
|
-
import {
|
|
2
|
+
import type {} from '@tanstack/react-start';
|
|
3
|
+
|
|
4
4
|
import type { ApplicationContext } from './lib/request-context';
|
|
5
|
+
import { routeTree } from './routeTree.gen';
|
|
5
6
|
|
|
6
7
|
export function getRouter() {
|
|
7
8
|
return createRouter({ routeTree, scrollRestoration: true });
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createFileRoute } from '@tanstack/react-router';
|
|
2
2
|
import { useState, type FormEvent } from 'react';
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import { Button } from '@/components/ui/button';
|
|
5
5
|
import { Input } from '@/components/ui/input';
|
|
6
6
|
import { Label } from '@/components/ui/label';
|
|
7
|
+
import { authClient } from '@/lib/auth-client';
|
|
7
8
|
|
|
8
9
|
export const Route = createFileRoute('/sign-in')({ component: Account });
|
|
9
10
|
|
|
@@ -24,7 +25,8 @@ function Account() {
|
|
|
24
25
|
const result = creating
|
|
25
26
|
? await authClient.signUp.email({ email, password, name: String(data.get('name') ?? '') })
|
|
26
27
|
: await authClient.signIn.email({ email, password });
|
|
27
|
-
if (result.error)
|
|
28
|
+
if (result.error)
|
|
29
|
+
setError(result.error.message ?? 'Unable to sign in. Check your details and try again.');
|
|
28
30
|
else await refetch();
|
|
29
31
|
} catch {
|
|
30
32
|
setError('Unable to reach the account service. Try again.');
|
|
@@ -47,7 +49,68 @@ function Account() {
|
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
if (isPending) return <p role="status">Loading your account…</p>;
|
|
50
|
-
if (sessionError)
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
if (sessionError)
|
|
53
|
+
return (
|
|
54
|
+
<section className="stack">
|
|
55
|
+
<h1>Account unavailable</h1>
|
|
56
|
+
<p role="alert">
|
|
57
|
+
Unable to load your account. Check that the API and authentication are configured.
|
|
58
|
+
</p>
|
|
59
|
+
<Button onClick={() => void refetch()}>Try again</Button>
|
|
60
|
+
</section>
|
|
61
|
+
);
|
|
62
|
+
if (session)
|
|
63
|
+
return (
|
|
64
|
+
<section className="stack">
|
|
65
|
+
<h1>Your account</h1>
|
|
66
|
+
<p>{session.user.email}</p>
|
|
67
|
+
{error && <p role="alert">{error}</p>}
|
|
68
|
+
<Button disabled={busy} onClick={() => void signOut()}>
|
|
69
|
+
{busy ? 'Signing out…' : 'Sign out'}
|
|
70
|
+
</Button>
|
|
71
|
+
</section>
|
|
72
|
+
);
|
|
73
|
+
return (
|
|
74
|
+
<section className="stack">
|
|
75
|
+
<h1>{creating ? 'Create an account' : 'Sign in'}</h1>
|
|
76
|
+
<p className="muted">
|
|
77
|
+
Email and password must be explicitly enabled in the API authentication configuration.
|
|
78
|
+
</p>
|
|
79
|
+
<form onSubmit={submit}>
|
|
80
|
+
{creating && (
|
|
81
|
+
<>
|
|
82
|
+
<Label htmlFor="name">Name</Label>
|
|
83
|
+
<Input id="name" name="name" autoComplete="name" required maxLength={160} />
|
|
84
|
+
</>
|
|
85
|
+
)}
|
|
86
|
+
<Label htmlFor="email">Email</Label>
|
|
87
|
+
<Input id="email" name="email" type="email" autoComplete="email" required maxLength={254} />
|
|
88
|
+
<Label htmlFor="password">Password</Label>
|
|
89
|
+
<Input
|
|
90
|
+
id="password"
|
|
91
|
+
name="password"
|
|
92
|
+
type="password"
|
|
93
|
+
autoComplete={creating ? 'new-password' : 'current-password'}
|
|
94
|
+
required
|
|
95
|
+
minLength={8}
|
|
96
|
+
maxLength={128}
|
|
97
|
+
/>
|
|
98
|
+
{error && <p role="alert">{error}</p>}
|
|
99
|
+
<Button type="submit" disabled={busy}>
|
|
100
|
+
{busy ? 'Working…' : creating ? 'Create account' : 'Sign in'}
|
|
101
|
+
</Button>
|
|
102
|
+
<Button
|
|
103
|
+
type="button"
|
|
104
|
+
variant="ghost"
|
|
105
|
+
disabled={busy}
|
|
106
|
+
onClick={() => {
|
|
107
|
+
setCreating(!creating);
|
|
108
|
+
setError('');
|
|
109
|
+
}}
|
|
110
|
+
>
|
|
111
|
+
{creating ? 'Already have an account? Sign in' : 'Create an account'}
|
|
112
|
+
</Button>
|
|
113
|
+
</form>
|
|
114
|
+
</section>
|
|
115
|
+
);
|
|
53
116
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
+
import { useState, type FormEvent } from 'react';
|
|
3
|
+
|
|
4
|
+
import { Button } from '@/components/ui/button';
|
|
5
|
+
|
|
6
|
+
export const Route = createFileRoute('/storage')({ component: Storage });
|
|
7
|
+
|
|
8
|
+
function Storage() {
|
|
9
|
+
const [stored, setStored] = useState('');
|
|
10
|
+
const [message, setMessage] = useState('');
|
|
11
|
+
const [busy, setBusy] = useState(false);
|
|
12
|
+
|
|
13
|
+
async function upload(event: FormEvent<HTMLFormElement>) {
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
const file = new FormData(event.currentTarget).get('file');
|
|
16
|
+
if (!(file instanceof File) || !file.name || busy) return;
|
|
17
|
+
setStored('');
|
|
18
|
+
setBusy(true);
|
|
19
|
+
try {
|
|
20
|
+
const path = '/api/files/' + encodeURIComponent(file.name);
|
|
21
|
+
const response = await fetch(path, { method: 'PUT', body: file });
|
|
22
|
+
if (response.ok) setStored(path);
|
|
23
|
+
setMessage(
|
|
24
|
+
response.ok
|
|
25
|
+
? 'File stored.'
|
|
26
|
+
: response.status === 401
|
|
27
|
+
? 'Sign in to upload.'
|
|
28
|
+
: 'Upload failed. Check the file name, size, and storage configuration.',
|
|
29
|
+
);
|
|
30
|
+
} catch {
|
|
31
|
+
setMessage('Storage is unavailable.');
|
|
32
|
+
} finally {
|
|
33
|
+
setBusy(false);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<section className="stack">
|
|
39
|
+
<h1>Private files</h1>
|
|
40
|
+
<form onSubmit={upload}>
|
|
41
|
+
<label>
|
|
42
|
+
Choose a file up to 1 MiB <input type="file" name="file" required />
|
|
43
|
+
</label>
|
|
44
|
+
<Button disabled={busy} type="submit">
|
|
45
|
+
Upload
|
|
46
|
+
</Button>
|
|
47
|
+
</form>
|
|
48
|
+
<p role="status">{message}</p>
|
|
49
|
+
{stored && (
|
|
50
|
+
<a href={stored} download>
|
|
51
|
+
Download your file
|
|
52
|
+
</a>
|
|
53
|
+
)}
|
|
54
|
+
<a href="/sign-in">Your account</a>
|
|
55
|
+
</section>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -1,19 +1,58 @@
|
|
|
1
1
|
@import 'tailwindcss';
|
|
2
2
|
@import '@workspace/styling/globals.css';
|
|
3
3
|
@theme inline {
|
|
4
|
-
--color-background: hsl(var(--background));
|
|
5
|
-
--color-
|
|
6
|
-
--color-
|
|
7
|
-
--color-
|
|
8
|
-
--color-
|
|
9
|
-
--color-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
--color-background: hsl(var(--background));
|
|
5
|
+
--color-foreground: hsl(var(--foreground));
|
|
6
|
+
--color-primary: hsl(var(--primary));
|
|
7
|
+
--color-primary-foreground: hsl(var(--primary-foreground));
|
|
8
|
+
--color-secondary: hsl(var(--secondary));
|
|
9
|
+
--color-secondary-foreground: hsl(var(--secondary-foreground));
|
|
10
|
+
--color-muted: hsl(var(--muted));
|
|
11
|
+
--color-muted-foreground: hsl(var(--muted-foreground));
|
|
12
|
+
--color-border: hsl(var(--border));
|
|
13
|
+
--color-input: hsl(var(--input));
|
|
14
|
+
--color-ring: hsl(var(--ring));
|
|
15
|
+
--color-destructive: hsl(var(--destructive));
|
|
16
|
+
--radius-md: var(--radius);
|
|
17
|
+
--radius-lg: calc(var(--radius) + 2px);
|
|
18
|
+
}
|
|
19
|
+
* {
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
}
|
|
22
|
+
body {
|
|
23
|
+
margin: 0;
|
|
24
|
+
background: hsl(var(--background));
|
|
25
|
+
color: hsl(var(--foreground));
|
|
26
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
27
|
+
}
|
|
28
|
+
main {
|
|
29
|
+
max-width: 64rem;
|
|
30
|
+
margin: 0 auto;
|
|
31
|
+
padding: 4rem 1.5rem;
|
|
32
|
+
}
|
|
33
|
+
nav {
|
|
34
|
+
display: flex;
|
|
35
|
+
gap: 1rem;
|
|
36
|
+
margin-bottom: 3rem;
|
|
37
|
+
}
|
|
38
|
+
.stack,
|
|
39
|
+
form {
|
|
40
|
+
display: grid;
|
|
41
|
+
gap: 1rem;
|
|
42
|
+
}
|
|
43
|
+
form {
|
|
44
|
+
width: 100%;
|
|
45
|
+
max-width: 26rem;
|
|
46
|
+
}
|
|
47
|
+
h1 {
|
|
48
|
+
font-size: 2rem;
|
|
49
|
+
font-weight: 600;
|
|
50
|
+
line-height: 1.2;
|
|
51
|
+
letter-spacing: -0.025em;
|
|
52
|
+
}
|
|
53
|
+
a {
|
|
54
|
+
color: inherit;
|
|
55
|
+
}
|
|
56
|
+
.muted {
|
|
57
|
+
color: hsl(var(--muted-foreground));
|
|
58
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
exports.light = {
|
|
2
|
+
'--background': '0 0% 100%',
|
|
3
|
+
'--foreground': '0 0% 9%',
|
|
4
|
+
'--card': '0 0% 100%',
|
|
5
|
+
'--card-foreground': '0 0% 9%',
|
|
6
|
+
'--popover': '0 0% 100%',
|
|
7
|
+
'--popover-foreground': '0 0% 9%',
|
|
8
|
+
'--primary': '0 0% 9%',
|
|
9
|
+
'--primary-foreground': '0 0% 98%',
|
|
10
|
+
'--secondary': '0 0% 96.1%',
|
|
11
|
+
'--secondary-foreground': '0 0% 9%',
|
|
12
|
+
'--muted': '0 0% 96.1%',
|
|
13
|
+
'--muted-foreground': '0 0% 45.1%',
|
|
14
|
+
'--accent': '0 0% 96.1%',
|
|
15
|
+
'--accent-foreground': '0 0% 9%',
|
|
16
|
+
'--destructive': '0 84.2% 60.2%',
|
|
17
|
+
'--destructive-foreground': '0 0% 98%',
|
|
18
|
+
'--border': '0 0% 89.8%',
|
|
19
|
+
'--input': '0 0% 89.8%',
|
|
20
|
+
'--ring': '0 0% 63.9%',
|
|
21
|
+
'--radius': '0.5rem',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.dark = {
|
|
25
|
+
...exports.light,
|
|
26
|
+
'--background': '0 0% 9%',
|
|
27
|
+
'--foreground': '0 0% 98%',
|
|
28
|
+
'--card': '0 0% 9%',
|
|
29
|
+
'--card-foreground': '0 0% 98%',
|
|
30
|
+
'--popover': '0 0% 9%',
|
|
31
|
+
'--popover-foreground': '0 0% 98%',
|
|
32
|
+
'--primary': '0 0% 98%',
|
|
33
|
+
'--primary-foreground': '0 0% 9%',
|
|
34
|
+
'--secondary': '0 0% 14.9%',
|
|
35
|
+
'--secondary-foreground': '0 0% 98%',
|
|
36
|
+
'--muted': '0 0% 14.9%',
|
|
37
|
+
'--muted-foreground': '0 0% 63.9%',
|
|
38
|
+
'--accent': '0 0% 14.9%',
|
|
39
|
+
'--accent-foreground': '0 0% 98%',
|
|
40
|
+
'--destructive': '0 70.9% 59.4%',
|
|
41
|
+
'--border': '0 0% 14.9%',
|
|
42
|
+
'--input': '0 0% 14.9%',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.spacing = { small: 4, medium: 8, large: 16 };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import { cloudflare } from '@cloudflare/vite-plugin';
|
|
4
|
+
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
|
|
5
|
+
import react from '@vitejs/plugin-react';
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } },
|
|
8
|
+
plugins: [
|
|
9
|
+
cloudflare({ viteEnvironment: { name: 'ssr' }, remoteBindings: false }),
|
|
10
|
+
tanstackStart({ server: { entry: './server.ts' } }),
|
|
11
|
+
react(),
|
|
12
|
+
],
|
|
13
|
+
});
|