@better-t-stack/template-generator 3.27.5 → 3.28.1-pr1036.ff20c00
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/dist/core/template-reader.mjs +1 -1
- package/dist/fs-writer.mjs +1 -1
- package/dist/fs-writer.mjs.map +1 -1
- package/dist/index.d.mts +6 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +743 -139
- package/dist/index.mjs.map +1 -1
- package/dist/is-binary-path-maAgJE_Q.mjs.map +1 -1
- package/dist/{template-reader-C8MBRmk-.mjs → template-reader-DVuwwW6S.mjs} +7 -1
- package/dist/{template-reader-C8MBRmk-.mjs.map → template-reader-DVuwwW6S.mjs.map} +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -694,8 +694,8 @@ function renameDevScriptsForAlchemy(vfs, config) {
|
|
|
694
694
|
//#region src/utils/add-deps.ts
|
|
695
695
|
const dependencyVersionMap = {
|
|
696
696
|
typescript: "^6",
|
|
697
|
-
"better-auth": "1.
|
|
698
|
-
"@better-auth/expo": "1.
|
|
697
|
+
"better-auth": "1.6.9",
|
|
698
|
+
"@better-auth/expo": "1.6.9",
|
|
699
699
|
"@clerk/backend": "^3.2.1",
|
|
700
700
|
"@clerk/express": "^2.0.5",
|
|
701
701
|
"@clerk/fastify": "^3.1.3",
|
|
@@ -770,13 +770,14 @@ const dependencyVersionMap = {
|
|
|
770
770
|
"@trpc/server": "^11.16.0",
|
|
771
771
|
"@trpc/client": "^11.16.0",
|
|
772
772
|
next: "^16.2.0",
|
|
773
|
+
nitro: "^3.0.260429-beta",
|
|
773
774
|
convex: "^1.33.1",
|
|
774
775
|
"@convex-dev/react-query": "^0.1.0",
|
|
775
776
|
"@convex-dev/agent": "^0.3.2",
|
|
776
777
|
"convex-svelte": "^0.0.12",
|
|
777
778
|
"convex-nuxt": "0.1.5",
|
|
778
779
|
"convex-vue": "^0.1.5",
|
|
779
|
-
"@convex-dev/better-auth": "^0.
|
|
780
|
+
"@convex-dev/better-auth": "^0.12.1",
|
|
780
781
|
"@tanstack/svelte-query": "^5.85.3",
|
|
781
782
|
"@tanstack/svelte-query-devtools": "^5.85.3",
|
|
782
783
|
"@tanstack/vue-query-devtools": "^6.1.5",
|
|
@@ -806,7 +807,8 @@ const dependencyVersionMap = {
|
|
|
806
807
|
"@t3-oss/env-nextjs": "^0.13.1",
|
|
807
808
|
"@t3-oss/env-nuxt": "^0.13.1",
|
|
808
809
|
"@polar-sh/better-auth": "^1.8.3",
|
|
809
|
-
"@polar-sh/sdk": "^0.42.2"
|
|
810
|
+
"@polar-sh/sdk": "^0.42.2",
|
|
811
|
+
evlog: "^2.14.1"
|
|
810
812
|
};
|
|
811
813
|
/**
|
|
812
814
|
* Add dependencies to a package.json file in the VFS
|
|
@@ -838,6 +840,13 @@ function processAddonsDeps(vfs, config) {
|
|
|
838
840
|
const hasViteReactFrontend = config.frontend.includes("react-router") || config.frontend.includes("tanstack-router");
|
|
839
841
|
const hasSolidFrontend = config.frontend.includes("solid");
|
|
840
842
|
const hasPwaCompatibleFrontend = hasViteReactFrontend || hasSolidFrontend;
|
|
843
|
+
const hasEvlogWebServer = config.frontend.some((frontend) => [
|
|
844
|
+
"next",
|
|
845
|
+
"nuxt",
|
|
846
|
+
"svelte",
|
|
847
|
+
"tanstack-start",
|
|
848
|
+
"astro"
|
|
849
|
+
].includes(frontend));
|
|
841
850
|
if (config.addons.includes("turborepo")) addPackageDependency({
|
|
842
851
|
vfs,
|
|
843
852
|
packagePath: "package.json",
|
|
@@ -848,6 +857,20 @@ function processAddonsDeps(vfs, config) {
|
|
|
848
857
|
packagePath: "package.json",
|
|
849
858
|
devDependencies: ["nx"]
|
|
850
859
|
});
|
|
860
|
+
if (config.addons.includes("evlog")) {
|
|
861
|
+
const serverPkgPath = "apps/server/package.json";
|
|
862
|
+
if (vfs.exists(serverPkgPath) && config.backend !== "self" && config.backend !== "none") addPackageDependency({
|
|
863
|
+
vfs,
|
|
864
|
+
packagePath: serverPkgPath,
|
|
865
|
+
dependencies: ["evlog"]
|
|
866
|
+
});
|
|
867
|
+
const webPkgPath = "apps/web/package.json";
|
|
868
|
+
if (vfs.exists(webPkgPath) && hasEvlogWebServer) addPackageDependency({
|
|
869
|
+
vfs,
|
|
870
|
+
packagePath: webPkgPath,
|
|
871
|
+
dependencies: config.frontend.includes("tanstack-start") ? ["evlog", "nitro"] : ["evlog"]
|
|
872
|
+
});
|
|
873
|
+
}
|
|
851
874
|
if (config.addons.includes("pwa") && hasPwaCompatibleFrontend) {
|
|
852
875
|
const webPkgPath = "apps/web/package.json";
|
|
853
876
|
if (vfs.exists(webPkgPath)) {
|
|
@@ -935,6 +958,49 @@ function processNuxtAlchemy(vfs) {
|
|
|
935
958
|
moduleSpecifier: "alchemy/cloudflare/nuxt",
|
|
936
959
|
defaultImport: "alchemy"
|
|
937
960
|
});
|
|
961
|
+
if (!sourceFile.getImportDeclarations().some((decl) => decl.getModuleSpecifierValue() === "node:fs")) sourceFile.addImportDeclaration({
|
|
962
|
+
moduleSpecifier: "node:fs",
|
|
963
|
+
namedImports: ["existsSync"]
|
|
964
|
+
});
|
|
965
|
+
if (!sourceFile.getImportDeclarations().some((decl) => decl.getModuleSpecifierValue() === "node:url")) sourceFile.addImportDeclaration({
|
|
966
|
+
moduleSpecifier: "node:url",
|
|
967
|
+
namedImports: ["fileURLToPath"]
|
|
968
|
+
});
|
|
969
|
+
if (!sourceFile.getVariableDeclaration("alchemyConfigPath")) {
|
|
970
|
+
const firstExport = sourceFile.getStatements().findIndex((statement) => Node.isExportAssignment(statement));
|
|
971
|
+
sourceFile.insertStatements(firstExport === -1 ? sourceFile.getStatements().length : firstExport, `const alchemyConfigPath = fileURLToPath(new URL("./.alchemy/local/wrangler.jsonc", import.meta.url));
|
|
972
|
+
const hasAlchemyConfig = existsSync(alchemyConfigPath);`);
|
|
973
|
+
}
|
|
974
|
+
if (!sourceFile.getVariableDeclaration("cloudflareWorkersShimPath")) {
|
|
975
|
+
const firstExport = sourceFile.getStatements().findIndex((statement) => Node.isExportAssignment(statement));
|
|
976
|
+
sourceFile.insertStatements(firstExport === -1 ? sourceFile.getStatements().length : firstExport, `const cloudflareWorkersShimPath = fileURLToPath(new URL("../../packages/env/src/cloudflare-local.ts", import.meta.url));`);
|
|
977
|
+
}
|
|
978
|
+
if (!sourceFile.getVariableDeclaration("isNuxtPrepare")) {
|
|
979
|
+
const firstExport = sourceFile.getStatements().findIndex((statement) => Node.isExportAssignment(statement));
|
|
980
|
+
sourceFile.insertStatements(firstExport === -1 ? sourceFile.getStatements().length : firstExport, `const isNuxtPrepare =
|
|
981
|
+
process.env.npm_lifecycle_event === "postinstall" ||
|
|
982
|
+
process.env.npm_lifecycle_script === "nuxt prepare" ||
|
|
983
|
+
process.argv.includes("prepare");`);
|
|
984
|
+
}
|
|
985
|
+
if (!sourceFile.getVariableDeclaration("shouldUseAlchemy")) {
|
|
986
|
+
const firstExport = sourceFile.getStatements().findIndex((statement) => Node.isExportAssignment(statement));
|
|
987
|
+
sourceFile.insertStatements(firstExport === -1 ? sourceFile.getStatements().length : firstExport, `const shouldUseAlchemy = !isNuxtPrepare && hasAlchemyConfig;`);
|
|
988
|
+
}
|
|
989
|
+
if (!sourceFile.getVariableDeclaration("cloudflareWorkersAlias")) {
|
|
990
|
+
const firstExport = sourceFile.getStatements().findIndex((statement) => Node.isExportAssignment(statement));
|
|
991
|
+
sourceFile.insertStatements(firstExport === -1 ? sourceFile.getStatements().length : firstExport, `const cloudflareWorkersAlias = shouldUseAlchemy
|
|
992
|
+
? {}
|
|
993
|
+
: {
|
|
994
|
+
"cloudflare:workers": cloudflareWorkersShimPath,
|
|
995
|
+
};`);
|
|
996
|
+
}
|
|
997
|
+
if (!sourceFile.getVariableDeclaration("isNuxtDev")) {
|
|
998
|
+
const firstExport = sourceFile.getStatements().findIndex((statement) => Node.isExportAssignment(statement));
|
|
999
|
+
sourceFile.insertStatements(firstExport === -1 ? sourceFile.getStatements().length : firstExport, `const isNuxtDev =
|
|
1000
|
+
!isNuxtPrepare &&
|
|
1001
|
+
process.env.NODE_ENV !== "production" &&
|
|
1002
|
+
!process.argv.some((arg) => arg === "build" || arg === "generate");`);
|
|
1003
|
+
}
|
|
938
1004
|
const exportAssignment = sourceFile.getExportAssignment((d) => !d.isExportEquals());
|
|
939
1005
|
if (!exportAssignment) return;
|
|
940
1006
|
const defineConfigCall = exportAssignment.getExpression();
|
|
@@ -946,11 +1012,20 @@ function processNuxtAlchemy(vfs) {
|
|
|
946
1012
|
name: "nitro",
|
|
947
1013
|
initializer: `{
|
|
948
1014
|
preset: "cloudflare-module",
|
|
949
|
-
cloudflare: alchemy(),
|
|
1015
|
+
...(shouldUseAlchemy ? { cloudflare: alchemy({ dev: { configPath: alchemyConfigPath } }) } : {}),
|
|
1016
|
+
alias: cloudflareWorkersAlias,
|
|
950
1017
|
prerender: {
|
|
951
1018
|
routes: ["/"],
|
|
952
1019
|
autoSubfolderIndex: false,
|
|
953
1020
|
},
|
|
1021
|
+
}`
|
|
1022
|
+
});
|
|
1023
|
+
if (!configObject.getProperty("vite")) configObject.addPropertyAssignment({
|
|
1024
|
+
name: "vite",
|
|
1025
|
+
initializer: `{
|
|
1026
|
+
resolve: {
|
|
1027
|
+
alias: cloudflareWorkersAlias,
|
|
1028
|
+
},
|
|
954
1029
|
}`
|
|
955
1030
|
});
|
|
956
1031
|
const modulesProperty = configObject.getProperty("modules");
|
|
@@ -977,15 +1052,27 @@ function processSvelteAlchemy(vfs) {
|
|
|
977
1052
|
quoteKind: QuoteKind.Single
|
|
978
1053
|
}
|
|
979
1054
|
}).createSourceFile("svelte.config.js", content);
|
|
980
|
-
|
|
981
|
-
if (adapterImport) {
|
|
982
|
-
adapterImport.setModuleSpecifier("alchemy/cloudflare/sveltekit");
|
|
983
|
-
adapterImport.removeDefaultImport();
|
|
984
|
-
adapterImport.setDefaultImport("alchemy");
|
|
985
|
-
} else sourceFile.insertImportDeclaration(0, {
|
|
1055
|
+
if (!sourceFile.getImportDeclarations().some((imp) => imp.getModuleSpecifierValue() === "alchemy/cloudflare/sveltekit")) sourceFile.insertImportDeclaration(0, {
|
|
986
1056
|
moduleSpecifier: "alchemy/cloudflare/sveltekit",
|
|
987
1057
|
defaultImport: "alchemy"
|
|
988
1058
|
});
|
|
1059
|
+
if (!sourceFile.getImportDeclarations().some((imp) => imp.getModuleSpecifierValue() === "@sveltejs/adapter-auto")) sourceFile.insertImportDeclaration(0, {
|
|
1060
|
+
moduleSpecifier: "@sveltejs/adapter-auto",
|
|
1061
|
+
defaultImport: "adapter"
|
|
1062
|
+
});
|
|
1063
|
+
if (!sourceFile.getImportDeclarations().some((decl) => decl.getModuleSpecifierValue() === "node:fs")) sourceFile.insertImportDeclaration(0, {
|
|
1064
|
+
moduleSpecifier: "node:fs",
|
|
1065
|
+
namedImports: ["existsSync"]
|
|
1066
|
+
});
|
|
1067
|
+
if (!sourceFile.getImportDeclarations().some((decl) => decl.getModuleSpecifierValue() === "node:url")) sourceFile.insertImportDeclaration(0, {
|
|
1068
|
+
moduleSpecifier: "node:url",
|
|
1069
|
+
namedImports: ["fileURLToPath"]
|
|
1070
|
+
});
|
|
1071
|
+
if (!sourceFile.getVariableDeclaration("alchemyConfigPath")) {
|
|
1072
|
+
const configVariableIndex = sourceFile.getStatements().findIndex((statement) => Node.isVariableStatement(statement) && statement.getDeclarationList().getDeclarations().some((decl) => decl.getName() === "config"));
|
|
1073
|
+
sourceFile.insertStatements(configVariableIndex === -1 ? sourceFile.getStatements().length : configVariableIndex, `const alchemyConfigPath = fileURLToPath(new URL("./.alchemy/local/wrangler.jsonc", import.meta.url));
|
|
1074
|
+
const shouldUseAlchemy = existsSync(alchemyConfigPath);`);
|
|
1075
|
+
}
|
|
989
1076
|
const configVariable = sourceFile.getVariableDeclaration("config");
|
|
990
1077
|
if (configVariable) {
|
|
991
1078
|
const initializer = configVariable.getInitializer();
|
|
@@ -995,13 +1082,7 @@ function processSvelteAlchemy(vfs) {
|
|
|
995
1082
|
const kitInitializer = kitProperty.getInitializer();
|
|
996
1083
|
if (Node.isObjectLiteralExpression(kitInitializer)) {
|
|
997
1084
|
const adapterProperty = kitInitializer.getProperty("adapter");
|
|
998
|
-
if (adapterProperty && Node.isPropertyAssignment(adapterProperty)) {
|
|
999
|
-
const adapterInitializer = adapterProperty.getInitializer();
|
|
1000
|
-
if (Node.isCallExpression(adapterInitializer)) {
|
|
1001
|
-
const expression = adapterInitializer.getExpression();
|
|
1002
|
-
if (Node.isIdentifier(expression) && expression.getText() === "adapter") expression.replaceWithText("alchemy");
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1085
|
+
if (adapterProperty && Node.isPropertyAssignment(adapterProperty)) adapterProperty.setInitializer("shouldUseAlchemy ? alchemy({ platformProxy: { configPath: alchemyConfigPath } }) : adapter()");
|
|
1005
1086
|
}
|
|
1006
1087
|
}
|
|
1007
1088
|
}
|
|
@@ -1023,6 +1104,31 @@ function processTanStackStartAlchemy(vfs) {
|
|
|
1023
1104
|
moduleSpecifier: "alchemy/cloudflare/tanstack-start",
|
|
1024
1105
|
defaultImport: "alchemy"
|
|
1025
1106
|
});
|
|
1107
|
+
if (!sourceFile.getImportDeclarations().some((decl) => decl.getModuleSpecifierValue() === "node:fs")) sourceFile.addImportDeclaration({
|
|
1108
|
+
moduleSpecifier: "node:fs",
|
|
1109
|
+
namedImports: ["existsSync"]
|
|
1110
|
+
});
|
|
1111
|
+
if (!sourceFile.getImportDeclarations().some((decl) => decl.getModuleSpecifierValue() === "node:url")) sourceFile.addImportDeclaration({
|
|
1112
|
+
moduleSpecifier: "node:url",
|
|
1113
|
+
namedImports: ["fileURLToPath"]
|
|
1114
|
+
});
|
|
1115
|
+
if (!sourceFile.getVariableDeclaration("alchemyConfigPath")) {
|
|
1116
|
+
const firstExport = sourceFile.getStatements().findIndex((statement) => Node.isExportAssignment(statement));
|
|
1117
|
+
sourceFile.insertStatements(firstExport === -1 ? sourceFile.getStatements().length : firstExport, `const alchemyConfigPath = fileURLToPath(new URL("./.alchemy/local/wrangler.jsonc", import.meta.url));
|
|
1118
|
+
const shouldUseAlchemy = existsSync(alchemyConfigPath);`);
|
|
1119
|
+
}
|
|
1120
|
+
if (!sourceFile.getVariableDeclaration("cloudflareWorkersShimPath")) {
|
|
1121
|
+
const firstExport = sourceFile.getStatements().findIndex((statement) => Node.isExportAssignment(statement));
|
|
1122
|
+
sourceFile.insertStatements(firstExport === -1 ? sourceFile.getStatements().length : firstExport, `const cloudflareWorkersShimPath = fileURLToPath(new URL("../../packages/env/src/cloudflare-local.ts", import.meta.url));`);
|
|
1123
|
+
}
|
|
1124
|
+
if (!sourceFile.getVariableDeclaration("cloudflareWorkersAlias")) {
|
|
1125
|
+
const firstExport = sourceFile.getStatements().findIndex((statement) => Node.isExportAssignment(statement));
|
|
1126
|
+
sourceFile.insertStatements(firstExport === -1 ? sourceFile.getStatements().length : firstExport, `const cloudflareWorkersAlias = shouldUseAlchemy
|
|
1127
|
+
? {}
|
|
1128
|
+
: {
|
|
1129
|
+
"cloudflare:workers": cloudflareWorkersShimPath,
|
|
1130
|
+
};`);
|
|
1131
|
+
}
|
|
1026
1132
|
const exportAssignment = sourceFile.getExportAssignment((d) => !d.isExportEquals());
|
|
1027
1133
|
if (!exportAssignment) return;
|
|
1028
1134
|
const defineConfigCall = exportAssignment.getExpression();
|
|
@@ -1034,11 +1140,22 @@ function processTanStackStartAlchemy(vfs) {
|
|
|
1034
1140
|
if (pluginsProperty && Node.isPropertyAssignment(pluginsProperty)) {
|
|
1035
1141
|
const initializer = pluginsProperty.getInitializer();
|
|
1036
1142
|
if (Node.isArrayLiteralExpression(initializer)) {
|
|
1037
|
-
if (!initializer.getElements().some((el) => el.getText().includes("alchemy("))) initializer.addElement("alchemy()");
|
|
1143
|
+
if (!initializer.getElements().some((el) => el.getText().includes("alchemy("))) initializer.addElement("...(shouldUseAlchemy ? [alchemy({ configPath: alchemyConfigPath })] : [])");
|
|
1038
1144
|
}
|
|
1039
1145
|
} else configObject.addPropertyAssignment({
|
|
1040
1146
|
name: "plugins",
|
|
1041
|
-
initializer: "[alchemy()]"
|
|
1147
|
+
initializer: "[...(shouldUseAlchemy ? [alchemy({ configPath: alchemyConfigPath })] : [])]"
|
|
1148
|
+
});
|
|
1149
|
+
const resolveProperty = configObject.getProperty("resolve");
|
|
1150
|
+
if (resolveProperty && Node.isPropertyAssignment(resolveProperty)) {
|
|
1151
|
+
const initializer = resolveProperty.getInitializer();
|
|
1152
|
+
if (Node.isObjectLiteralExpression(initializer) && !initializer.getProperty("alias")) initializer.addPropertyAssignment({
|
|
1153
|
+
name: "alias",
|
|
1154
|
+
initializer: "cloudflareWorkersAlias"
|
|
1155
|
+
});
|
|
1156
|
+
} else if (!resolveProperty) configObject.addPropertyAssignment({
|
|
1157
|
+
name: "resolve",
|
|
1158
|
+
initializer: "{ alias: cloudflareWorkersAlias }"
|
|
1042
1159
|
});
|
|
1043
1160
|
}
|
|
1044
1161
|
vfs.writeFile(viteConfigPath, sourceFile.getFullText());
|
|
@@ -1054,15 +1171,39 @@ function processAstroAlchemy(vfs) {
|
|
|
1054
1171
|
quoteKind: QuoteKind.Double
|
|
1055
1172
|
}
|
|
1056
1173
|
}).createSourceFile("astro.config.mjs", content);
|
|
1057
|
-
|
|
1058
|
-
if (nodeAdapterImport) {
|
|
1059
|
-
nodeAdapterImport.setModuleSpecifier("alchemy/cloudflare/astro");
|
|
1060
|
-
nodeAdapterImport.removeDefaultImport();
|
|
1061
|
-
nodeAdapterImport.setDefaultImport("alchemy");
|
|
1062
|
-
} else sourceFile.insertImportDeclaration(0, {
|
|
1174
|
+
if (!sourceFile.getImportDeclarations().some((imp) => imp.getModuleSpecifierValue() === "alchemy/cloudflare/astro")) sourceFile.insertImportDeclaration(0, {
|
|
1063
1175
|
moduleSpecifier: "alchemy/cloudflare/astro",
|
|
1064
1176
|
defaultImport: "alchemy"
|
|
1065
1177
|
});
|
|
1178
|
+
if (!sourceFile.getImportDeclarations().some((imp) => imp.getModuleSpecifierValue() === "@astrojs/node")) sourceFile.insertImportDeclaration(0, {
|
|
1179
|
+
moduleSpecifier: "@astrojs/node",
|
|
1180
|
+
defaultImport: "node"
|
|
1181
|
+
});
|
|
1182
|
+
if (!sourceFile.getImportDeclarations().some((decl) => decl.getModuleSpecifierValue() === "node:fs")) sourceFile.insertImportDeclaration(0, {
|
|
1183
|
+
moduleSpecifier: "node:fs",
|
|
1184
|
+
namedImports: ["existsSync"]
|
|
1185
|
+
});
|
|
1186
|
+
if (!sourceFile.getImportDeclarations().some((decl) => decl.getModuleSpecifierValue() === "node:url")) sourceFile.insertImportDeclaration(0, {
|
|
1187
|
+
moduleSpecifier: "node:url",
|
|
1188
|
+
namedImports: ["fileURLToPath"]
|
|
1189
|
+
});
|
|
1190
|
+
if (!sourceFile.getVariableDeclaration("alchemyConfigPath")) {
|
|
1191
|
+
const firstExport = sourceFile.getStatements().findIndex((statement) => Node.isExportAssignment(statement));
|
|
1192
|
+
sourceFile.insertStatements(firstExport === -1 ? sourceFile.getStatements().length : firstExport, `const alchemyConfigPath = fileURLToPath(new URL("./.alchemy/local/wrangler.jsonc", import.meta.url));
|
|
1193
|
+
const shouldUseAlchemy = existsSync(alchemyConfigPath);`);
|
|
1194
|
+
}
|
|
1195
|
+
if (!sourceFile.getVariableDeclaration("cloudflareWorkersShimPath")) {
|
|
1196
|
+
const firstExport = sourceFile.getStatements().findIndex((statement) => Node.isExportAssignment(statement));
|
|
1197
|
+
sourceFile.insertStatements(firstExport === -1 ? sourceFile.getStatements().length : firstExport, `const cloudflareWorkersShimPath = fileURLToPath(new URL("../../packages/env/src/cloudflare-local.ts", import.meta.url));`);
|
|
1198
|
+
}
|
|
1199
|
+
if (!sourceFile.getVariableDeclaration("cloudflareWorkersAlias")) {
|
|
1200
|
+
const firstExport = sourceFile.getStatements().findIndex((statement) => Node.isExportAssignment(statement));
|
|
1201
|
+
sourceFile.insertStatements(firstExport === -1 ? sourceFile.getStatements().length : firstExport, `const cloudflareWorkersAlias = shouldUseAlchemy
|
|
1202
|
+
? {}
|
|
1203
|
+
: {
|
|
1204
|
+
"cloudflare:workers": cloudflareWorkersShimPath,
|
|
1205
|
+
};`);
|
|
1206
|
+
}
|
|
1066
1207
|
const exportAssignment = sourceFile.getExportAssignment((d) => !d.isExportEquals());
|
|
1067
1208
|
if (exportAssignment) {
|
|
1068
1209
|
const defineConfigCall = exportAssignment.getExpression();
|
|
@@ -1070,7 +1211,27 @@ function processAstroAlchemy(vfs) {
|
|
|
1070
1211
|
const configObject = defineConfigCall.getArguments()[0];
|
|
1071
1212
|
if (Node.isObjectLiteralExpression(configObject)) {
|
|
1072
1213
|
const adapterProperty = configObject.getProperty("adapter");
|
|
1073
|
-
if (adapterProperty && Node.isPropertyAssignment(adapterProperty)) adapterProperty.setInitializer("alchemy()");
|
|
1214
|
+
if (adapterProperty && Node.isPropertyAssignment(adapterProperty)) adapterProperty.setInitializer("shouldUseAlchemy ? alchemy({ platformProxy: { configPath: alchemyConfigPath } }) : node({ mode: \"standalone\" })");
|
|
1215
|
+
const viteProperty = configObject.getProperty("vite");
|
|
1216
|
+
if (viteProperty && Node.isPropertyAssignment(viteProperty)) {
|
|
1217
|
+
const viteInitializer = viteProperty.getInitializer();
|
|
1218
|
+
if (Node.isObjectLiteralExpression(viteInitializer)) {
|
|
1219
|
+
const resolveProperty = viteInitializer.getProperty("resolve");
|
|
1220
|
+
if (resolveProperty && Node.isPropertyAssignment(resolveProperty)) {
|
|
1221
|
+
const resolveInitializer = resolveProperty.getInitializer();
|
|
1222
|
+
if (Node.isObjectLiteralExpression(resolveInitializer) && !resolveInitializer.getProperty("alias")) resolveInitializer.addPropertyAssignment({
|
|
1223
|
+
name: "alias",
|
|
1224
|
+
initializer: "cloudflareWorkersAlias"
|
|
1225
|
+
});
|
|
1226
|
+
} else if (!resolveProperty) viteInitializer.addPropertyAssignment({
|
|
1227
|
+
name: "resolve",
|
|
1228
|
+
initializer: "{ alias: cloudflareWorkersAlias }"
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
} else if (!viteProperty) configObject.addPropertyAssignment({
|
|
1232
|
+
name: "vite",
|
|
1233
|
+
initializer: "{ resolve: { alias: cloudflareWorkersAlias } }"
|
|
1234
|
+
});
|
|
1074
1235
|
}
|
|
1075
1236
|
}
|
|
1076
1237
|
}
|
|
@@ -1327,7 +1488,7 @@ function addConvexDeps(vfs, frontend, frontendType) {
|
|
|
1327
1488
|
}
|
|
1328
1489
|
//#endregion
|
|
1329
1490
|
//#region src/processors/auth-deps.ts
|
|
1330
|
-
const CONVEX_BETTER_AUTH_VERSION = "1.
|
|
1491
|
+
const CONVEX_BETTER_AUTH_VERSION = "1.6.9";
|
|
1331
1492
|
function processAuthDeps(vfs, config) {
|
|
1332
1493
|
const { auth, backend } = config;
|
|
1333
1494
|
if (!auth || auth === "none") return;
|
|
@@ -1695,9 +1856,9 @@ function processDatabaseDeps(vfs, config) {
|
|
|
1695
1856
|
const dbPkgPath = "packages/db/package.json";
|
|
1696
1857
|
const webPkgPath = "apps/web/package.json";
|
|
1697
1858
|
if (!vfs.exists(dbPkgPath)) return;
|
|
1698
|
-
const
|
|
1699
|
-
if (orm === "prisma") processPrismaDeps(vfs, config, dbPkgPath, webPkgPath,
|
|
1700
|
-
else if (orm === "drizzle") processDrizzleDeps(vfs, config, dbPkgPath, webPkgPath,
|
|
1859
|
+
const webNeedsDbRuntime = backend === "self" && vfs.exists(webPkgPath);
|
|
1860
|
+
if (orm === "prisma") processPrismaDeps(vfs, config, dbPkgPath, webPkgPath, webNeedsDbRuntime);
|
|
1861
|
+
else if (orm === "drizzle") processDrizzleDeps(vfs, config, dbPkgPath, webPkgPath, webNeedsDbRuntime);
|
|
1701
1862
|
else if (orm === "mongoose") addPackageDependency({
|
|
1702
1863
|
vfs,
|
|
1703
1864
|
packagePath: dbPkgPath,
|
|
@@ -1849,6 +2010,7 @@ function processDeployDeps(vfs, config) {
|
|
|
1849
2010
|
else if (frontend.includes("astro")) addPackageDependency({
|
|
1850
2011
|
vfs,
|
|
1851
2012
|
packagePath: webPkgPath,
|
|
2013
|
+
dependencies: ["@astrojs/node"],
|
|
1852
2014
|
devDependencies: [
|
|
1853
2015
|
"alchemy",
|
|
1854
2016
|
"@astrojs/cloudflare",
|
|
@@ -2020,9 +2182,10 @@ function buildClientVars(frontend, backend, auth) {
|
|
|
2020
2182
|
}
|
|
2021
2183
|
function buildNativeVars(frontend, backend, auth) {
|
|
2022
2184
|
const hasAstro = frontend.includes("astro");
|
|
2185
|
+
const hasSvelte = frontend.includes("svelte");
|
|
2023
2186
|
let envVarName = "EXPO_PUBLIC_SERVER_URL";
|
|
2024
2187
|
let serverUrl = "http://localhost:3000";
|
|
2025
|
-
if (backend === "self") serverUrl = hasAstro ? "http://localhost:4321" : "http://localhost:3001";
|
|
2188
|
+
if (backend === "self") serverUrl = hasSvelte ? "http://localhost:5173" : hasAstro ? "http://localhost:4321" : "http://localhost:3001";
|
|
2026
2189
|
if (backend === "convex") {
|
|
2027
2190
|
envVarName = "EXPO_PUBLIC_CONVEX_URL";
|
|
2028
2191
|
serverUrl = "https://<YOUR_CONVEX_URL>";
|
|
@@ -2135,7 +2298,7 @@ function buildServerVars(backend, frontend, auth, api, database, dbSetup, runtim
|
|
|
2135
2298
|
},
|
|
2136
2299
|
{
|
|
2137
2300
|
key: "BETTER_AUTH_URL",
|
|
2138
|
-
value: backend === "self" ? hasAstro ? "http://localhost:4321" : "http://localhost:3001" : "http://localhost:3000",
|
|
2301
|
+
value: backend === "self" ? hasSvelte ? "http://localhost:5173" : hasAstro ? "http://localhost:4321" : "http://localhost:3001" : "http://localhost:3000",
|
|
2139
2302
|
condition: hasBetterAuth
|
|
2140
2303
|
},
|
|
2141
2304
|
{
|
|
@@ -2665,7 +2828,7 @@ ${packageManagerRunCmd} dev
|
|
|
2665
2828
|
${generateRunningInstructions(frontend, backend, webPort, hasNative, isConvex)}
|
|
2666
2829
|
${generateReactUiSection(hasReactWeb, projectName)}
|
|
2667
2830
|
${addons.includes("pwa") && hasReactRouter ? "\n## PWA Support with React Router v7\n\nThere is a known compatibility issue between VitePWA and React Router v7.\nSee: https://github.com/vite-pwa/vite-plugin-pwa/issues/809\n" : ""}
|
|
2668
|
-
${generateDeploymentCommands(packageManagerRunCmd, webDeploy, serverDeploy)}
|
|
2831
|
+
${generateDeploymentCommands(packageManagerRunCmd, webDeploy, serverDeploy, backend)}
|
|
2669
2832
|
${generateGitHooksSection(packageManagerRunCmd, addons)}
|
|
2670
2833
|
|
|
2671
2834
|
## Project Structure
|
|
@@ -2963,12 +3126,11 @@ function generateScriptsList(packageManagerRunCmd, config, hasNative) {
|
|
|
2963
3126
|
- \`cd apps/docs && ${packageManagerRunCmd} build\`: Build documentation site`;
|
|
2964
3127
|
return scripts;
|
|
2965
3128
|
}
|
|
2966
|
-
function generateDeploymentCommands(packageManagerRunCmd, webDeploy, serverDeploy) {
|
|
3129
|
+
function generateDeploymentCommands(packageManagerRunCmd, webDeploy, serverDeploy, backend) {
|
|
2967
3130
|
if (webDeploy !== "cloudflare" && serverDeploy !== "cloudflare") return "";
|
|
2968
3131
|
const lines = ["## Deployment (Cloudflare via Alchemy)"];
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
if (webDeploy === "cloudflare" && serverDeploy === "cloudflare") lines.push(`- Dev: ${packageManagerRunCmd} dev`, `- Deploy: ${packageManagerRunCmd} deploy`, `- Destroy: ${packageManagerRunCmd} destroy`);
|
|
3132
|
+
const targetLabel = webDeploy === "cloudflare" && (serverDeploy === "cloudflare" || backend === "self") ? "web + server" : webDeploy === "cloudflare" ? "web" : "server";
|
|
3133
|
+
lines.push(`- Target: ${targetLabel}`, `- Dev: ${packageManagerRunCmd} dev`, `- Deploy: ${packageManagerRunCmd} deploy`, `- Destroy: ${packageManagerRunCmd} destroy`);
|
|
2972
3134
|
lines.push("", "For more details, see the guide on [Deploying to Cloudflare with Alchemy](https://www.better-t-stack.dev/docs/guides/cloudflare-alchemy).");
|
|
2973
3135
|
return `${lines.join("\n")}\n`;
|
|
2974
3136
|
}
|
|
@@ -3223,7 +3385,7 @@ function processWorkspaceDeps(vfs, config) {
|
|
|
3223
3385
|
...uiDep
|
|
3224
3386
|
};
|
|
3225
3387
|
if (api !== "none" && packages.api) webPackageDeps[`@${projectName}/api`] = workspaceVersion;
|
|
3226
|
-
if (auth !== "none" && packages.auth) webPackageDeps[`@${projectName}/auth`] = workspaceVersion;
|
|
3388
|
+
if (backend === "self" && auth !== "none" && packages.auth) webPackageDeps[`@${projectName}/auth`] = workspaceVersion;
|
|
3227
3389
|
if (backend === "convex" && packages.backend) webPackageDeps[`@${projectName}/backend`] = workspaceVersion;
|
|
3228
3390
|
addPackageDependency({
|
|
3229
3391
|
vfs,
|
|
@@ -3409,8 +3571,13 @@ async function processApiTemplates(vfs, templates, config) {
|
|
|
3409
3571
|
processTemplatesFromPrefix(vfs, templates, `api/${config.api}/fullstack/nuxt`, "apps/web", config);
|
|
3410
3572
|
processSingleTemplate(vfs, templates, `api/${config.api}/web/nuxt/app/plugins/vue-query.ts`, "apps/web/app/plugins/vue-query.ts", config);
|
|
3411
3573
|
} else processTemplatesFromPrefix(vfs, templates, `api/${config.api}/web/nuxt`, "apps/web", config);
|
|
3412
|
-
else if (hasSvelteWeb && config.api === "orpc")
|
|
3413
|
-
|
|
3574
|
+
else if (hasSvelteWeb && config.api === "orpc") {
|
|
3575
|
+
processTemplatesFromPrefix(vfs, templates, `api/${config.api}/web/svelte`, "apps/web", config);
|
|
3576
|
+
if (config.backend === "self") {
|
|
3577
|
+
processTemplatesFromPrefix(vfs, templates, `api/${config.api}/fullstack/svelte`, "apps/web", config);
|
|
3578
|
+
if (config.auth !== "better-auth") vfs.writeFile("apps/web/src/hooks.server.ts", "import \"./lib/orpc.server\";\n");
|
|
3579
|
+
}
|
|
3580
|
+
} else if (hasSolidWeb && config.api === "orpc") processTemplatesFromPrefix(vfs, templates, `api/${config.api}/web/solid`, "apps/web", config);
|
|
3414
3581
|
else if (hasAstroWeb && config.api === "orpc") {
|
|
3415
3582
|
processTemplatesFromPrefix(vfs, templates, `api/${config.api}/web/astro`, "apps/web", config);
|
|
3416
3583
|
if (config.backend === "self") processTemplatesFromPrefix(vfs, templates, `api/${config.api}/fullstack/astro`, "apps/web", config);
|
|
@@ -3442,7 +3609,10 @@ async function processEnvPackage(vfs, templates, config) {
|
|
|
3442
3609
|
processSingleTemplate(vfs, templates, "packages/env/tsconfig.json", "packages/env/tsconfig.json", config);
|
|
3443
3610
|
if (hasWebFrontend) processSingleTemplate(vfs, templates, "packages/env/src/web.ts", "packages/env/src/web.ts", config);
|
|
3444
3611
|
if (hasNative) processSingleTemplate(vfs, templates, "packages/env/src/native.ts", "packages/env/src/native.ts", config);
|
|
3445
|
-
if (config.backend !== "none" && config.backend !== "convex")
|
|
3612
|
+
if (config.backend !== "none" && config.backend !== "convex") {
|
|
3613
|
+
processSingleTemplate(vfs, templates, "packages/env/src/server.ts", "packages/env/src/server.ts", config);
|
|
3614
|
+
if (config.serverDeploy === "cloudflare" || config.backend === "self" && config.webDeploy === "cloudflare") processSingleTemplate(vfs, templates, "packages/env/src/cloudflare-local.ts", "packages/env/src/cloudflare-local.ts", config);
|
|
3615
|
+
}
|
|
3446
3616
|
}
|
|
3447
3617
|
async function processUiPackage(vfs, templates, config) {
|
|
3448
3618
|
if (!config.frontend.some((f) => [
|
|
@@ -3534,8 +3704,10 @@ async function processAuthTemplates(vfs, templates, config) {
|
|
|
3534
3704
|
} else if (hasNuxtWeb) {
|
|
3535
3705
|
if (config.backend === "self") processTemplatesFromPrefix(vfs, templates, `auth/${authProvider}/fullstack/nuxt`, "apps/web", config);
|
|
3536
3706
|
processTemplatesFromPrefix(vfs, templates, `auth/${authProvider}/web/nuxt`, "apps/web", config);
|
|
3537
|
-
} else if (hasSvelteWeb)
|
|
3538
|
-
|
|
3707
|
+
} else if (hasSvelteWeb) {
|
|
3708
|
+
if (config.backend === "self" && authProvider === "better-auth") processTemplatesFromPrefix(vfs, templates, `auth/${authProvider}/fullstack/svelte`, "apps/web", config);
|
|
3709
|
+
processTemplatesFromPrefix(vfs, templates, `auth/${authProvider}/web/svelte`, "apps/web", config);
|
|
3710
|
+
} else if (hasSolidWeb) processTemplatesFromPrefix(vfs, templates, `auth/${authProvider}/web/solid`, "apps/web", config);
|
|
3539
3711
|
else if (hasAstroWeb) {
|
|
3540
3712
|
if (config.backend === "self" && authProvider === "better-auth") processTemplatesFromPrefix(vfs, templates, `auth/${authProvider}/fullstack/astro`, "apps/web", config);
|
|
3541
3713
|
processTemplatesFromPrefix(vfs, templates, `auth/${authProvider}/web/astro`, "apps/web", config);
|
|
@@ -3634,8 +3806,10 @@ async function processExampleTemplates(vfs, templates, config) {
|
|
|
3634
3806
|
} else if (hasNuxtWeb) {
|
|
3635
3807
|
if (config.backend === "self") processTemplatesFromPrefix(vfs, templates, `examples/${example}/fullstack/nuxt`, "apps/web", config);
|
|
3636
3808
|
processTemplatesFromPrefix(vfs, templates, `examples/${example}/web/nuxt`, "apps/web", config);
|
|
3637
|
-
} else if (hasSvelteWeb)
|
|
3638
|
-
|
|
3809
|
+
} else if (hasSvelteWeb) {
|
|
3810
|
+
if (config.backend === "self") processTemplatesFromPrefix(vfs, templates, `examples/${example}/fullstack/svelte`, "apps/web", config);
|
|
3811
|
+
processTemplatesFromPrefix(vfs, templates, `examples/${example}/web/svelte`, "apps/web", config);
|
|
3812
|
+
} else if (hasSolidWeb) processTemplatesFromPrefix(vfs, templates, `examples/${example}/web/solid`, "apps/web", config);
|
|
3639
3813
|
else if (hasAstroWeb) processTemplatesFromPrefix(vfs, templates, `examples/${example}/web/astro`, "apps/web", config);
|
|
3640
3814
|
if (hasNative) {
|
|
3641
3815
|
let nativeFramework = "";
|
|
@@ -4098,6 +4272,9 @@ export default defineConfig({
|
|
|
4098
4272
|
});
|
|
4099
4273
|
`],
|
|
4100
4274
|
["api/orpc/fullstack/astro/src/pages/rpc/[...rest].ts.hbs", `import type { APIRoute } from "astro";
|
|
4275
|
+
import { OpenAPIHandler } from "@orpc/openapi/fetch";
|
|
4276
|
+
import { OpenAPIReferencePlugin } from "@orpc/openapi/plugins";
|
|
4277
|
+
import { ZodToJsonSchemaConverter } from "@orpc/zod/zod4";
|
|
4101
4278
|
import { RPCHandler } from "@orpc/server/fetch";
|
|
4102
4279
|
import { onError } from "@orpc/server";
|
|
4103
4280
|
import { appRouter } from "@{{projectName}}/api/routers/index";
|
|
@@ -4111,17 +4288,37 @@ const handler = new RPCHandler(appRouter, {
|
|
|
4111
4288
|
],
|
|
4112
4289
|
});
|
|
4113
4290
|
|
|
4291
|
+
const apiHandler = new OpenAPIHandler(appRouter, {
|
|
4292
|
+
plugins: [
|
|
4293
|
+
new OpenAPIReferencePlugin({
|
|
4294
|
+
schemaConverters: [new ZodToJsonSchemaConverter()],
|
|
4295
|
+
}),
|
|
4296
|
+
],
|
|
4297
|
+
interceptors: [
|
|
4298
|
+
onError((error) => {
|
|
4299
|
+
console.error(error);
|
|
4300
|
+
}),
|
|
4301
|
+
],
|
|
4302
|
+
});
|
|
4303
|
+
|
|
4114
4304
|
export const prerender = false;
|
|
4115
4305
|
|
|
4116
4306
|
export const ALL: APIRoute = async ({ request }) => {
|
|
4117
4307
|
const context = await createContext({ headers: request.headers });
|
|
4118
4308
|
|
|
4119
|
-
const
|
|
4309
|
+
const rpcResult = await handler.handle(request, {
|
|
4120
4310
|
prefix: "/rpc",
|
|
4121
4311
|
context,
|
|
4122
4312
|
});
|
|
4313
|
+
if (rpcResult.response) return rpcResult.response;
|
|
4123
4314
|
|
|
4124
|
-
|
|
4315
|
+
const apiResult = await apiHandler.handle(request, {
|
|
4316
|
+
prefix: "/rpc/api-reference",
|
|
4317
|
+
context,
|
|
4318
|
+
});
|
|
4319
|
+
if (apiResult.response) return apiResult.response;
|
|
4320
|
+
|
|
4321
|
+
return new Response("Not found", { status: 404 });
|
|
4125
4322
|
};
|
|
4126
4323
|
`],
|
|
4127
4324
|
["api/orpc/fullstack/next/src/app/api/rpc/[[...rest]]/route.ts.hbs", `import { createContext } from "@{{projectName}}/api/context";
|
|
@@ -4279,6 +4476,105 @@ export default defineEventHandler(async (event) => {
|
|
|
4279
4476
|
});
|
|
4280
4477
|
`],
|
|
4281
4478
|
["api/orpc/fullstack/nuxt/server/routes/rpc/index.ts.hbs", `export { default } from "./[...]";
|
|
4479
|
+
`],
|
|
4480
|
+
["api/orpc/fullstack/svelte/src/lib/orpc.server.ts.hbs", `import { getRequestEvent } from "$app/server";
|
|
4481
|
+
import { createContext } from "@{{projectName}}/api/context";
|
|
4482
|
+
import { appRouter, type AppRouterClient } from "@{{projectName}}/api/routers/index";
|
|
4483
|
+
{{#if (eq webDeploy "cloudflare")}}
|
|
4484
|
+
import { env as localEnv } from "@{{projectName}}/env/server";
|
|
4485
|
+
{{/if}}
|
|
4486
|
+
import { createRouterClient } from "@orpc/server";
|
|
4487
|
+
|
|
4488
|
+
if (typeof window !== "undefined") {
|
|
4489
|
+
throw new Error("This file should only be imported on the server.");
|
|
4490
|
+
}
|
|
4491
|
+
|
|
4492
|
+
const serverClient: AppRouterClient = createRouterClient(appRouter, {
|
|
4493
|
+
context: async () => {
|
|
4494
|
+
const event = getRequestEvent();
|
|
4495
|
+
{{#if (eq webDeploy "cloudflare")}}
|
|
4496
|
+
const env = event.platform?.env ?? localEnv;
|
|
4497
|
+
|
|
4498
|
+
{{/if}}
|
|
4499
|
+
return createContext({
|
|
4500
|
+
headers: event.request.headers,
|
|
4501
|
+
{{#if (eq webDeploy "cloudflare")}}
|
|
4502
|
+
env,
|
|
4503
|
+
{{/if}}
|
|
4504
|
+
});
|
|
4505
|
+
},
|
|
4506
|
+
});
|
|
4507
|
+
|
|
4508
|
+
// oRPC's SvelteKit SSR setup loads this from hooks.server.ts so $lib/orpc can
|
|
4509
|
+
// reuse the in-process server client during SSR and fall back to HTTP in the browser.
|
|
4510
|
+
globalThis.$client = serverClient;
|
|
4511
|
+
`],
|
|
4512
|
+
["api/orpc/fullstack/svelte/src/routes/rpc/[...rest]/+server.ts.hbs", `import { createContext } from "@{{projectName}}/api/context";
|
|
4513
|
+
import { appRouter } from "@{{projectName}}/api/routers/index";
|
|
4514
|
+
{{#if (eq webDeploy "cloudflare")}}
|
|
4515
|
+
import { env as localEnv } from "@{{projectName}}/env/server";
|
|
4516
|
+
{{/if}}
|
|
4517
|
+
import { OpenAPIHandler } from "@orpc/openapi/fetch";
|
|
4518
|
+
import { OpenAPIReferencePlugin } from "@orpc/openapi/plugins";
|
|
4519
|
+
import { ZodToJsonSchemaConverter } from "@orpc/zod/zod4";
|
|
4520
|
+
import { onError } from "@orpc/server";
|
|
4521
|
+
import { RPCHandler } from "@orpc/server/fetch";
|
|
4522
|
+
import type { RequestHandler } from "@sveltejs/kit";
|
|
4523
|
+
|
|
4524
|
+
const rpcHandler = new RPCHandler(appRouter, {
|
|
4525
|
+
interceptors: [
|
|
4526
|
+
onError((error) => {
|
|
4527
|
+
console.error(error);
|
|
4528
|
+
}),
|
|
4529
|
+
],
|
|
4530
|
+
});
|
|
4531
|
+
|
|
4532
|
+
const apiHandler = new OpenAPIHandler(appRouter, {
|
|
4533
|
+
plugins: [
|
|
4534
|
+
new OpenAPIReferencePlugin({
|
|
4535
|
+
schemaConverters: [new ZodToJsonSchemaConverter()],
|
|
4536
|
+
}),
|
|
4537
|
+
],
|
|
4538
|
+
interceptors: [
|
|
4539
|
+
onError((error) => {
|
|
4540
|
+
console.error(error);
|
|
4541
|
+
}),
|
|
4542
|
+
],
|
|
4543
|
+
});
|
|
4544
|
+
|
|
4545
|
+
const handle: RequestHandler = async ({ request{{#if (eq webDeploy "cloudflare")}}, platform{{/if}} }) => {
|
|
4546
|
+
{{#if (eq webDeploy "cloudflare")}}
|
|
4547
|
+
const env = platform?.env ?? localEnv;
|
|
4548
|
+
|
|
4549
|
+
{{/if}}
|
|
4550
|
+
const context = await createContext({
|
|
4551
|
+
headers: request.headers,
|
|
4552
|
+
{{#if (eq webDeploy "cloudflare")}}
|
|
4553
|
+
env,
|
|
4554
|
+
{{/if}}
|
|
4555
|
+
});
|
|
4556
|
+
|
|
4557
|
+
const rpcResult = await rpcHandler.handle(request, {
|
|
4558
|
+
prefix: "/rpc",
|
|
4559
|
+
context,
|
|
4560
|
+
});
|
|
4561
|
+
if (rpcResult.response) return rpcResult.response;
|
|
4562
|
+
|
|
4563
|
+
const apiResult = await apiHandler.handle(request, {
|
|
4564
|
+
prefix: "/rpc/api-reference",
|
|
4565
|
+
context,
|
|
4566
|
+
});
|
|
4567
|
+
if (apiResult.response) return apiResult.response;
|
|
4568
|
+
|
|
4569
|
+
return new Response("Not found", { status: 404 });
|
|
4570
|
+
};
|
|
4571
|
+
|
|
4572
|
+
export const HEAD = handle;
|
|
4573
|
+
export const GET = handle;
|
|
4574
|
+
export const POST = handle;
|
|
4575
|
+
export const PUT = handle;
|
|
4576
|
+
export const PATCH = handle;
|
|
4577
|
+
export const DELETE = handle;
|
|
4282
4578
|
`],
|
|
4283
4579
|
["api/orpc/fullstack/tanstack-start/src/routes/api/rpc/$.ts.hbs", `import { createContext } from "@{{projectName}}/api/context";
|
|
4284
4580
|
import { appRouter } from "@{{projectName}}/api/routers/index";
|
|
@@ -4467,6 +4763,8 @@ function toClerkContextAuth(auth: { userId: string | null } | null): ClerkContex
|
|
|
4467
4763
|
{{/if}}
|
|
4468
4764
|
|
|
4469
4765
|
{{#if (and (eq auth "clerk") (or (eq backend 'self') (eq backend 'hono') (eq backend 'elysia')))}}
|
|
4766
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
4767
|
+
{{else}}
|
|
4470
4768
|
import { createClerkClient } from "@clerk/backend";
|
|
4471
4769
|
import { env } from "@{{projectName}}/env/server";
|
|
4472
4770
|
|
|
@@ -4482,6 +4780,7 @@ async function authenticateClerkRequest(request: Request): Promise<ClerkContextA
|
|
|
4482
4780
|
return toClerkContextAuth(requestState.toAuth());
|
|
4483
4781
|
}
|
|
4484
4782
|
{{/if}}
|
|
4783
|
+
{{/if}}
|
|
4485
4784
|
|
|
4486
4785
|
{{#if (and (eq backend 'self') (includes frontend "next"))}}
|
|
4487
4786
|
import type { NextRequest } from "next/server";
|
|
@@ -4576,6 +4875,46 @@ export async function createContext({ headers }: CreateContextOptions) {
|
|
|
4576
4875
|
{{/if}}
|
|
4577
4876
|
}
|
|
4578
4877
|
|
|
4878
|
+
{{else if (and (eq backend 'self') (includes frontend "svelte"))}}
|
|
4879
|
+
{{#if (eq auth "better-auth")}}
|
|
4880
|
+
{{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
4881
|
+
import { createAuth } from "@{{projectName}}/auth";
|
|
4882
|
+
{{else}}
|
|
4883
|
+
import { auth } from "@{{projectName}}/auth";
|
|
4884
|
+
{{/if}}
|
|
4885
|
+
{{/if}}
|
|
4886
|
+
{{#if (eq webDeploy "cloudflare")}}
|
|
4887
|
+
import type {} from "@{{projectName}}/env/server";
|
|
4888
|
+
{{/if}}
|
|
4889
|
+
|
|
4890
|
+
export type CreateContextOptions = {
|
|
4891
|
+
headers: Headers;
|
|
4892
|
+
{{#if (eq webDeploy "cloudflare")}}
|
|
4893
|
+
env: Env;
|
|
4894
|
+
{{/if}}
|
|
4895
|
+
};
|
|
4896
|
+
|
|
4897
|
+
export async function createContext({ headers{{#if (eq webDeploy "cloudflare")}}, env{{/if}} }: CreateContextOptions) {
|
|
4898
|
+
{{#if (eq auth "better-auth")}}
|
|
4899
|
+
const session = await {{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}createAuth({{#if (eq webDeploy "cloudflare")}}env{{/if}}){{else}}auth{{/if}}.api.getSession({ headers });
|
|
4900
|
+
return {
|
|
4901
|
+
auth: null,
|
|
4902
|
+
session,
|
|
4903
|
+
{{#if (eq webDeploy "cloudflare")}}
|
|
4904
|
+
env,
|
|
4905
|
+
{{/if}}
|
|
4906
|
+
};
|
|
4907
|
+
{{else}}
|
|
4908
|
+
return {
|
|
4909
|
+
auth: null,
|
|
4910
|
+
session: null,
|
|
4911
|
+
{{#if (eq webDeploy "cloudflare")}}
|
|
4912
|
+
env,
|
|
4913
|
+
{{/if}}
|
|
4914
|
+
};
|
|
4915
|
+
{{/if}}
|
|
4916
|
+
}
|
|
4917
|
+
|
|
4579
4918
|
{{else if (and (eq backend 'self') (includes frontend "astro"))}}
|
|
4580
4919
|
{{#if (eq auth "better-auth")}}
|
|
4581
4920
|
{{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
@@ -5144,7 +5483,9 @@ export const client: AppRouterClient = createORPCClient(link);
|
|
|
5144
5483
|
|
|
5145
5484
|
export const orpc = createTanstackQueryUtils(client);
|
|
5146
5485
|
`],
|
|
5147
|
-
["api/orpc/web/svelte/src/lib/orpc.ts.hbs", `
|
|
5486
|
+
["api/orpc/web/svelte/src/lib/orpc.ts.hbs", `{{#unless (eq backend "self")}}
|
|
5487
|
+
import { PUBLIC_SERVER_URL } from "$env/static/public";
|
|
5488
|
+
{{/unless}}
|
|
5148
5489
|
import { createORPCClient } from "@orpc/client";
|
|
5149
5490
|
import { RPCLink } from "@orpc/client/fetch";
|
|
5150
5491
|
import { createTanstackQueryUtils } from "@orpc/tanstack-query";
|
|
@@ -5160,7 +5501,17 @@ export const queryClient = new QueryClient({
|
|
|
5160
5501
|
});
|
|
5161
5502
|
|
|
5162
5503
|
export const link = new RPCLink({
|
|
5504
|
+
{{#if (eq backend "self")}}
|
|
5505
|
+
url: () => {
|
|
5506
|
+
if (typeof window === "undefined") {
|
|
5507
|
+
throw new Error("This link is not allowed on the server side.");
|
|
5508
|
+
}
|
|
5509
|
+
|
|
5510
|
+
return \`\${window.location.origin}/rpc\`;
|
|
5511
|
+
},
|
|
5512
|
+
{{else}}
|
|
5163
5513
|
url: \`\${PUBLIC_SERVER_URL}/rpc\`,
|
|
5514
|
+
{{/if}}
|
|
5164
5515
|
{{#if (eq auth "better-auth")}}
|
|
5165
5516
|
fetch(url, options) {
|
|
5166
5517
|
return fetch(url, {
|
|
@@ -5171,7 +5522,11 @@ export const link = new RPCLink({
|
|
|
5171
5522
|
{{/if}}
|
|
5172
5523
|
});
|
|
5173
5524
|
|
|
5525
|
+
{{#if (eq backend "self")}}
|
|
5526
|
+
export const client: AppRouterClient = globalThis.$client ?? createORPCClient(link);
|
|
5527
|
+
{{else}}
|
|
5174
5528
|
export const client: AppRouterClient = createORPCClient(link);
|
|
5529
|
+
{{/if}}
|
|
5175
5530
|
|
|
5176
5531
|
export const orpc = createTanstackQueryUtils(client);
|
|
5177
5532
|
`],
|
|
@@ -8900,6 +9255,45 @@ export default defineEventHandler((event) => {
|
|
|
8900
9255
|
{{/if}}
|
|
8901
9256
|
return auth.handler(toWebRequest(event));
|
|
8902
9257
|
});
|
|
9258
|
+
`],
|
|
9259
|
+
["auth/better-auth/fullstack/svelte/src/hooks.server.ts.hbs", `{{#if (eq api "orpc")}}
|
|
9260
|
+
import "./lib/orpc.server";
|
|
9261
|
+
{{/if}}
|
|
9262
|
+
import { building } from "$app/environment";
|
|
9263
|
+
{{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
9264
|
+
import { createAuth } from "@{{projectName}}/auth";
|
|
9265
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare"))}}
|
|
9266
|
+
import { env as localEnv } from "@{{projectName}}/env/server";
|
|
9267
|
+
{{/if}}
|
|
9268
|
+
{{else}}
|
|
9269
|
+
import { auth } from "@{{projectName}}/auth";
|
|
9270
|
+
{{/if}}
|
|
9271
|
+
import { svelteKitHandler } from "better-auth/svelte-kit";
|
|
9272
|
+
import type { Handle } from "@sveltejs/kit";
|
|
9273
|
+
|
|
9274
|
+
export const handle: Handle = async ({ event, resolve }) => {
|
|
9275
|
+
{{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
9276
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare"))}}
|
|
9277
|
+
if (building) {
|
|
9278
|
+
return resolve(event);
|
|
9279
|
+
}
|
|
9280
|
+
|
|
9281
|
+
const authEnv = event.platform?.env ?? localEnv;
|
|
9282
|
+
const authInstance = createAuth(authEnv);
|
|
9283
|
+
{{else}}
|
|
9284
|
+
const authInstance = createAuth();
|
|
9285
|
+
{{/if}}
|
|
9286
|
+
{{else}}
|
|
9287
|
+
const authInstance = auth;
|
|
9288
|
+
{{/if}}
|
|
9289
|
+
|
|
9290
|
+
return svelteKitHandler({
|
|
9291
|
+
event,
|
|
9292
|
+
resolve,
|
|
9293
|
+
auth: authInstance,
|
|
9294
|
+
building,
|
|
9295
|
+
});
|
|
9296
|
+
};
|
|
8903
9297
|
`],
|
|
8904
9298
|
["auth/better-auth/fullstack/tanstack-start/src/routes/api/auth/$.ts.hbs", `{{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
8905
9299
|
import { createAuth } from '@{{projectName}}/auth'
|
|
@@ -10835,15 +11229,23 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
|
|
10835
11229
|
["auth/better-auth/server/base/src/index.ts.hbs", `{{#if (eq orm "prisma")}}
|
|
10836
11230
|
import { betterAuth } from "better-auth";
|
|
10837
11231
|
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
11232
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
11233
|
+
import type {} from "@{{projectName}}/env/server";
|
|
11234
|
+
{{else}}
|
|
10838
11235
|
import { env } from "@{{projectName}}/env/server";
|
|
11236
|
+
{{/if}}
|
|
10839
11237
|
{{#if (eq payments "polar")}}
|
|
10840
11238
|
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
|
11239
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
11240
|
+
import { createPolarClient } from "./lib/payments";
|
|
11241
|
+
{{else}}
|
|
10841
11242
|
import { polarClient } from "./lib/payments";
|
|
10842
11243
|
{{/if}}
|
|
11244
|
+
{{/if}}
|
|
10843
11245
|
import { createPrismaClient } from "@{{projectName}}/db";
|
|
10844
11246
|
|
|
10845
|
-
export function createAuth() {
|
|
10846
|
-
const prisma = createPrismaClient();
|
|
11247
|
+
export function createAuth({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
11248
|
+
const prisma = createPrismaClient({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env{{/if}});
|
|
10847
11249
|
|
|
10848
11250
|
return betterAuth({
|
|
10849
11251
|
database: prismaAdapter(prisma, {
|
|
@@ -10884,7 +11286,7 @@ export function createAuth() {
|
|
|
10884
11286
|
plugins: [
|
|
10885
11287
|
{{#if (eq payments "polar")}}
|
|
10886
11288
|
polar({
|
|
10887
|
-
client: polarClient,
|
|
11289
|
+
client: {{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}createPolarClient(env){{else}}polarClient{{/if}},
|
|
10888
11290
|
createCustomerOnSignUp: true,
|
|
10889
11291
|
enableCustomerPortal: true,
|
|
10890
11292
|
use: [
|
|
@@ -10915,17 +11317,25 @@ export const auth = createAuth();
|
|
|
10915
11317
|
{{#if (or (eq runtime "bun") (eq runtime "node") (eq runtime "none"))}}
|
|
10916
11318
|
import { betterAuth } from "better-auth";
|
|
10917
11319
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
11320
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
11321
|
+
import type {} from "@{{projectName}}/env/server";
|
|
11322
|
+
{{else}}
|
|
10918
11323
|
import { env } from "@{{projectName}}/env/server";
|
|
11324
|
+
{{/if}}
|
|
10919
11325
|
{{#if (eq payments "polar")}}
|
|
10920
11326
|
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
|
11327
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
11328
|
+
import { createPolarClient } from "./lib/payments";
|
|
11329
|
+
{{else}}
|
|
10921
11330
|
import { polarClient } from "./lib/payments";
|
|
10922
11331
|
{{/if}}
|
|
11332
|
+
{{/if}}
|
|
10923
11333
|
import { createDb } from "@{{projectName}}/db";
|
|
10924
11334
|
import * as schema from "@{{projectName}}/db/schema/auth";
|
|
10925
11335
|
|
|
10926
11336
|
|
|
10927
|
-
export function createAuth() {
|
|
10928
|
-
const db = createDb();
|
|
11337
|
+
export function createAuth({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
11338
|
+
const db = createDb({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env{{/if}});
|
|
10929
11339
|
|
|
10930
11340
|
return betterAuth({
|
|
10931
11341
|
database: drizzleAdapter(db, {
|
|
@@ -10965,7 +11375,7 @@ export function createAuth() {
|
|
|
10965
11375
|
plugins: [
|
|
10966
11376
|
{{#if (eq payments "polar")}}
|
|
10967
11377
|
polar({
|
|
10968
|
-
client: polarClient,
|
|
11378
|
+
client: {{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}createPolarClient(env){{else}}polarClient{{/if}},
|
|
10969
11379
|
createCustomerOnSignUp: true,
|
|
10970
11380
|
enableCustomerPortal: true,
|
|
10971
11381
|
use: [
|
|
@@ -11083,14 +11493,22 @@ export function createAuth() {
|
|
|
11083
11493
|
{{#if (eq orm "mongoose")}}
|
|
11084
11494
|
import { betterAuth } from "better-auth";
|
|
11085
11495
|
import { mongodbAdapter } from "better-auth/adapters/mongodb";
|
|
11496
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
11497
|
+
import type {} from "@{{projectName}}/env/server";
|
|
11498
|
+
{{else}}
|
|
11086
11499
|
import { env } from "@{{projectName}}/env/server";
|
|
11500
|
+
{{/if}}
|
|
11087
11501
|
{{#if (eq payments "polar")}}
|
|
11088
11502
|
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
|
11503
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
11504
|
+
import { createPolarClient } from "./lib/payments";
|
|
11505
|
+
{{else}}
|
|
11089
11506
|
import { polarClient } from "./lib/payments";
|
|
11090
11507
|
{{/if}}
|
|
11508
|
+
{{/if}}
|
|
11091
11509
|
import { client } from "@{{projectName}}/db";
|
|
11092
11510
|
|
|
11093
|
-
export function createAuth() {
|
|
11511
|
+
export function createAuth({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
11094
11512
|
return betterAuth({
|
|
11095
11513
|
database: mongodbAdapter(client),
|
|
11096
11514
|
trustedOrigins: [
|
|
@@ -11124,7 +11542,7 @@ export function createAuth() {
|
|
|
11124
11542
|
{{#if (eq payments "polar")}}
|
|
11125
11543
|
plugins: [
|
|
11126
11544
|
polar({
|
|
11127
|
-
client: polarClient,
|
|
11545
|
+
client: {{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}createPolarClient(env){{else}}polarClient{{/if}},
|
|
11128
11546
|
createCustomerOnSignUp: true,
|
|
11129
11547
|
enableCustomerPortal: true,
|
|
11130
11548
|
use: [
|
|
@@ -11153,14 +11571,22 @@ export const auth = createAuth();
|
|
|
11153
11571
|
|
|
11154
11572
|
{{#if (eq orm "none")}}
|
|
11155
11573
|
import { betterAuth } from "better-auth";
|
|
11574
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
11575
|
+
import type {} from "@{{projectName}}/env/server";
|
|
11576
|
+
{{else}}
|
|
11156
11577
|
import { env } from "@{{projectName}}/env/server";
|
|
11578
|
+
{{/if}}
|
|
11157
11579
|
{{#if (eq payments "polar")}}
|
|
11158
11580
|
import { polar, checkout, portal } from "@polar-sh/better-auth";
|
|
11581
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
11582
|
+
import { createPolarClient } from "./lib/payments";
|
|
11583
|
+
{{else}}
|
|
11159
11584
|
import { polarClient } from "./lib/payments";
|
|
11160
11585
|
{{/if}}
|
|
11586
|
+
{{/if}}
|
|
11161
11587
|
|
|
11162
11588
|
|
|
11163
|
-
export function createAuth() {
|
|
11589
|
+
export function createAuth({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
11164
11590
|
return betterAuth({
|
|
11165
11591
|
database: "", // Invalid configuration
|
|
11166
11592
|
trustedOrigins: [
|
|
@@ -11194,7 +11620,7 @@ export function createAuth() {
|
|
|
11194
11620
|
{{#if (eq payments "polar")}}
|
|
11195
11621
|
plugins: [
|
|
11196
11622
|
polar({
|
|
11197
|
-
client: polarClient,
|
|
11623
|
+
client: {{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}createPolarClient(env){{else}}polarClient{{/if}},
|
|
11198
11624
|
createCustomerOnSignUp: true,
|
|
11199
11625
|
enableCustomerPortal: true,
|
|
11200
11626
|
use: [
|
|
@@ -12597,10 +13023,14 @@ import { polarClient } from "@polar-sh/better-auth";
|
|
|
12597
13023
|
{{/if}}
|
|
12598
13024
|
|
|
12599
13025
|
export default defineNuxtPlugin(() => {
|
|
13026
|
+
{{#if (ne backend "self")}}
|
|
12600
13027
|
const config = useRuntimeConfig();
|
|
13028
|
+
{{/if}}
|
|
12601
13029
|
|
|
12602
13030
|
const authClient = createAuthClient({
|
|
13031
|
+
{{#if (ne backend "self")}}
|
|
12603
13032
|
baseURL: config.public.serverUrl,
|
|
13033
|
+
{{/if}}
|
|
12604
13034
|
{{#if (eq payments "polar")}}
|
|
12605
13035
|
plugins: [polarClient()],
|
|
12606
13036
|
{{/if}}
|
|
@@ -14995,6 +15425,8 @@ function RouteComponent() {
|
|
|
14995
15425
|
onSubmit: validationSchema,
|
|
14996
15426
|
},
|
|
14997
15427
|
}));
|
|
15428
|
+
|
|
15429
|
+
type SubmitState = Pick<typeof form.state, 'canSubmit' | 'isSubmitting'>;
|
|
14998
15430
|
<\/script>
|
|
14999
15431
|
|
|
15000
15432
|
<div class="mx-auto mt-10 w-full max-w-md p-6">
|
|
@@ -15058,8 +15490,8 @@ function RouteComponent() {
|
|
|
15058
15490
|
{/snippet}
|
|
15059
15491
|
</form.Field>
|
|
15060
15492
|
|
|
15061
|
-
<form.Subscribe selector={(state) => ({ canSubmit: state.canSubmit, isSubmitting: state.isSubmitting })}>
|
|
15062
|
-
{#snippet children(state)}
|
|
15493
|
+
<form.Subscribe selector={(state: typeof form.state): SubmitState => ({ canSubmit: state.canSubmit, isSubmitting: state.isSubmitting })}>
|
|
15494
|
+
{#snippet children(state: SubmitState)}
|
|
15063
15495
|
<button type="submit" class="w-full" disabled={!state.canSubmit || state.isSubmitting}>
|
|
15064
15496
|
{state.isSubmitting ? 'Submitting...' : 'Sign In'}
|
|
15065
15497
|
</button>
|
|
@@ -15113,6 +15545,8 @@ function RouteComponent() {
|
|
|
15113
15545
|
onSubmit: validationSchema,
|
|
15114
15546
|
},
|
|
15115
15547
|
}));
|
|
15548
|
+
|
|
15549
|
+
type SubmitState = Pick<typeof form.state, 'canSubmit' | 'isSubmitting'>;
|
|
15116
15550
|
<\/script>
|
|
15117
15551
|
|
|
15118
15552
|
<div class="mx-auto mt-10 w-full max-w-md p-6">
|
|
@@ -15201,8 +15635,8 @@ function RouteComponent() {
|
|
|
15201
15635
|
{/snippet}
|
|
15202
15636
|
</form.Field>
|
|
15203
15637
|
|
|
15204
|
-
<form.Subscribe selector={(state) => ({ canSubmit: state.canSubmit, isSubmitting: state.isSubmitting })}>
|
|
15205
|
-
{#snippet children(state)}
|
|
15638
|
+
<form.Subscribe selector={(state: typeof form.state): SubmitState => ({ canSubmit: state.canSubmit, isSubmitting: state.isSubmitting })}>
|
|
15639
|
+
{#snippet children(state: SubmitState)}
|
|
15206
15640
|
<button type="submit" class="w-full" disabled={!state.canSubmit || state.isSubmitting}>
|
|
15207
15641
|
{state.isSubmitting ? 'Submitting...' : 'Sign Up'}
|
|
15208
15642
|
</button>
|
|
@@ -15270,14 +15704,18 @@ function RouteComponent() {
|
|
|
15270
15704
|
{/if}
|
|
15271
15705
|
</div>
|
|
15272
15706
|
`],
|
|
15273
|
-
["auth/better-auth/web/svelte/src/lib/auth-client.ts.hbs", `
|
|
15707
|
+
["auth/better-auth/web/svelte/src/lib/auth-client.ts.hbs", `{{#unless (eq backend "self")}}
|
|
15708
|
+
import { PUBLIC_SERVER_URL } from "$env/static/public";
|
|
15709
|
+
{{/unless}}
|
|
15274
15710
|
import { createAuthClient } from "better-auth/svelte";
|
|
15275
15711
|
{{#if (eq payments "polar")}}
|
|
15276
15712
|
import { polarClient } from "@polar-sh/better-auth";
|
|
15277
15713
|
{{/if}}
|
|
15278
15714
|
|
|
15279
15715
|
export const authClient = createAuthClient({
|
|
15716
|
+
{{#unless (eq backend "self")}}
|
|
15280
15717
|
baseURL: PUBLIC_SERVER_URL,
|
|
15718
|
+
{{/unless}}
|
|
15281
15719
|
{{#if (eq payments "polar")}}
|
|
15282
15720
|
plugins: [polarClient()]
|
|
15283
15721
|
{{/if}}
|
|
@@ -17132,7 +17570,7 @@ import { Elysia } from "elysia";
|
|
|
17132
17570
|
import { cors } from "@elysiajs/cors";
|
|
17133
17571
|
{{#if (includes examples "ai")}}
|
|
17134
17572
|
import { google } from "@ai-sdk/google";
|
|
17135
|
-
import { convertToModelMessages, streamText, wrapLanguageModel } from "ai";
|
|
17573
|
+
import { convertToModelMessages, streamText, type UIMessage, wrapLanguageModel } from "ai";
|
|
17136
17574
|
import { devToolsMiddleware } from "@ai-sdk/devtools";
|
|
17137
17575
|
{{/if}}
|
|
17138
17576
|
{{#if (eq api "trpc")}}
|
|
@@ -17176,9 +17614,9 @@ const apiHandler = new OpenAPIHandler(appRouter, {
|
|
|
17176
17614
|
{{/if}}
|
|
17177
17615
|
|
|
17178
17616
|
{{#if (eq runtime "node")}}
|
|
17179
|
-
|
|
17617
|
+
new Elysia({ adapter: node() })
|
|
17180
17618
|
{{else}}
|
|
17181
|
-
|
|
17619
|
+
new Elysia()
|
|
17182
17620
|
{{/if}}
|
|
17183
17621
|
.use(
|
|
17184
17622
|
cors({
|
|
@@ -17242,7 +17680,7 @@ const app = new Elysia()
|
|
|
17242
17680
|
{{/if}}
|
|
17243
17681
|
{{#if (includes examples "ai")}}
|
|
17244
17682
|
.post("/ai", async (context) => {
|
|
17245
|
-
const body = await context.request.json();
|
|
17683
|
+
const body = (await context.request.json()) as { messages?: UIMessage[] };
|
|
17246
17684
|
const uiMessages = body.messages || [];
|
|
17247
17685
|
const model = wrapLanguageModel({
|
|
17248
17686
|
model: google("gemini-2.5-flash"),
|
|
@@ -17250,7 +17688,7 @@ const app = new Elysia()
|
|
|
17250
17688
|
});
|
|
17251
17689
|
const result = streamText({
|
|
17252
17690
|
model,
|
|
17253
|
-
messages: await convertToModelMessages(uiMessages)
|
|
17691
|
+
messages: await convertToModelMessages(uiMessages),
|
|
17254
17692
|
});
|
|
17255
17693
|
|
|
17256
17694
|
return result.toUIMessageStreamResponse();
|
|
@@ -17998,13 +18436,17 @@ export default defineConfig({
|
|
|
17998
18436
|
});
|
|
17999
18437
|
`],
|
|
18000
18438
|
["db/drizzle/mysql/src/index.ts.hbs", `{{#if (or (eq runtime "bun") (eq runtime "node") (eq runtime "none"))}}
|
|
18439
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
18440
|
+
import type {} from "@{{projectName}}/env/server";
|
|
18441
|
+
{{else}}
|
|
18001
18442
|
import { env } from "@{{projectName}}/env/server";
|
|
18443
|
+
{{/if}}
|
|
18002
18444
|
import * as schema from "./schema";
|
|
18003
18445
|
|
|
18004
18446
|
{{#if (eq dbSetup "planetscale")}}
|
|
18005
18447
|
import { drizzle } from "drizzle-orm/planetscale-serverless";
|
|
18006
18448
|
|
|
18007
|
-
export function createDb() {
|
|
18449
|
+
export function createDb({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
18008
18450
|
return drizzle({
|
|
18009
18451
|
connection: {
|
|
18010
18452
|
host: env.DATABASE_HOST,
|
|
@@ -18017,7 +18459,7 @@ export function createDb() {
|
|
|
18017
18459
|
{{else}}
|
|
18018
18460
|
import { drizzle } from "drizzle-orm/mysql2";
|
|
18019
18461
|
|
|
18020
|
-
export function createDb() {
|
|
18462
|
+
export function createDb({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
18021
18463
|
return drizzle({
|
|
18022
18464
|
connection: {
|
|
18023
18465
|
uri: env.DATABASE_URL,
|
|
@@ -18085,14 +18527,18 @@ export default defineConfig({
|
|
|
18085
18527
|
});
|
|
18086
18528
|
`],
|
|
18087
18529
|
["db/drizzle/postgres/src/index.ts.hbs", `{{#if (or (eq runtime "bun") (eq runtime "node") (eq runtime "none"))}}
|
|
18530
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
18531
|
+
import type {} from "@{{projectName}}/env/server";
|
|
18532
|
+
{{else}}
|
|
18088
18533
|
import { env } from "@{{projectName}}/env/server";
|
|
18534
|
+
{{/if}}
|
|
18089
18535
|
import * as schema from "./schema";
|
|
18090
18536
|
|
|
18091
18537
|
{{#if (eq dbSetup "neon")}}
|
|
18092
18538
|
import { neon } from '@neondatabase/serverless';
|
|
18093
18539
|
import { drizzle } from 'drizzle-orm/neon-http';
|
|
18094
18540
|
|
|
18095
|
-
export function createDb() {
|
|
18541
|
+
export function createDb({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
18096
18542
|
const sql = neon(env.DATABASE_URL);
|
|
18097
18543
|
return drizzle(sql, { schema });
|
|
18098
18544
|
}
|
|
@@ -18102,7 +18548,7 @@ import { drizzle } from "drizzle-orm/node-postgres";
|
|
|
18102
18548
|
import { Pool } from "pg";
|
|
18103
18549
|
{{/if}}
|
|
18104
18550
|
|
|
18105
|
-
export function createDb() {
|
|
18551
|
+
export function createDb({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
18106
18552
|
{{#if (and (eq backend "self") (eq webDeploy "cloudflare"))}}
|
|
18107
18553
|
const pool = new Pool({
|
|
18108
18554
|
connectionString: env.DATABASE_URL,
|
|
@@ -18181,18 +18627,26 @@ export default defineConfig({
|
|
|
18181
18627
|
["db/drizzle/sqlite/src/index.ts.hbs", `{{#if (eq dbSetup "d1")}}
|
|
18182
18628
|
import * as schema from "./schema";
|
|
18183
18629
|
import { drizzle } from "drizzle-orm/d1";
|
|
18630
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
18631
|
+
import type {} from "@{{projectName}}/env/server";
|
|
18632
|
+
{{else}}
|
|
18184
18633
|
import { env } from "@{{projectName}}/env/server";
|
|
18634
|
+
{{/if}}
|
|
18185
18635
|
|
|
18186
|
-
export function createDb() {
|
|
18636
|
+
export function createDb({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
18187
18637
|
return drizzle(env.DB, { schema });
|
|
18188
18638
|
}
|
|
18189
18639
|
{{else if (or (eq runtime "bun") (eq runtime "node") (eq runtime "none"))}}
|
|
18640
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
18641
|
+
import type {} from "@{{projectName}}/env/server";
|
|
18642
|
+
{{else}}
|
|
18190
18643
|
import { env } from "@{{projectName}}/env/server";
|
|
18644
|
+
{{/if}}
|
|
18191
18645
|
import * as schema from "./schema";
|
|
18192
18646
|
import { drizzle } from "drizzle-orm/libsql";
|
|
18193
18647
|
import { createClient } from "@libsql/client";
|
|
18194
18648
|
|
|
18195
|
-
export function createDb() {
|
|
18649
|
+
export function createDb({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
18196
18650
|
const client = createClient({
|
|
18197
18651
|
url: env.DATABASE_URL,
|
|
18198
18652
|
{{#if (eq dbSetup "turso")}}
|
|
@@ -18353,19 +18807,23 @@ export function createPrismaClient() {
|
|
|
18353
18807
|
{{/if}}
|
|
18354
18808
|
{{else}}
|
|
18355
18809
|
import { PrismaClient } from "../prisma/generated/client";
|
|
18810
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
18811
|
+
import type {} from "@{{projectName}}/env/server";
|
|
18812
|
+
{{else}}
|
|
18356
18813
|
import { env } from "@{{projectName}}/env/server";
|
|
18814
|
+
{{/if}}
|
|
18357
18815
|
|
|
18358
18816
|
{{#if (eq dbSetup "planetscale")}}
|
|
18359
18817
|
import { PrismaPlanetScale } from "@prisma/adapter-planetscale";
|
|
18360
18818
|
|
|
18361
|
-
export function createPrismaClient() {
|
|
18819
|
+
export function createPrismaClient({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
18362
18820
|
const adapter = new PrismaPlanetScale({ url: env.DATABASE_URL });
|
|
18363
18821
|
return new PrismaClient({ adapter });
|
|
18364
18822
|
}
|
|
18365
18823
|
{{else}}
|
|
18366
18824
|
import { PrismaMariaDb } from "@prisma/adapter-mariadb";
|
|
18367
18825
|
|
|
18368
|
-
export function createPrismaClient() {
|
|
18826
|
+
export function createPrismaClient({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
18369
18827
|
const databaseUrl: string = env.DATABASE_URL;
|
|
18370
18828
|
const url: URL = new URL(databaseUrl);
|
|
18371
18829
|
const connectionConfig = {
|
|
@@ -18474,11 +18932,15 @@ export function createPrismaClient() {
|
|
|
18474
18932
|
{{/if}}
|
|
18475
18933
|
{{else}}
|
|
18476
18934
|
import { PrismaClient } from "../prisma/generated/client";
|
|
18935
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
18936
|
+
import type {} from "@{{projectName}}/env/server";
|
|
18937
|
+
{{else}}
|
|
18477
18938
|
import { env } from "@{{projectName}}/env/server";
|
|
18939
|
+
{{/if}}
|
|
18478
18940
|
{{#if (eq dbSetup "neon")}}
|
|
18479
18941
|
import { PrismaNeon } from "@prisma/adapter-neon";
|
|
18480
18942
|
|
|
18481
|
-
export function createPrismaClient() {
|
|
18943
|
+
export function createPrismaClient({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
18482
18944
|
const adapter = new PrismaNeon({
|
|
18483
18945
|
connectionString: env.DATABASE_URL,
|
|
18484
18946
|
});
|
|
@@ -18489,7 +18951,7 @@ export function createPrismaClient() {
|
|
|
18489
18951
|
{{else if (eq dbSetup "prisma-postgres")}}
|
|
18490
18952
|
import { PrismaPg } from "@prisma/adapter-pg";
|
|
18491
18953
|
|
|
18492
|
-
export function createPrismaClient() {
|
|
18954
|
+
export function createPrismaClient({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
18493
18955
|
const adapter = new PrismaPg({
|
|
18494
18956
|
connectionString: env.DATABASE_URL,
|
|
18495
18957
|
{{#if (and (eq backend "self") (eq webDeploy "cloudflare"))}}
|
|
@@ -18503,7 +18965,7 @@ export function createPrismaClient() {
|
|
|
18503
18965
|
{{else}}
|
|
18504
18966
|
import { PrismaPg } from "@prisma/adapter-pg";
|
|
18505
18967
|
|
|
18506
|
-
export function createPrismaClient() {
|
|
18968
|
+
export function createPrismaClient({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
18507
18969
|
const adapter = new PrismaPg({
|
|
18508
18970
|
connectionString: env.DATABASE_URL,
|
|
18509
18971
|
{{#if (and (eq backend "self") (eq webDeploy "cloudflare"))}}
|
|
@@ -18568,9 +19030,13 @@ datasource db {
|
|
|
18568
19030
|
|
|
18569
19031
|
{{#if (eq dbSetup "d1")}}
|
|
18570
19032
|
import { PrismaD1 } from "@prisma/adapter-d1";
|
|
19033
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
19034
|
+
import type {} from "@{{projectName}}/env/server";
|
|
19035
|
+
{{else}}
|
|
18571
19036
|
import { env } from "@{{projectName}}/env/server";
|
|
19037
|
+
{{/if}}
|
|
18572
19038
|
|
|
18573
|
-
export function createPrismaClient() {
|
|
19039
|
+
export function createPrismaClient({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
18574
19040
|
const adapter = new PrismaD1(env.DB);
|
|
18575
19041
|
return new PrismaClient({ adapter });
|
|
18576
19042
|
}
|
|
@@ -18581,9 +19047,13 @@ export default prisma;
|
|
|
18581
19047
|
{{/if}}
|
|
18582
19048
|
{{else}}
|
|
18583
19049
|
import { PrismaLibSql } from "@prisma/adapter-libsql";
|
|
19050
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
19051
|
+
import type {} from "@{{projectName}}/env/server";
|
|
19052
|
+
{{else}}
|
|
18584
19053
|
import { env } from "@{{projectName}}/env/server";
|
|
19054
|
+
{{/if}}
|
|
18585
19055
|
|
|
18586
|
-
export function createPrismaClient() {
|
|
19056
|
+
export function createPrismaClient({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
18587
19057
|
const adapter = new PrismaLibSql({
|
|
18588
19058
|
url: env.DATABASE_URL,
|
|
18589
19059
|
{{#if (eq dbSetup "turso")}}
|
|
@@ -18719,6 +19189,26 @@ export default defineEventHandler(async (event) => {
|
|
|
18719
19189
|
|
|
18720
19190
|
return result.toUIMessageStreamResponse();
|
|
18721
19191
|
});
|
|
19192
|
+
`],
|
|
19193
|
+
["examples/ai/fullstack/svelte/src/routes/api/ai/+server.ts.hbs", `import { devToolsMiddleware } from "@ai-sdk/devtools";
|
|
19194
|
+
import { google } from "@ai-sdk/google";
|
|
19195
|
+
import { convertToModelMessages, streamText, type UIMessage, wrapLanguageModel } from "ai";
|
|
19196
|
+
import type { RequestHandler } from "@sveltejs/kit";
|
|
19197
|
+
|
|
19198
|
+
export const POST: RequestHandler = async ({ request }) => {
|
|
19199
|
+
const { messages }: { messages: UIMessage[] } = await request.json();
|
|
19200
|
+
|
|
19201
|
+
const model = wrapLanguageModel({
|
|
19202
|
+
model: google("gemini-2.5-flash"),
|
|
19203
|
+
middleware: devToolsMiddleware(),
|
|
19204
|
+
});
|
|
19205
|
+
const result = streamText({
|
|
19206
|
+
model,
|
|
19207
|
+
messages: await convertToModelMessages(messages),
|
|
19208
|
+
});
|
|
19209
|
+
|
|
19210
|
+
return result.toUIMessageStreamResponse();
|
|
19211
|
+
};
|
|
18722
19212
|
`],
|
|
18723
19213
|
["examples/ai/fullstack/tanstack-start/src/routes/api/ai/$.ts.hbs", `import { createFileRoute } from "@tanstack/react-router";
|
|
18724
19214
|
import { google } from "@ai-sdk/google";
|
|
@@ -21489,14 +21979,20 @@ function RouteComponent() {
|
|
|
21489
21979
|
{{/if}}
|
|
21490
21980
|
`],
|
|
21491
21981
|
["examples/ai/web/svelte/src/routes/ai/+page.svelte.hbs", `<script lang="ts">
|
|
21982
|
+
{{#unless (eq backend "self")}}
|
|
21492
21983
|
import { PUBLIC_SERVER_URL } from "$env/static/public";
|
|
21984
|
+
{{/unless}}
|
|
21493
21985
|
import { Chat } from "@ai-sdk/svelte";
|
|
21494
21986
|
import { DefaultChatTransport } from "ai";
|
|
21495
21987
|
|
|
21496
21988
|
let input = $state("");
|
|
21497
21989
|
const chat = new Chat({
|
|
21498
21990
|
transport: new DefaultChatTransport({
|
|
21991
|
+
{{#if (eq backend "self")}}
|
|
21992
|
+
api: "/api/ai",
|
|
21993
|
+
{{else}}
|
|
21499
21994
|
api: \`\${PUBLIC_SERVER_URL}/ai\`,
|
|
21995
|
+
{{/if}}
|
|
21500
21996
|
}),
|
|
21501
21997
|
});
|
|
21502
21998
|
|
|
@@ -22794,18 +23290,18 @@ import { todo } from "@{{projectName}}/db/schema/todo";
|
|
|
22794
23290
|
import { publicProcedure } from "../index";
|
|
22795
23291
|
|
|
22796
23292
|
export const todoRouter = {
|
|
22797
|
-
getAll: publicProcedure.handler(async () => {
|
|
23293
|
+
getAll: publicProcedure.handler(async ({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}{ context }{{/if}}) => {
|
|
22798
23294
|
{{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
22799
|
-
const db = createDb();
|
|
23295
|
+
const db = createDb({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}context.env{{/if}});
|
|
22800
23296
|
{{/if}}
|
|
22801
23297
|
return await db.select().from(todo);
|
|
22802
23298
|
}),
|
|
22803
23299
|
|
|
22804
23300
|
create: publicProcedure
|
|
22805
23301
|
.input(z.object({ text: z.string().min(1) }))
|
|
22806
|
-
.handler(async ({ input }) => {
|
|
23302
|
+
.handler(async ({ input{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}, context{{/if}} }) => {
|
|
22807
23303
|
{{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
22808
|
-
const db = createDb();
|
|
23304
|
+
const db = createDb({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}context.env{{/if}});
|
|
22809
23305
|
{{/if}}
|
|
22810
23306
|
return await db
|
|
22811
23307
|
.insert(todo)
|
|
@@ -22816,9 +23312,9 @@ export const todoRouter = {
|
|
|
22816
23312
|
|
|
22817
23313
|
toggle: publicProcedure
|
|
22818
23314
|
.input(z.object({ id: z.number(), completed: z.boolean() }))
|
|
22819
|
-
.handler(async ({ input }) => {
|
|
23315
|
+
.handler(async ({ input{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}, context{{/if}} }) => {
|
|
22820
23316
|
{{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
22821
|
-
const db = createDb();
|
|
23317
|
+
const db = createDb({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}context.env{{/if}});
|
|
22822
23318
|
{{/if}}
|
|
22823
23319
|
return await db
|
|
22824
23320
|
.update(todo)
|
|
@@ -22828,9 +23324,9 @@ export const todoRouter = {
|
|
|
22828
23324
|
|
|
22829
23325
|
delete: publicProcedure
|
|
22830
23326
|
.input(z.object({ id: z.number() }))
|
|
22831
|
-
.handler(async ({ input }) => {
|
|
23327
|
+
.handler(async ({ input{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}, context{{/if}} }) => {
|
|
22832
23328
|
{{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
22833
|
-
const db = createDb();
|
|
23329
|
+
const db = createDb({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}context.env{{/if}});
|
|
22834
23330
|
{{/if}}
|
|
22835
23331
|
return await db.delete(todo).where(eq(todo.id, input.id));
|
|
22836
23332
|
}),
|
|
@@ -23016,9 +23512,9 @@ import prisma from "@{{projectName}}/db";
|
|
|
23016
23512
|
import { publicProcedure } from "../index";
|
|
23017
23513
|
|
|
23018
23514
|
export const todoRouter = {
|
|
23019
|
-
getAll: publicProcedure.handler(async () => {
|
|
23515
|
+
getAll: publicProcedure.handler(async ({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}{ context }{{/if}}) => {
|
|
23020
23516
|
{{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
23021
|
-
const prisma = createPrismaClient();
|
|
23517
|
+
const prisma = createPrismaClient({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}context.env{{/if}});
|
|
23022
23518
|
{{/if}}
|
|
23023
23519
|
return await prisma.todo.findMany({
|
|
23024
23520
|
orderBy: {
|
|
@@ -23029,9 +23525,9 @@ export const todoRouter = {
|
|
|
23029
23525
|
|
|
23030
23526
|
create: publicProcedure
|
|
23031
23527
|
.input(z.object({ text: z.string().min(1) }))
|
|
23032
|
-
.handler(async ({ input }) => {
|
|
23528
|
+
.handler(async ({ input{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}, context{{/if}} }) => {
|
|
23033
23529
|
{{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
23034
|
-
const prisma = createPrismaClient();
|
|
23530
|
+
const prisma = createPrismaClient({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}context.env{{/if}});
|
|
23035
23531
|
{{/if}}
|
|
23036
23532
|
return await prisma.todo.create({
|
|
23037
23533
|
data: {
|
|
@@ -23046,9 +23542,9 @@ export const todoRouter = {
|
|
|
23046
23542
|
{{else}}
|
|
23047
23543
|
.input(z.object({ id: z.number(), completed: z.boolean() }))
|
|
23048
23544
|
{{/if}}
|
|
23049
|
-
.handler(async ({ input }) => {
|
|
23545
|
+
.handler(async ({ input{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}, context{{/if}} }) => {
|
|
23050
23546
|
{{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
23051
|
-
const prisma = createPrismaClient();
|
|
23547
|
+
const prisma = createPrismaClient({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}context.env{{/if}});
|
|
23052
23548
|
{{/if}}
|
|
23053
23549
|
return await prisma.todo.update({
|
|
23054
23550
|
where: { id: input.id },
|
|
@@ -23062,9 +23558,9 @@ export const todoRouter = {
|
|
|
23062
23558
|
{{else}}
|
|
23063
23559
|
.input(z.object({ id: z.number() }))
|
|
23064
23560
|
{{/if}}
|
|
23065
|
-
.handler(async ({ input }) => {
|
|
23561
|
+
.handler(async ({ input{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}, context{{/if}} }) => {
|
|
23066
23562
|
{{#if (or (eq runtime "workers") (eq serverDeploy "cloudflare") (and (eq backend "self") (eq webDeploy "cloudflare")))}}
|
|
23067
|
-
const prisma = createPrismaClient();
|
|
23563
|
+
const prisma = createPrismaClient({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}context.env{{/if}});
|
|
23068
23564
|
{{/if}}
|
|
23069
23565
|
return await prisma.todo.delete({
|
|
23070
23566
|
where: { id: input.id },
|
|
@@ -28912,7 +29408,7 @@ export default defineNuxtConfig({
|
|
|
28912
29408
|
{{else if (and (ne backend "self") (ne backend "none"))}}
|
|
28913
29409
|
runtimeConfig: {
|
|
28914
29410
|
public: {
|
|
28915
|
-
serverUrl: process.env.NUXT_PUBLIC_SERVER_URL,
|
|
29411
|
+
serverUrl: process.env.NUXT_PUBLIC_SERVER_URL ?? "",
|
|
28916
29412
|
}
|
|
28917
29413
|
},
|
|
28918
29414
|
{{/if}}
|
|
@@ -28931,7 +29427,7 @@ export default defineNuxtConfig({
|
|
|
28931
29427
|
},
|
|
28932
29428
|
"dependencies": {
|
|
28933
29429
|
"@nuxt/ui": "^4.5.1",
|
|
28934
|
-
"nuxt": "^4.4.
|
|
29430
|
+
"nuxt": "^4.4.4"
|
|
28935
29431
|
},
|
|
28936
29432
|
"devDependencies": {
|
|
28937
29433
|
"tailwindcss": "^4.2.1",
|
|
@@ -28984,7 +29480,7 @@ const nextConfig: NextConfig = {
|
|
|
28984
29480
|
{{#if (includes examples "ai")}}
|
|
28985
29481
|
transpilePackages: ["shiki"],
|
|
28986
29482
|
{{/if}}
|
|
28987
|
-
{{#if (eq dbSetup "turso")}}
|
|
29483
|
+
{{#if (and (eq backend "self") (eq dbSetup "turso"))}}
|
|
28988
29484
|
serverExternalPackages: ["libsql", "@libsql/client"],
|
|
28989
29485
|
{{/if}}
|
|
28990
29486
|
};
|
|
@@ -31507,13 +32003,13 @@ vite.config.ts.timestamp-*
|
|
|
31507
32003
|
},
|
|
31508
32004
|
"devDependencies": {
|
|
31509
32005
|
"@sveltejs/adapter-auto": "^7.0.1",
|
|
31510
|
-
"@sveltejs/kit": "^2.
|
|
32006
|
+
"@sveltejs/kit": "^2.58.0",
|
|
31511
32007
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
31512
|
-
"@tailwindcss/vite": "^4.2.
|
|
31513
|
-
"svelte": "^5.55.
|
|
32008
|
+
"@tailwindcss/vite": "^4.2.4",
|
|
32009
|
+
"svelte": "^5.55.5",
|
|
31514
32010
|
"svelte-check": "^4.4.6",
|
|
31515
|
-
"tailwindcss": "^4.2.
|
|
31516
|
-
"vite": "^8.0.
|
|
32011
|
+
"tailwindcss": "^4.2.4",
|
|
32012
|
+
"vite": "^8.0.10"
|
|
31517
32013
|
},
|
|
31518
32014
|
"dependencies": {}
|
|
31519
32015
|
}
|
|
@@ -31524,16 +32020,36 @@ body {
|
|
|
31524
32020
|
@apply bg-neutral-950 text-neutral-100;
|
|
31525
32021
|
}
|
|
31526
32022
|
`],
|
|
31527
|
-
["frontend/svelte/src/app.d.ts",
|
|
32023
|
+
["frontend/svelte/src/app.d.ts.hbs", `{{#if (eq webDeploy "cloudflare")}}
|
|
32024
|
+
/// <reference path="../../../packages/env/env.d.ts" />
|
|
32025
|
+
{{/if}}
|
|
32026
|
+
{{#if (and (eq backend "self") (eq api "orpc"))}}
|
|
32027
|
+
import type { AppRouterClient } from "@{{projectName}}/api/routers/index";
|
|
32028
|
+
|
|
32029
|
+
{{/if}}
|
|
32030
|
+
// See https://svelte.dev/docs/kit/types#app.d.ts
|
|
31528
32031
|
// for information about these interfaces
|
|
31529
32032
|
declare global {
|
|
31530
|
-
|
|
31531
|
-
|
|
31532
|
-
|
|
31533
|
-
|
|
31534
|
-
|
|
31535
|
-
|
|
31536
|
-
|
|
32033
|
+
{{#if (and (eq backend "self") (eq api "orpc"))}}
|
|
32034
|
+
var $client: AppRouterClient | undefined;
|
|
32035
|
+
|
|
32036
|
+
{{/if}}
|
|
32037
|
+
namespace App {
|
|
32038
|
+
// interface Error {}
|
|
32039
|
+
// interface Locals {}
|
|
32040
|
+
// interface PageData {}
|
|
32041
|
+
// interface PageState {}
|
|
32042
|
+
{{#if (eq webDeploy "cloudflare")}}
|
|
32043
|
+
interface Platform {
|
|
32044
|
+
env: Env;
|
|
32045
|
+
ctx: ExecutionContext;
|
|
32046
|
+
caches: CacheStorage;
|
|
32047
|
+
cf: IncomingRequestCfProperties;
|
|
32048
|
+
}
|
|
32049
|
+
{{else}}
|
|
32050
|
+
// interface Platform {}
|
|
32051
|
+
{{/if}}
|
|
32052
|
+
}
|
|
31537
32053
|
}
|
|
31538
32054
|
|
|
31539
32055
|
export {};
|
|
@@ -31556,32 +32072,22 @@ export {};
|
|
|
31556
32072
|
{{#if (eq auth "better-auth")}}
|
|
31557
32073
|
import UserMenu from './UserMenu.svelte';
|
|
31558
32074
|
{{/if}}
|
|
31559
|
-
const links = [
|
|
31560
|
-
{ to: "/", label: "Home" },
|
|
31561
|
-
{{#if (eq auth "better-auth")}}
|
|
31562
|
-
{ to: "/dashboard", label: "Dashboard" },
|
|
31563
|
-
{{/if}}
|
|
31564
|
-
{{#if (includes examples "todo")}}
|
|
31565
|
-
{ to: "/todos", label: "Todos" },
|
|
31566
|
-
{{/if}}
|
|
31567
|
-
{{#if (includes examples "ai")}}
|
|
31568
|
-
{ to: "/ai", label: "AI Chat" },
|
|
31569
|
-
{{/if}}
|
|
31570
|
-
];
|
|
31571
32075
|
|
|
31572
32076
|
<\/script>
|
|
31573
32077
|
|
|
31574
32078
|
<div>
|
|
31575
32079
|
<div class="flex flex-row items-center justify-between px-4 py-2 md:px-6">
|
|
31576
32080
|
<nav class="flex gap-4 text-lg">
|
|
31577
|
-
|
|
31578
|
-
|
|
31579
|
-
|
|
31580
|
-
|
|
31581
|
-
|
|
31582
|
-
|
|
31583
|
-
|
|
31584
|
-
|
|
32081
|
+
<a href="/" class="hover:text-neutral-400 transition-colors">Home</a>
|
|
32082
|
+
{{#if (eq auth "better-auth")}}
|
|
32083
|
+
<a href="/dashboard" class="hover:text-neutral-400 transition-colors">Dashboard</a>
|
|
32084
|
+
{{/if}}
|
|
32085
|
+
{{#if (includes examples "todo")}}
|
|
32086
|
+
<a href="/todos" class="hover:text-neutral-400 transition-colors">Todos</a>
|
|
32087
|
+
{{/if}}
|
|
32088
|
+
{{#if (includes examples "ai")}}
|
|
32089
|
+
<a href="/ai" class="hover:text-neutral-400 transition-colors">AI Chat</a>
|
|
32090
|
+
{{/if}}
|
|
31585
32091
|
</nav>
|
|
31586
32092
|
<div class="flex items-center gap-2">
|
|
31587
32093
|
{{#if (eq auth "better-auth")}}
|
|
@@ -31744,7 +32250,11 @@ const TITLE_TEXT = \`
|
|
|
31744
32250
|
{{/if}}
|
|
31745
32251
|
`],
|
|
31746
32252
|
["frontend/svelte/static/favicon.png", `[Binary file]`],
|
|
31747
|
-
["frontend/svelte/svelte.config.js.hbs", `
|
|
32253
|
+
["frontend/svelte/svelte.config.js.hbs", `{{#if (eq webDeploy "cloudflare")}}
|
|
32254
|
+
import alchemy from 'alchemy/cloudflare/sveltekit';
|
|
32255
|
+
{{else}}
|
|
32256
|
+
import adapter from '@sveltejs/adapter-auto';
|
|
32257
|
+
{{/if}}
|
|
31748
32258
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
31749
32259
|
|
|
31750
32260
|
/** @type {import('@sveltejs/kit').Config} */
|
|
@@ -31754,10 +32264,15 @@ const config = {
|
|
|
31754
32264
|
preprocess: vitePreprocess(),
|
|
31755
32265
|
|
|
31756
32266
|
kit: {
|
|
32267
|
+
{{#if (eq webDeploy "cloudflare")}}
|
|
32268
|
+
// Alchemy's adapter wraps SvelteKit's Cloudflare adapter for local platform.env and Worker builds.
|
|
32269
|
+
adapter: alchemy()
|
|
32270
|
+
{{else}}
|
|
31757
32271
|
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
|
|
31758
32272
|
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
|
|
31759
32273
|
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
|
|
31760
32274
|
adapter: adapter()
|
|
32275
|
+
{{/if}}
|
|
31761
32276
|
}
|
|
31762
32277
|
};
|
|
31763
32278
|
|
|
@@ -31774,7 +32289,8 @@ export default config;
|
|
|
31774
32289
|
"skipLibCheck": true,
|
|
31775
32290
|
"sourceMap": true,
|
|
31776
32291
|
"strict": true,
|
|
31777
|
-
"moduleResolution": "bundler"
|
|
32292
|
+
"moduleResolution": "bundler"{{#if (eq webDeploy "cloudflare")}},
|
|
32293
|
+
"types": ["@cloudflare/workers-types"]{{/if}}
|
|
31778
32294
|
}
|
|
31779
32295
|
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
|
|
31780
32296
|
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
|
|
@@ -31837,6 +32353,24 @@ export default defineConfig({
|
|
|
31837
32353
|
"type": "module",
|
|
31838
32354
|
"exports": {}
|
|
31839
32355
|
}`],
|
|
32356
|
+
["packages/env/src/cloudflare-local.ts.hbs", `import { config } from "dotenv";
|
|
32357
|
+
import { fileURLToPath } from "node:url";
|
|
32358
|
+
|
|
32359
|
+
config({ path: fileURLToPath(new URL("../../../.env", import.meta.url)) });
|
|
32360
|
+
config();
|
|
32361
|
+
|
|
32362
|
+
const runtimeEnv = typeof process === "undefined" ? {} : process.env;
|
|
32363
|
+
|
|
32364
|
+
export const env = new Proxy({} as Env, {
|
|
32365
|
+
get(_target, prop) {
|
|
32366
|
+
if (typeof prop !== "string") {
|
|
32367
|
+
return undefined;
|
|
32368
|
+
}
|
|
32369
|
+
|
|
32370
|
+
return runtimeEnv[prop];
|
|
32371
|
+
},
|
|
32372
|
+
});
|
|
32373
|
+
`],
|
|
31840
32374
|
["packages/env/src/native.ts.hbs", `import { createEnv } from "@t3-oss/env-core";
|
|
31841
32375
|
import { z } from "zod";
|
|
31842
32376
|
|
|
@@ -31859,7 +32393,8 @@ export const env = createEnv({
|
|
|
31859
32393
|
emptyStringAsUndefined: true,
|
|
31860
32394
|
});
|
|
31861
32395
|
`],
|
|
31862
|
-
["packages/env/src/server.ts.hbs", `{{#if (eq serverDeploy "cloudflare")}}
|
|
32396
|
+
["packages/env/src/server.ts.hbs", `{{#if (and (eq serverDeploy "cloudflare") (or (ne backend "self") (ne webDeploy "cloudflare")))}}
|
|
32397
|
+
/// <reference types="@cloudflare/workers-types" />
|
|
31863
32398
|
/// <reference path="../env.d.ts" />
|
|
31864
32399
|
// For Cloudflare Workers, env is accessed via cloudflare:workers module
|
|
31865
32400
|
// Types are defined in env.d.ts based on your alchemy.run.ts bindings
|
|
@@ -31869,6 +32404,10 @@ export { env } from "cloudflare:workers";
|
|
|
31869
32404
|
import { getCloudflareContext } from "@opennextjs/cloudflare";
|
|
31870
32405
|
|
|
31871
32406
|
function getNodeEnvValue(key: string) {
|
|
32407
|
+
if (key === "DB") {
|
|
32408
|
+
return undefined;
|
|
32409
|
+
}
|
|
32410
|
+
|
|
31872
32411
|
return process.env[key];
|
|
31873
32412
|
}
|
|
31874
32413
|
|
|
@@ -31921,7 +32460,27 @@ export async function getEnvAsync() {
|
|
|
31921
32460
|
}
|
|
31922
32461
|
|
|
31923
32462
|
export const env = createEnvProxy(resolveEnvValue);
|
|
32463
|
+
{{else if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
32464
|
+
/// <reference path="../env.d.ts" />
|
|
32465
|
+
import { config } from "dotenv";
|
|
32466
|
+
import { fileURLToPath } from "node:url";
|
|
32467
|
+
|
|
32468
|
+
config({ path: fileURLToPath(new URL("../../../.env", import.meta.url)) });
|
|
32469
|
+
config();
|
|
32470
|
+
|
|
32471
|
+
const runtimeEnv = typeof process === "undefined" ? {} : process.env;
|
|
32472
|
+
|
|
32473
|
+
export const env = new Proxy({} as Env, {
|
|
32474
|
+
get(_target, prop) {
|
|
32475
|
+
if (typeof prop !== "string") {
|
|
32476
|
+
return undefined;
|
|
32477
|
+
}
|
|
32478
|
+
|
|
32479
|
+
return runtimeEnv[prop];
|
|
32480
|
+
},
|
|
32481
|
+
});
|
|
31924
32482
|
{{else if (and (eq backend "self") (eq webDeploy "cloudflare"))}}
|
|
32483
|
+
/// <reference types="@cloudflare/workers-types" />
|
|
31925
32484
|
/// <reference path="../env.d.ts" />
|
|
31926
32485
|
// For Cloudflare Workers, env is accessed via cloudflare:workers module
|
|
31927
32486
|
// Types are defined in env.d.ts based on your alchemy.run.ts bindings
|
|
@@ -32265,7 +32824,39 @@ export const web = await SvelteKit("web", {
|
|
|
32265
32824
|
{{else if (ne backend "self")}}
|
|
32266
32825
|
PUBLIC_SERVER_URL: alchemy.env.PUBLIC_SERVER_URL!,
|
|
32267
32826
|
{{/if}}
|
|
32268
|
-
|
|
32827
|
+
{{#if (eq backend "self")}}
|
|
32828
|
+
{{#if (eq dbSetup "d1")}}
|
|
32829
|
+
DB: db,
|
|
32830
|
+
{{else if (ne database "none")}}
|
|
32831
|
+
DATABASE_URL: alchemy.secret.env.DATABASE_URL!,
|
|
32832
|
+
{{/if}}
|
|
32833
|
+
CORS_ORIGIN: alchemy.env.CORS_ORIGIN!,
|
|
32834
|
+
{{#if (eq auth "better-auth")}}
|
|
32835
|
+
BETTER_AUTH_SECRET: alchemy.secret.env.BETTER_AUTH_SECRET!,
|
|
32836
|
+
BETTER_AUTH_URL: alchemy.env.BETTER_AUTH_URL!,
|
|
32837
|
+
{{/if}}
|
|
32838
|
+
{{#if (and (includes examples "ai") (ne backend "convex"))}}
|
|
32839
|
+
GOOGLE_GENERATIVE_AI_API_KEY: alchemy.secret.env.GOOGLE_GENERATIVE_AI_API_KEY!,
|
|
32840
|
+
{{/if}}
|
|
32841
|
+
{{#if (eq payments "polar")}}
|
|
32842
|
+
POLAR_ACCESS_TOKEN: alchemy.secret.env.POLAR_ACCESS_TOKEN!,
|
|
32843
|
+
POLAR_SUCCESS_URL: alchemy.env.POLAR_SUCCESS_URL!,
|
|
32844
|
+
{{/if}}
|
|
32845
|
+
{{#if (eq dbSetup "turso")}}
|
|
32846
|
+
DATABASE_AUTH_TOKEN: alchemy.secret.env.DATABASE_AUTH_TOKEN!,
|
|
32847
|
+
{{/if}}
|
|
32848
|
+
{{#if (eq database "mysql")}}
|
|
32849
|
+
{{#if (eq orm "drizzle")}}
|
|
32850
|
+
DATABASE_HOST: alchemy.env.DATABASE_HOST!,
|
|
32851
|
+
DATABASE_USERNAME: alchemy.env.DATABASE_USERNAME!,
|
|
32852
|
+
DATABASE_PASSWORD: alchemy.secret.env.DATABASE_PASSWORD!,
|
|
32853
|
+
{{/if}}
|
|
32854
|
+
{{/if}}
|
|
32855
|
+
{{/if}}
|
|
32856
|
+
},
|
|
32857
|
+
dev: {
|
|
32858
|
+
domain: "localhost:5173",
|
|
32859
|
+
},
|
|
32269
32860
|
});
|
|
32270
32861
|
{{else if (includes frontend "tanstack-start")}}
|
|
32271
32862
|
export const web = await TanStackStart("web", {
|
|
@@ -33257,12 +33848,25 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
33257
33848
|
}
|
|
33258
33849
|
`],
|
|
33259
33850
|
["payments/polar/server/base/src/lib/payments.ts.hbs", `import { Polar } from "@polar-sh/sdk";
|
|
33851
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
33852
|
+
import type {} from "@{{projectName}}/env/server";
|
|
33853
|
+
{{else}}
|
|
33260
33854
|
import { env } from "@{{projectName}}/env/server";
|
|
33855
|
+
{{/if}}
|
|
33261
33856
|
|
|
33857
|
+
{{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}
|
|
33858
|
+
export function createPolarClient({{#if (and (eq backend "self") (eq webDeploy "cloudflare") (includes frontend "svelte"))}}env: Env{{/if}}) {
|
|
33859
|
+
return new Polar({
|
|
33860
|
+
accessToken: env.POLAR_ACCESS_TOKEN,
|
|
33861
|
+
server: "sandbox",
|
|
33862
|
+
});
|
|
33863
|
+
}
|
|
33864
|
+
{{else}}
|
|
33262
33865
|
export const polarClient = new Polar({
|
|
33263
33866
|
accessToken: env.POLAR_ACCESS_TOKEN,
|
|
33264
33867
|
server: "sandbox",
|
|
33265
33868
|
});
|
|
33869
|
+
{{/if}}
|
|
33266
33870
|
`],
|
|
33267
33871
|
["payments/polar/web/nuxt/app/pages/success.vue.hbs", `<script setup lang="ts">
|
|
33268
33872
|
const route = useRoute()
|
|
@@ -33400,7 +34004,7 @@ function SuccessPage() {
|
|
|
33400
34004
|
</div>
|
|
33401
34005
|
`]
|
|
33402
34006
|
]);
|
|
33403
|
-
const TEMPLATE_COUNT =
|
|
34007
|
+
const TEMPLATE_COUNT = 467;
|
|
33404
34008
|
//#endregion
|
|
33405
34009
|
export { EMBEDDED_TEMPLATES, GeneratorError, Handlebars, TEMPLATE_COUNT, VirtualFileSystem, dependencyVersionMap, generate, generateReproducibleCommand, isBinaryFile, processAddonTemplates, processAddonsDeps, processFileContent, processTemplateString, transformFilename, writeBtsConfigToVfs };
|
|
33406
34010
|
|