alchemy 0.37.2 → 0.38.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/bin/alchemy.mjs +44306 -48055
- package/bin/alchemy.ts +80 -85
- package/bin/commands/create.ts +263 -0
- package/bin/constants.ts +13 -0
- package/bin/errors.ts +11 -0
- package/bin/services/dependencies.ts +47 -0
- package/bin/services/get-package-version.ts +11 -0
- package/bin/services/package-manager.ts +113 -0
- package/bin/services/template-manager.ts +137 -0
- package/bin/types.ts +83 -0
- package/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +12 -3
- package/lib/alchemy.js.map +1 -1
- package/lib/apply.d.ts +2 -0
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +47 -12
- package/lib/apply.js.map +1 -1
- package/lib/build-date.d.ts +6 -0
- package/lib/build-date.d.ts.map +1 -0
- package/lib/build-date.js +8 -0
- package/lib/build-date.js.map +1 -0
- package/lib/cloudflare/api.d.ts.map +1 -1
- package/lib/cloudflare/api.js +2 -1
- package/lib/cloudflare/api.js.map +1 -1
- package/lib/cloudflare/do-state-store/internal.js +5 -3
- package/lib/cloudflare/do-state-store/internal.js.map +1 -1
- package/lib/cloudflare/do-state-store/worker.d.ts.map +1 -1
- package/lib/cloudflare/do-state-store/worker.js +6 -1
- package/lib/cloudflare/do-state-store/worker.js.map +1 -1
- package/lib/cloudflare/pipeline.d.ts +1 -1
- package/lib/cloudflare/pipeline.d.ts.map +1 -1
- package/lib/cloudflare/pipeline.js +6 -1
- package/lib/cloudflare/pipeline.js.map +1 -1
- package/lib/cloudflare/worker-stub.d.ts +23 -2
- package/lib/cloudflare/worker-stub.d.ts.map +1 -1
- package/lib/cloudflare/worker-stub.js +16 -2
- package/lib/cloudflare/worker-stub.js.map +1 -1
- package/lib/cloudflare/worker.d.ts +5 -4
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +4 -7
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/context.d.ts +2 -2
- package/lib/context.d.ts.map +1 -1
- package/lib/destroy.d.ts +8 -2
- package/lib/destroy.d.ts.map +1 -1
- package/lib/destroy.js +19 -5
- package/lib/destroy.js.map +1 -1
- package/lib/scope.d.ts +26 -4
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +104 -9
- package/lib/scope.js.map +1 -1
- package/lib/sentry/project.js +1 -1
- package/lib/sentry/project.js.map +1 -1
- package/lib/util/logger.js +1 -1
- package/lib/util/logger.js.map +1 -1
- package/lib/util/mutex.d.ts +9 -0
- package/lib/util/mutex.d.ts.map +1 -0
- package/lib/util/mutex.js +35 -0
- package/lib/util/mutex.js.map +1 -0
- package/package.json +16 -6
- package/src/alchemy.ts +17 -5
- package/src/apply.ts +67 -17
- package/src/build-date.ts +8 -0
- package/src/cloudflare/api.ts +2 -1
- package/src/cloudflare/do-state-store/internal.ts +5 -3
- package/src/cloudflare/do-state-store/worker.ts +13 -3
- package/src/cloudflare/pipeline.ts +6 -0
- package/src/cloudflare/worker-stub.ts +31 -2
- package/src/cloudflare/worker.ts +6 -15
- package/src/context.ts +2 -2
- package/src/destroy.ts +30 -7
- package/src/scope.ts +145 -10
- package/src/sentry/project.ts +1 -1
- package/src/util/logger.ts +1 -1
- package/src/util/mutex.ts +33 -0
- package/templates/astro/.vscode/extensions.json +4 -0
- package/templates/astro/.vscode/launch.json +11 -0
- package/templates/astro/README.md +48 -0
- package/templates/astro/_env.example +1 -0
- package/templates/astro/_gitignore +27 -0
- package/templates/astro/alchemy.run.ts +16 -0
- package/templates/astro/astro.config.mjs +8 -0
- package/templates/astro/package.json +23 -0
- package/templates/astro/public/favicon.svg +9 -0
- package/templates/astro/src/assets/astro.svg +1 -0
- package/templates/astro/src/assets/background.svg +1 -0
- package/templates/astro/src/components/Welcome.astro +210 -0
- package/templates/astro/src/layouts/Layout.astro +22 -0
- package/templates/astro/src/pages/api/hello.ts +19 -0
- package/templates/astro/src/pages/index.astro +11 -0
- package/templates/astro/tsconfig.json +18 -0
- package/templates/astro/types/env.d.ts +16 -0
- package/templates/astro/wrangler.jsonc +6 -0
- package/templates/nuxt/README.md +75 -0
- package/templates/nuxt/_env +1 -0
- package/templates/nuxt/_env.example +1 -0
- package/templates/nuxt/_gitignore +27 -0
- package/templates/nuxt/alchemy.run.ts +16 -0
- package/templates/nuxt/app.vue +6 -0
- package/templates/nuxt/nuxt.config.ts +13 -0
- package/templates/nuxt/package.json +26 -0
- package/templates/nuxt/public/favicon.ico +0 -0
- package/templates/nuxt/public/robots.txt +2 -0
- package/templates/nuxt/server/api/hello.ts +7 -0
- package/templates/nuxt/server/middleware/auth.ts +5 -0
- package/templates/nuxt/server/middleware/hello.ts +5 -0
- package/templates/nuxt/server/tsconfig.json +3 -0
- package/templates/nuxt/tsconfig.json +15 -0
- package/templates/nuxt/types/env.d.ts +16 -0
- package/templates/react-router/.vscode/settings.json +5 -0
- package/templates/react-router/README.md +79 -0
- package/templates/react-router/_env +1 -0
- package/templates/react-router/_env.example +1 -0
- package/templates/react-router/_gitignore +15 -0
- package/templates/react-router/alchemy.run.ts +17 -0
- package/templates/react-router/app/app.css +15 -0
- package/templates/react-router/app/entry.server.tsx +43 -0
- package/templates/react-router/app/root.tsx +75 -0
- package/templates/react-router/app/routes/home.tsx +17 -0
- package/templates/react-router/app/routes.ts +3 -0
- package/templates/react-router/app/welcome/logo-dark.svg +23 -0
- package/templates/react-router/app/welcome/logo-light.svg +23 -0
- package/templates/react-router/app/welcome/welcome.tsx +90 -0
- package/templates/react-router/package.json +34 -0
- package/templates/react-router/public/favicon.ico +0 -0
- package/templates/react-router/react-router.config.ts +8 -0
- package/templates/react-router/tsconfig.cloudflare.json +27 -0
- package/templates/react-router/tsconfig.json +17 -0
- package/templates/react-router/tsconfig.node.json +20 -0
- package/templates/react-router/types/env.d.ts +16 -0
- package/templates/react-router/vite.config.ts +14 -0
- package/templates/react-router/workers/app.ts +23 -0
- package/templates/react-router/wrangler.jsonc +6 -0
- package/templates/rwsdk/.cursor/rules/rwsdk_rwsdk-interruptors.mdc +247 -0
- package/templates/rwsdk/.cursor/rules/rwsdk_rwsdk-middleware.mdc +75 -0
- package/templates/rwsdk/.cursor/rules/rwsdk_rwsdk-react.mdc +110 -0
- package/templates/rwsdk/.cursor/rules/rwsdk_rwsdk-request-response.mdc +213 -0
- package/templates/rwsdk/.devcontainer/Dockerfile +8 -0
- package/templates/rwsdk/.devcontainer/devcontainer.json +21 -0
- package/templates/rwsdk/README.md +62 -0
- package/templates/rwsdk/_env +5 -0
- package/templates/rwsdk/_env.example +5 -0
- package/templates/rwsdk/_gitignore +71 -0
- package/templates/rwsdk/alchemy.run.ts +29 -0
- package/templates/rwsdk/package.json +61 -0
- package/templates/rwsdk/prisma/schema.prisma +43 -0
- package/templates/rwsdk/src/app/Document.tsx +16 -0
- package/templates/rwsdk/src/app/headers.ts +32 -0
- package/templates/rwsdk/src/app/pages/Home.tsx +13 -0
- package/templates/rwsdk/src/app/pages/user/Login.tsx +79 -0
- package/templates/rwsdk/src/app/pages/user/functions.ts +171 -0
- package/templates/rwsdk/src/app/pages/user/routes.ts +17 -0
- package/templates/rwsdk/src/app/shared/links.ts +3 -0
- package/templates/rwsdk/src/client.tsx +3 -0
- package/templates/rwsdk/src/db.ts +26 -0
- package/templates/rwsdk/src/scripts/seed.ts +21 -0
- package/templates/rwsdk/src/session/durableObject.ts +63 -0
- package/templates/rwsdk/src/session/store.ts +13 -0
- package/templates/rwsdk/src/worker.tsx +63 -0
- package/templates/rwsdk/tsconfig.json +47 -0
- package/templates/rwsdk/types/env.d.ts +16 -0
- package/templates/rwsdk/types/rw.d.ts +5 -0
- package/templates/rwsdk/types/vite.d.ts +4 -0
- package/templates/rwsdk/vite.config.mts +6 -0
- package/templates/rwsdk/wrangler.jsonc +28 -0
- package/templates/sveltekit/README.md +38 -0
- package/templates/sveltekit/_env +1 -0
- package/templates/sveltekit/_env.example +1 -0
- package/templates/sveltekit/_gitignore +26 -0
- package/templates/sveltekit/_npmrc +1 -0
- package/templates/sveltekit/_prettierrc +3 -0
- package/templates/sveltekit/alchemy.run.ts +16 -0
- package/templates/sveltekit/bun.lock +1099 -0
- package/templates/sveltekit/package.json +33 -0
- package/templates/sveltekit/src/app.css +1 -0
- package/templates/sveltekit/src/app.d.ts +13 -0
- package/templates/sveltekit/src/app.html +12 -0
- package/templates/sveltekit/src/routes/+layout.svelte +7 -0
- package/templates/sveltekit/src/routes/+page.svelte +2 -0
- package/templates/sveltekit/static/favicon.png +0 -0
- package/templates/sveltekit/svelte.config.js +12 -0
- package/templates/sveltekit/tsconfig.json +27 -0
- package/templates/sveltekit/types/env.d.ts +16 -0
- package/templates/sveltekit/vite.config.ts +6 -0
- package/templates/sveltekit/wrangler.jsonc +7 -0
- package/templates/tanstack-start/.vscode/settings.json +11 -0
- package/templates/tanstack-start/README.md +72 -0
- package/templates/tanstack-start/_env +1 -0
- package/templates/tanstack-start/_env.example +1 -0
- package/templates/tanstack-start/_gitignore +22 -0
- package/templates/tanstack-start/_prettierignore +4 -0
- package/templates/tanstack-start/alchemy.run.ts +16 -0
- package/templates/tanstack-start/package.json +37 -0
- package/templates/tanstack-start/public/android-chrome-192x192.png +0 -0
- package/templates/tanstack-start/public/android-chrome-512x512.png +0 -0
- package/templates/tanstack-start/public/apple-touch-icon.png +0 -0
- package/templates/tanstack-start/public/favicon-16x16.png +0 -0
- package/templates/tanstack-start/public/favicon-32x32.png +0 -0
- package/templates/tanstack-start/public/favicon.ico +0 -0
- package/templates/tanstack-start/public/favicon.png +0 -0
- package/templates/tanstack-start/public/site.webmanifest +19 -0
- package/templates/tanstack-start/src/components/DefaultCatchBoundary.tsx +53 -0
- package/templates/tanstack-start/src/components/NotFound.tsx +25 -0
- package/templates/tanstack-start/src/components/PostError.tsx +5 -0
- package/templates/tanstack-start/src/components/UserError.tsx +5 -0
- package/templates/tanstack-start/src/router.tsx +22 -0
- package/templates/tanstack-start/src/routes/__root.tsx +146 -0
- package/templates/tanstack-start/src/routes/_pathlessLayout/_nested-layout/route-a.tsx +10 -0
- package/templates/tanstack-start/src/routes/_pathlessLayout/_nested-layout/route-b.tsx +10 -0
- package/templates/tanstack-start/src/routes/_pathlessLayout/_nested-layout.tsx +34 -0
- package/templates/tanstack-start/src/routes/_pathlessLayout.tsx +16 -0
- package/templates/tanstack-start/src/routes/api/users.$userId.ts +28 -0
- package/templates/tanstack-start/src/routes/api/users.ts +59 -0
- package/templates/tanstack-start/src/routes/customScript[.]js.ts +10 -0
- package/templates/tanstack-start/src/routes/deferred.tsx +62 -0
- package/templates/tanstack-start/src/routes/index.tsx +12 -0
- package/templates/tanstack-start/src/routes/posts.$postId.tsx +34 -0
- package/templates/tanstack-start/src/routes/posts.index.tsx +8 -0
- package/templates/tanstack-start/src/routes/posts.tsx +38 -0
- package/templates/tanstack-start/src/routes/posts_.$postId.deep.tsx +29 -0
- package/templates/tanstack-start/src/routes/redirect.tsx +9 -0
- package/templates/tanstack-start/src/routes/users.$userId.tsx +44 -0
- package/templates/tanstack-start/src/routes/users.index.tsx +18 -0
- package/templates/tanstack-start/src/routes/users.tsx +49 -0
- package/templates/tanstack-start/src/styles/app.css +12 -0
- package/templates/tanstack-start/src/utils/loggingMiddleware.tsx +41 -0
- package/templates/tanstack-start/src/utils/posts.tsx +40 -0
- package/templates/tanstack-start/src/utils/seo.ts +33 -0
- package/templates/tanstack-start/src/utils/users.tsx +5 -0
- package/templates/tanstack-start/tsconfig.json +31 -0
- package/templates/tanstack-start/types/env.d.ts +16 -0
- package/templates/tanstack-start/vite.config.ts +33 -0
- package/templates/tanstack-start/wrangler.jsonc +7 -0
- package/templates/typescript/README.md +15 -0
- package/templates/typescript/_gitignore +37 -0
- package/templates/typescript/alchemy.run.ts +15 -0
- package/templates/typescript/index.ts +1 -0
- package/templates/typescript/package.json +18 -0
- package/templates/typescript/src/worker.js +5 -0
- package/templates/typescript/src/worker.ts +7 -0
- package/templates/typescript/tsconfig.json +21 -0
- package/templates/typescript/types/env.d.ts +16 -0
- package/templates/vite/README.md +54 -0
- package/templates/vite/_env.example +1 -0
- package/templates/vite/_gitignore +27 -0
- package/templates/vite/alchemy.run.ts +17 -0
- package/templates/vite/eslint.config.js +28 -0
- package/templates/vite/index.html +13 -0
- package/templates/vite/package.json +35 -0
- package/templates/vite/public/vite.svg +1 -0
- package/templates/vite/src/App.css +42 -0
- package/templates/vite/src/App.tsx +35 -0
- package/templates/vite/src/assets/react.svg +1 -0
- package/templates/vite/src/index.css +68 -0
- package/templates/vite/src/main.tsx +10 -0
- package/templates/vite/src/vite-env.d.ts +1 -0
- package/templates/vite/tsconfig.json +34 -0
- package/templates/vite/types/env.d.ts +16 -0
- package/templates/vite/vite.config.ts +9 -0
- package/templates/vite/worker/index.ts +12 -0
- package/templates/vite/wrangler.jsonc +6 -0
- package/bin/create-alchemy.ts +0 -1220
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { MAX_SESSION_DURATION } from "rwsdk/auth";
|
|
2
|
+
import { DurableObject } from "cloudflare:workers";
|
|
3
|
+
|
|
4
|
+
export interface Session {
|
|
5
|
+
userId?: string | null;
|
|
6
|
+
challenge?: string | null;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class SessionDurableObject extends DurableObject {
|
|
11
|
+
private session: Session | undefined = undefined;
|
|
12
|
+
constructor(state: DurableObjectState, env: Env) {
|
|
13
|
+
super(state, env);
|
|
14
|
+
this.session = undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async saveSession({
|
|
18
|
+
userId = null,
|
|
19
|
+
challenge = null,
|
|
20
|
+
}: {
|
|
21
|
+
userId?: string | null;
|
|
22
|
+
challenge?: string | null;
|
|
23
|
+
}): Promise<Session> {
|
|
24
|
+
const session: Session = {
|
|
25
|
+
userId,
|
|
26
|
+
challenge,
|
|
27
|
+
createdAt: Date.now(),
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
await this.ctx.storage.put<Session>("session", session);
|
|
31
|
+
this.session = session;
|
|
32
|
+
return session;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async getSession(): Promise<{ value: Session } | { error: string }> {
|
|
36
|
+
if (this.session) {
|
|
37
|
+
return { value: this.session };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const session = await this.ctx.storage.get<Session>("session");
|
|
41
|
+
|
|
42
|
+
if (!session) {
|
|
43
|
+
return {
|
|
44
|
+
error: "Invalid session",
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (session.createdAt + MAX_SESSION_DURATION < Date.now()) {
|
|
49
|
+
await this.revokeSession();
|
|
50
|
+
return {
|
|
51
|
+
error: "Session expired",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this.session = session;
|
|
56
|
+
return { value: session };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async revokeSession() {
|
|
60
|
+
await this.ctx.storage.delete("session");
|
|
61
|
+
this.session = undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineDurableSession } from "rwsdk/auth";
|
|
2
|
+
|
|
3
|
+
export let sessions: ReturnType<typeof createSessionStore>;
|
|
4
|
+
|
|
5
|
+
const createSessionStore = (env: Env) =>
|
|
6
|
+
defineDurableSession({
|
|
7
|
+
sessionDurableObject: env.SESSION_DURABLE_OBJECT,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const setupSessionStore = (env: Env) => {
|
|
11
|
+
sessions = createSessionStore(env);
|
|
12
|
+
return sessions;
|
|
13
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { defineApp, ErrorResponse } from "rwsdk/worker";
|
|
2
|
+
import { route, render, prefix } from "rwsdk/router";
|
|
3
|
+
import { Document } from "@/app/Document";
|
|
4
|
+
import { Home } from "@/app/pages/Home";
|
|
5
|
+
import { setCommonHeaders } from "@/app/headers";
|
|
6
|
+
import { userRoutes } from "@/app/pages/user/routes";
|
|
7
|
+
import { sessions, setupSessionStore } from "./session/store";
|
|
8
|
+
import { Session } from "./session/durableObject";
|
|
9
|
+
import { type User, db, setupDb } from "@/db";
|
|
10
|
+
import { env } from "cloudflare:workers";
|
|
11
|
+
export { SessionDurableObject } from "./session/durableObject";
|
|
12
|
+
|
|
13
|
+
export type AppContext = {
|
|
14
|
+
session: Session | null;
|
|
15
|
+
user: User | null;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default defineApp([
|
|
19
|
+
setCommonHeaders(),
|
|
20
|
+
async ({ ctx, request, headers }) => {
|
|
21
|
+
await setupDb(env);
|
|
22
|
+
setupSessionStore(env);
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
ctx.session = await sessions.load(request);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if (error instanceof ErrorResponse && error.code === 401) {
|
|
28
|
+
await sessions.remove(request, headers);
|
|
29
|
+
headers.set("Location", "/user/login");
|
|
30
|
+
|
|
31
|
+
return new Response(null, {
|
|
32
|
+
status: 302,
|
|
33
|
+
headers,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (ctx.session?.userId) {
|
|
41
|
+
ctx.user = await db.user.findUnique({
|
|
42
|
+
where: {
|
|
43
|
+
id: ctx.session.userId,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
render(Document, [
|
|
49
|
+
route("/", () => new Response("Hello, World!")),
|
|
50
|
+
route("/protected", [
|
|
51
|
+
({ ctx }) => {
|
|
52
|
+
if (!ctx.user) {
|
|
53
|
+
return new Response(null, {
|
|
54
|
+
status: 302,
|
|
55
|
+
headers: { Location: "/user/login" },
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
Home,
|
|
60
|
+
]),
|
|
61
|
+
prefix("/user", userRoutes),
|
|
62
|
+
]),
|
|
63
|
+
]);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
6
|
+
"target": "es2021",
|
|
7
|
+
/* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
8
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext", "ES2022"],
|
|
9
|
+
/* Specify what JSX code is generated. */
|
|
10
|
+
"jsx": "react-jsx",
|
|
11
|
+
|
|
12
|
+
/* Specify what module code is generated. */
|
|
13
|
+
"module": "es2022",
|
|
14
|
+
/* Specify how TypeScript looks up a file from a given module specifier. */
|
|
15
|
+
"moduleResolution": "bundler",
|
|
16
|
+
/* Specify type package names to be included without being referenced in a source file. */
|
|
17
|
+
"types": [
|
|
18
|
+
"@cloudflare/workers-types",
|
|
19
|
+
"types/**/*.ts"
|
|
20
|
+
],
|
|
21
|
+
"paths": {
|
|
22
|
+
"@/*": ["./src/*"],
|
|
23
|
+
"@generated/*": ["./generated/*"]
|
|
24
|
+
},
|
|
25
|
+
/* Enable importing .json files */
|
|
26
|
+
"resolveJsonModule": true,
|
|
27
|
+
|
|
28
|
+
/* Enable error reporting in type-checked JavaScript files. */
|
|
29
|
+
"checkJs": false,
|
|
30
|
+
|
|
31
|
+
/* Disable emitting files from a compilation. */
|
|
32
|
+
"noEmit": true,
|
|
33
|
+
|
|
34
|
+
/* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
35
|
+
"isolatedModules": true,
|
|
36
|
+
/* Allow 'import x from y' when a module doesn't have a default export. */
|
|
37
|
+
"allowSyntheticDefaultImports": true,
|
|
38
|
+
/* Ensure that casing is correct in imports. */
|
|
39
|
+
"forceConsistentCasingInFileNames": true,
|
|
40
|
+
|
|
41
|
+
/* Enable all strict type-checking options. */
|
|
42
|
+
"strict": true,
|
|
43
|
+
|
|
44
|
+
/* Skip type checking all .d.ts files. */
|
|
45
|
+
"skipLibCheck": true
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// This file infers types for the cloudflare:workers environment from your Alchemy Worker.
|
|
2
|
+
// @see https://alchemy.run/docs/concepts/bindings.html#type-safe-bindings
|
|
3
|
+
|
|
4
|
+
import type { worker } from "../alchemy.run.ts";
|
|
5
|
+
|
|
6
|
+
export type CloudflareEnv = typeof worker.Env;
|
|
7
|
+
|
|
8
|
+
declare global {
|
|
9
|
+
type Env = CloudflareEnv;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare module "cloudflare:workers" {
|
|
13
|
+
namespace Cloudflare {
|
|
14
|
+
export interface Env extends CloudflareEnv {}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-alchemy-app-website",
|
|
3
|
+
"main": "src/worker.tsx",
|
|
4
|
+
"compatibility_date": "2025-04-02",
|
|
5
|
+
"compatibility_flags": ["nodejs_compat"],
|
|
6
|
+
"assets": { "binding": "ASSETS", "directory": "dist/client" },
|
|
7
|
+
"durable_objects": {
|
|
8
|
+
"bindings": [
|
|
9
|
+
{ "name": "SESSION_DURABLE_OBJECT", "class_name": "SessionDurableObject" }
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"d1_databases": [
|
|
13
|
+
{
|
|
14
|
+
"binding": "DB",
|
|
15
|
+
"database_id": "33c4fe7d-fbfe-4cef-959c-bb54292af712",
|
|
16
|
+
"database_name": "my-alchemy-app-db",
|
|
17
|
+
"migrations_dir": "migrations",
|
|
18
|
+
"preview_database_id": "33c4fe7d-fbfe-4cef-959c-bb54292af712"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"migrations": [
|
|
22
|
+
{
|
|
23
|
+
"tag": "v1",
|
|
24
|
+
"new_sqlite_classes": [],
|
|
25
|
+
"new_classes": ["SessionDurableObject"]
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# sv
|
|
2
|
+
|
|
3
|
+
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
|
|
4
|
+
|
|
5
|
+
## Creating a project
|
|
6
|
+
|
|
7
|
+
If you're seeing this, you've probably already done this step. Congrats!
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# create a new project in the current directory
|
|
11
|
+
npx sv create
|
|
12
|
+
|
|
13
|
+
# create a new project in my-app
|
|
14
|
+
npx sv create my-app
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Developing
|
|
18
|
+
|
|
19
|
+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm run dev
|
|
23
|
+
|
|
24
|
+
# or start the server and open the app in a new browser tab
|
|
25
|
+
npm run dev -- --open
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Building
|
|
29
|
+
|
|
30
|
+
To create a production version of your app:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm run build
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
You can preview the production build with `npm run preview`.
|
|
37
|
+
|
|
38
|
+
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALCHEMY_PASSWORD=change-me
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALCHEMY_PASSWORD=change-me
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
node_modules
|
|
2
|
+
|
|
3
|
+
# Output
|
|
4
|
+
.output
|
|
5
|
+
.vercel
|
|
6
|
+
.netlify
|
|
7
|
+
.wrangler
|
|
8
|
+
/.svelte-kit
|
|
9
|
+
/build
|
|
10
|
+
|
|
11
|
+
# OS
|
|
12
|
+
.DS_Store
|
|
13
|
+
Thumbs.db
|
|
14
|
+
|
|
15
|
+
# Env
|
|
16
|
+
.env
|
|
17
|
+
.env.*
|
|
18
|
+
!.env.example
|
|
19
|
+
!.env.test
|
|
20
|
+
|
|
21
|
+
# Vite
|
|
22
|
+
vite.config.js.timestamp-*
|
|
23
|
+
vite.config.ts.timestamp-*
|
|
24
|
+
|
|
25
|
+
.alchemy/
|
|
26
|
+
.env
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
engine-strict=true
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="@types/node" />
|
|
2
|
+
|
|
3
|
+
import alchemy from "alchemy";
|
|
4
|
+
import { SvelteKit } from "alchemy/cloudflare";
|
|
5
|
+
|
|
6
|
+
const app = await alchemy("my-alchemy-app");
|
|
7
|
+
|
|
8
|
+
export const worker = await SvelteKit("website", {
|
|
9
|
+
command: "bun run build",
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
console.log({
|
|
13
|
+
url: worker.url,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
await app.finalize();
|