covara 0.9.2 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +8 -13
  2. package/dist/auth/api-keys.d.ts +17 -0
  3. package/dist/auth/api-keys.d.ts.map +1 -1
  4. package/dist/auth/api-keys.js +75 -0
  5. package/dist/auth/api-keys.js.map +1 -1
  6. package/dist/auth/config.d.ts +7 -3
  7. package/dist/auth/config.d.ts.map +1 -1
  8. package/dist/auth/config.js +8 -5
  9. package/dist/auth/config.js.map +1 -1
  10. package/dist/auth/index.d.ts +4 -4
  11. package/dist/auth/index.d.ts.map +1 -1
  12. package/dist/auth/index.js +3 -3
  13. package/dist/auth/index.js.map +1 -1
  14. package/dist/auth/stores/drizzle.d.ts +6 -2
  15. package/dist/auth/stores/drizzle.d.ts.map +1 -1
  16. package/dist/auth/stores/drizzle.js +68 -70
  17. package/dist/auth/stores/drizzle.js.map +1 -1
  18. package/dist/auth/stores/index.d.ts +4 -2
  19. package/dist/auth/stores/index.d.ts.map +1 -1
  20. package/dist/auth/stores/index.js +3 -1
  21. package/dist/auth/stores/index.js.map +1 -1
  22. package/dist/auth/stores/kv.d.ts +31 -0
  23. package/dist/auth/stores/kv.d.ts.map +1 -0
  24. package/dist/auth/stores/{redis.js → kv.js} +8 -4
  25. package/dist/auth/stores/kv.js.map +1 -0
  26. package/dist/auth/verification.d.ts +12 -0
  27. package/dist/auth/verification.d.ts.map +1 -1
  28. package/dist/auth/verification.js +0 -0
  29. package/dist/auth/verification.js.map +1 -1
  30. package/dist/cli/commands/env.d.ts.map +1 -1
  31. package/dist/cli/commands/env.js +1 -13
  32. package/dist/cli/commands/env.js.map +1 -1
  33. package/dist/cli/dotenv.d.ts +3 -0
  34. package/dist/cli/dotenv.d.ts.map +1 -0
  35. package/dist/cli/dotenv.js +34 -0
  36. package/dist/cli/dotenv.js.map +1 -0
  37. package/dist/cli/index.d.ts.map +1 -1
  38. package/dist/cli/index.js +13 -2
  39. package/dist/cli/index.js.map +1 -1
  40. package/dist/cli/options.d.ts +3 -0
  41. package/dist/cli/options.d.ts.map +1 -1
  42. package/dist/cli/options.js +1 -0
  43. package/dist/cli/options.js.map +1 -1
  44. package/dist/cli/templates/configs.d.ts.map +1 -1
  45. package/dist/cli/templates/configs.js +15 -1
  46. package/dist/cli/templates/configs.js.map +1 -1
  47. package/dist/cli/templates/deploy.d.ts +1 -1
  48. package/dist/cli/templates/deploy.d.ts.map +1 -1
  49. package/dist/cli/templates/deploy.js +10 -2
  50. package/dist/cli/templates/deploy.js.map +1 -1
  51. package/dist/cli/templates/frontend.d.ts +11 -0
  52. package/dist/cli/templates/frontend.d.ts.map +1 -0
  53. package/dist/cli/templates/frontend.js +254 -0
  54. package/dist/cli/templates/frontend.js.map +1 -0
  55. package/dist/cli/templates/index.d.ts +1 -0
  56. package/dist/cli/templates/index.d.ts.map +1 -1
  57. package/dist/cli/templates/index.js +6 -1
  58. package/dist/cli/templates/index.js.map +1 -1
  59. package/dist/cli/templates/package-json.d.ts.map +1 -1
  60. package/dist/cli/templates/package-json.js +66 -64
  61. package/dist/cli/templates/package-json.js.map +1 -1
  62. package/dist/cli/templates/source.d.ts.map +1 -1
  63. package/dist/cli/templates/source.js +79 -1
  64. package/dist/cli/templates/source.js.map +1 -1
  65. package/dist/cli/templates/versions.d.ts +24 -0
  66. package/dist/cli/templates/versions.d.ts.map +1 -0
  67. package/dist/cli/templates/versions.js +53 -0
  68. package/dist/cli/templates/versions.js.map +1 -0
  69. package/dist/db/index.d.ts +2 -2
  70. package/dist/db/index.d.ts.map +1 -1
  71. package/dist/db/index.js +1 -1
  72. package/dist/db/index.js.map +1 -1
  73. package/dist/db/internal-schema.d.ts +39 -0
  74. package/dist/db/internal-schema.d.ts.map +1 -1
  75. package/dist/db/internal-schema.js +97 -0
  76. package/dist/db/internal-schema.js.map +1 -1
  77. package/dist/db/migrate.d.ts +11 -2
  78. package/dist/db/migrate.d.ts.map +1 -1
  79. package/dist/db/migrate.js +166 -31
  80. package/dist/db/migrate.js.map +1 -1
  81. package/dist/index.d.ts +6 -4
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +5 -3
  84. package/dist/index.js.map +1 -1
  85. package/dist/kv/index.d.ts +1 -1
  86. package/dist/kv/index.d.ts.map +1 -1
  87. package/dist/kv/index.js +1 -1
  88. package/dist/kv/index.js.map +1 -1
  89. package/dist/kv/types.d.ts +1 -0
  90. package/dist/kv/types.d.ts.map +1 -1
  91. package/dist/kv/types.js +3 -0
  92. package/dist/kv/types.js.map +1 -1
  93. package/dist/middleware/observability.d.ts +1 -0
  94. package/dist/middleware/observability.d.ts.map +1 -1
  95. package/dist/middleware/observability.js +41 -27
  96. package/dist/middleware/observability.js.map +1 -1
  97. package/dist/observability/index.d.ts +3 -0
  98. package/dist/observability/index.d.ts.map +1 -0
  99. package/dist/observability/index.js +2 -0
  100. package/dist/observability/index.js.map +1 -0
  101. package/dist/observability/log-adapter.d.ts +50 -0
  102. package/dist/observability/log-adapter.d.ts.map +1 -0
  103. package/dist/observability/log-adapter.js +174 -0
  104. package/dist/observability/log-adapter.js.map +1 -0
  105. package/dist/server/app.d.ts +3 -0
  106. package/dist/server/app.d.ts.map +1 -1
  107. package/dist/server/app.js +1 -0
  108. package/dist/server/app.js.map +1 -1
  109. package/dist/ui/admin-auth.d.ts +3 -0
  110. package/dist/ui/admin-auth.d.ts.map +1 -1
  111. package/dist/ui/admin-auth.js +56 -26
  112. package/dist/ui/admin-auth.js.map +1 -1
  113. package/dist/ui/index.d.ts +2 -2
  114. package/dist/ui/index.d.ts.map +1 -1
  115. package/dist/ui/index.js +2 -2
  116. package/dist/ui/index.js.map +1 -1
  117. package/dist/ui/middleware.d.ts +9 -1
  118. package/dist/ui/middleware.d.ts.map +1 -1
  119. package/dist/ui/middleware.js +44 -24
  120. package/dist/ui/middleware.js.map +1 -1
  121. package/package.json +2 -2
  122. package/dist/auth/stores/redis.d.ts +0 -25
  123. package/dist/auth/stores/redis.d.ts.map +0 -1
  124. package/dist/auth/stores/redis.js.map +0 -1
@@ -0,0 +1,254 @@
1
+ // The dev API/admin origin the standalone `vite` server proxies to. In the node
2
+ // template the single-process dev server embeds Vite (no proxy needed), but this
3
+ // keeps `vite` usable on its own; cloudflare dev runs `wrangler dev` on :8787.
4
+ const proxyTarget = (options) => options.template === "cloudflare"
5
+ ? "http://localhost:8787"
6
+ : "http://localhost:3000";
7
+ export const renderViteConfig = (options) => `import { defineConfig } from "vite";
8
+ import react from "@vitejs/plugin-react";
9
+
10
+ // The node template embeds this Vite server in-process during \`covara dev\`
11
+ // (HMR + API on one origin, no proxy). The proxy below only applies if you run
12
+ // \`vite\` standalone.
13
+ export default defineConfig({
14
+ root: __dirname,
15
+ plugins: [react()],
16
+ build: {
17
+ outDir: "../public",
18
+ emptyOutDir: true,
19
+ },
20
+ server: {
21
+ proxy: {
22
+ "/api": "${proxyTarget(options)}",
23
+ "/__covara": "${proxyTarget(options)}",
24
+ },
25
+ },
26
+ });
27
+ `;
28
+ export const FRONTEND_TSCONFIG = `{
29
+ "compilerOptions": {
30
+ "target": "ES2020",
31
+ "useDefineForClassFields": true,
32
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
33
+ "module": "ESNext",
34
+ "skipLibCheck": true,
35
+ "moduleResolution": "bundler",
36
+ "resolveJsonModule": true,
37
+ "isolatedModules": true,
38
+ "noEmit": true,
39
+ "jsx": "react-jsx",
40
+ "strict": true
41
+ },
42
+ "include": ["src"]
43
+ }
44
+ `;
45
+ export const renderFrontendIndexHtml = (options) => `<!DOCTYPE html>
46
+ <html lang="en">
47
+ <head>
48
+ <meta charset="UTF-8" />
49
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
50
+ <title>${options.name}</title>
51
+ </head>
52
+ <body>
53
+ <div id="root"></div>
54
+ <script type="module" src="/src/main.tsx"></script>
55
+ </body>
56
+ </html>
57
+ `;
58
+ export const FRONTEND_MAIN = `import React from "react";
59
+ import ReactDOM from "react-dom/client";
60
+ import { App } from "./App";
61
+ import "./styles.css";
62
+
63
+ ReactDOM.createRoot(document.getElementById("root")!).render(
64
+ <React.StrictMode>
65
+ <App />
66
+ </React.StrictMode>
67
+ );
68
+ `;
69
+ export const FRONTEND_APP = `import { useState } from "react";
70
+ import { getOrCreateClient } from "covara/client";
71
+ import { useLiveList } from "covara/client/react";
72
+
73
+ // A live, real-time view of the scaffolded \`todos\` resource. \`useLiveList\`
74
+ // opens an SSE subscription, so inserts/updates/deletes (from this tab or any
75
+ // other client) stream in automatically.
76
+ //
77
+ // This uses the generic typed hook with a hand-written Todo interface so it
78
+ // compiles on the first run with no codegen. Run \`npm run types\` against the
79
+ // dev server to generate \`src/generated/api-types.ts\` and switch to the fully
80
+ // typed client (createTypedClient) when you want end-to-end inferred types.
81
+ interface Todo {
82
+ id: string;
83
+ title: string;
84
+ completed: boolean;
85
+ createdAt: string;
86
+ }
87
+
88
+ const client = getOrCreateClient({
89
+ baseUrl: location.origin,
90
+ credentials: "include",
91
+ });
92
+
93
+ export function App() {
94
+ const { items, statusLabel, mutate } = useLiveList<Todo>("/api/todos", {
95
+ orderBy: "createdAt",
96
+ });
97
+ const [title, setTitle] = useState("");
98
+
99
+ const add = (e: React.FormEvent) => {
100
+ e.preventDefault();
101
+ const value = title.trim();
102
+ if (!value) return;
103
+ mutate.create({ title: value, completed: false });
104
+ setTitle("");
105
+ };
106
+
107
+ return (
108
+ <main className="app">
109
+ <header className="app__header">
110
+ <h1>Todos</h1>
111
+ <span className="app__status">{statusLabel}</span>
112
+ </header>
113
+
114
+ <form className="app__add" onSubmit={add}>
115
+ <input
116
+ value={title}
117
+ onChange={(e) => setTitle(e.target.value)}
118
+ placeholder="What needs doing?"
119
+ />
120
+ <button type="submit">Add</button>
121
+ </form>
122
+
123
+ <ul className="app__list">
124
+ {items.map((todo) => (
125
+ <li key={todo.id} className="todo">
126
+ <label>
127
+ <input
128
+ type="checkbox"
129
+ checked={todo.completed}
130
+ onChange={() =>
131
+ mutate.update(todo.id, { completed: !todo.completed })
132
+ }
133
+ />
134
+ <span className={todo.completed ? "todo--done" : ""}>
135
+ {todo.title}
136
+ </span>
137
+ </label>
138
+ <button onClick={() => mutate.delete(todo.id)}>✕</button>
139
+ </li>
140
+ ))}
141
+ {items.length === 0 && <li className="todo todo--empty">No todos yet</li>}
142
+ </ul>
143
+ </main>
144
+ );
145
+ }
146
+ `;
147
+ export const FRONTEND_STYLES = `:root {
148
+ color-scheme: light dark;
149
+ font-family: system-ui, -apple-system, sans-serif;
150
+ }
151
+ body {
152
+ margin: 0;
153
+ background: #f6f7f9;
154
+ }
155
+ .app {
156
+ max-width: 32rem;
157
+ margin: 3rem auto;
158
+ padding: 0 1rem;
159
+ }
160
+ .app__header {
161
+ display: flex;
162
+ align-items: baseline;
163
+ justify-content: space-between;
164
+ }
165
+ .app__status {
166
+ font-size: 0.8rem;
167
+ opacity: 0.6;
168
+ }
169
+ .app__add {
170
+ display: flex;
171
+ gap: 0.5rem;
172
+ margin: 1rem 0;
173
+ }
174
+ .app__add input {
175
+ flex: 1;
176
+ padding: 0.5rem 0.75rem;
177
+ border: 1px solid #ccc;
178
+ border-radius: 6px;
179
+ }
180
+ .app__add button {
181
+ padding: 0.5rem 1rem;
182
+ border: 0;
183
+ border-radius: 6px;
184
+ background: #2563eb;
185
+ color: white;
186
+ cursor: pointer;
187
+ }
188
+ .app__list {
189
+ list-style: none;
190
+ padding: 0;
191
+ margin: 0;
192
+ display: flex;
193
+ flex-direction: column;
194
+ gap: 0.5rem;
195
+ }
196
+ .todo {
197
+ display: flex;
198
+ align-items: center;
199
+ justify-content: space-between;
200
+ padding: 0.6rem 0.8rem;
201
+ background: white;
202
+ border-radius: 8px;
203
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
204
+ }
205
+ .todo label {
206
+ display: flex;
207
+ align-items: center;
208
+ gap: 0.6rem;
209
+ }
210
+ .todo--done {
211
+ text-decoration: line-through;
212
+ opacity: 0.5;
213
+ }
214
+ .todo--empty {
215
+ justify-content: center;
216
+ opacity: 0.5;
217
+ }
218
+ .todo button {
219
+ border: 0;
220
+ background: transparent;
221
+ cursor: pointer;
222
+ opacity: 0.5;
223
+ }
224
+ .todo button:hover {
225
+ opacity: 1;
226
+ }
227
+ `;
228
+ // A committed placeholder so the project type-checks before the first codegen.
229
+ // \`covara dev\` (and \`npm run types\`) regenerate this from the running server.
230
+ export const FRONTEND_API_TYPES_STUB = `// AUTO-GENERATED PLACEHOLDER — regenerated by \`covara dev\` / \`npm run types\`.
231
+ // Until then this stub lets the project type-check. The starter App.tsx uses the
232
+ // generic client and does not import from here; switch to createTypedClient once
233
+ // real types are generated.
234
+ export interface Todo {
235
+ id: string;
236
+ title: string;
237
+ completed: boolean;
238
+ createdAt: string;
239
+ }
240
+ `;
241
+ export const renderFrontendGitignore = () => `node_modules/
242
+ dist/
243
+ *.local
244
+ `;
245
+ export const buildFrontendFiles = (options) => ({
246
+ "frontend/vite.config.ts": renderViteConfig(options),
247
+ "frontend/tsconfig.json": FRONTEND_TSCONFIG,
248
+ "frontend/index.html": renderFrontendIndexHtml(options),
249
+ "frontend/src/main.tsx": FRONTEND_MAIN,
250
+ "frontend/src/App.tsx": FRONTEND_APP,
251
+ "frontend/src/styles.css": FRONTEND_STYLES,
252
+ "frontend/src/generated/api-types.ts": FRONTEND_API_TYPES_STUB,
253
+ });
254
+ //# sourceMappingURL=frontend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontend.js","sourceRoot":"","sources":["../../../src/cli/templates/frontend.ts"],"names":[],"mappings":"AAEA,gFAAgF;AAChF,iFAAiF;AACjF,+EAA+E;AAC/E,MAAM,WAAW,GAAG,CAAC,OAAwB,EAAU,EAAE,CACvD,OAAO,CAAC,QAAQ,KAAK,YAAY;IAC/B,CAAC,CAAC,uBAAuB;IACzB,CAAC,CAAC,uBAAuB,CAAC;AAE9B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAwB,EAAU,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  export { renderReadme } from "./readme.js";
7
7
  export { renderDockerfile, renderDockerignore, renderDockerCompose, renderCiWorkflow, } from "./deploy.js";
8
+ export { buildFrontendFiles } from "./frontend.js";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAmBrD,eAAO,MAAM,iBAAiB,GAC5B,SAAS,eAAe,KACvB,MAAM,CAAC,MAAM,EAAE,MAAM,CAwBvB,CAAC;AAEF,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAoBrD,eAAO,MAAM,iBAAiB,GAC5B,SAAS,eAAe,KACvB,MAAM,CAAC,MAAM,EAAE,MAAM,CA4BvB,CAAC;AAEF,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
@@ -3,6 +3,7 @@ import { NODE_TSCONFIG, CLOUDFLARE_TSCONFIG, renderDrizzleConfig, renderWrangler
3
3
  import { renderSchema, renderNodeIndex, renderWorker } from "./source.js";
4
4
  import { renderReadme } from "./readme.js";
5
5
  import { renderDockerfile, renderDockerignore, renderDockerCompose, renderCiWorkflow, } from "./deploy.js";
6
+ import { buildFrontendFiles } from "./frontend.js";
6
7
  export const buildProjectFiles = (options) => {
7
8
  const files = {
8
9
  "package.json": renderPackageJson(options),
@@ -16,7 +17,7 @@ export const buildProjectFiles = (options) => {
16
17
  if (options.template === "node") {
17
18
  files["tsconfig.json"] = NODE_TSCONFIG;
18
19
  files["src/index.ts"] = renderNodeIndex(options);
19
- files["Dockerfile"] = renderDockerfile();
20
+ files["Dockerfile"] = renderDockerfile(options);
20
21
  files[".dockerignore"] = renderDockerignore();
21
22
  files["docker-compose.yml"] = renderDockerCompose(options);
22
23
  }
@@ -25,6 +26,9 @@ export const buildProjectFiles = (options) => {
25
26
  files["src/worker.ts"] = renderWorker(options);
26
27
  files["wrangler.toml"] = renderWranglerToml(options);
27
28
  }
29
+ if (options.frontend === "react") {
30
+ Object.assign(files, buildFrontendFiles(options));
31
+ }
28
32
  return files;
29
33
  };
30
34
  export { NODE_TSCONFIG, CLOUDFLARE_TSCONFIG, renderDrizzleConfig, renderWranglerToml, renderGitignore, renderEnvExample, } from "./configs.js";
@@ -32,4 +36,5 @@ export { renderPackageJson } from "./package-json.js";
32
36
  export { renderSchema, renderNodeIndex, renderWorker } from "./source.js";
33
37
  export { renderReadme } from "./readme.js";
34
38
  export { renderDockerfile, renderDockerignore, renderDockerCompose, renderCiWorkflow, } from "./deploy.js";
39
+ export { buildFrontendFiles } from "./frontend.js";
35
40
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/templates/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,OAAwB,EACA,EAAE;IAC1B,MAAM,KAAK,GAA2B;QACpC,cAAc,EAAE,iBAAiB,CAAC,OAAO,CAAC;QAC1C,mBAAmB,EAAE,mBAAmB,CAAC,OAAO,CAAC;QACjD,eAAe,EAAE,YAAY,CAAC,OAAO,CAAC;QACtC,WAAW,EAAE,YAAY,CAAC,OAAO,CAAC;QAClC,YAAY,EAAE,eAAe,CAAC,OAAO,CAAC;QACtC,cAAc,EAAE,gBAAgB,CAAC,OAAO,CAAC;QACzC,0BAA0B,EAAE,gBAAgB,EAAE;KAC/C,CAAC;IAEF,IAAI,OAAO,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;QAChC,KAAK,CAAC,eAAe,CAAC,GAAG,aAAa,CAAC;QACvC,KAAK,CAAC,cAAc,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;QACjD,KAAK,CAAC,YAAY,CAAC,GAAG,gBAAgB,EAAE,CAAC;QACzC,KAAK,CAAC,eAAe,CAAC,GAAG,kBAAkB,EAAE,CAAC;QAC9C,KAAK,CA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,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/package-json.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAiDrD,eAAO,MAAM,iBAAiB,GAAI,SAAS,eAAe,KAAG,MA6D5D,CAAC"}
1
+ {"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/package-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD,eAAO,MAAM,iBAAiB,GAAI,SAAS,eAAe,KAAG,MA2G5D,CAAC"}
@@ -1,49 +1,4 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- // Pin the generated `covara` dependency to the version of the CLI doing the
5
- // scaffolding — that version is, by definition, published (it's the same package
6
- // the user invoked), so `npm install` always resolves. Avoids hand-syncing a
7
- // hardcoded range with package.json on every release. Falls back to the literal
8
- // below only if the CLI's own package.json can't be located.
9
- const FALLBACK_COVARA_VERSION = "^0.9.0";
10
- const resolveCovaraVersion = () => {
11
- try {
12
- let dir = path.dirname(fileURLToPath(import.meta.url));
13
- for (let i = 0; i < 10; i++) {
14
- const candidate = path.join(dir, "package.json");
15
- if (fs.existsSync(candidate)) {
16
- const pkg = JSON.parse(fs.readFileSync(candidate, "utf8"));
17
- if (pkg.name === "covara" && pkg.version) {
18
- return `^${pkg.version}`;
19
- }
20
- }
21
- const parent = path.dirname(dir);
22
- if (parent === dir)
23
- break;
24
- dir = parent;
25
- }
26
- }
27
- catch {
28
- // fall through to the fallback
29
- }
30
- return FALLBACK_COVARA_VERSION;
31
- };
32
- const VERSIONS = {
33
- covara: resolveCovaraVersion(),
34
- hono: "^4.12.25",
35
- drizzleOrm: "^0.45.1",
36
- zod: "^4.3.5",
37
- libsql: "^0.17.0",
38
- postgres: "^3.4.7",
39
- typescript: "^5.9.3",
40
- tsx: "^4.21.0",
41
- drizzleKit: "^0.31.8",
42
- typesNode: "^25.0.8",
43
- wrangler: "^4.0.0",
44
- workersTypes: "^4.0.0",
45
- vitest: "^3.0.0",
46
- };
1
+ import { VERSIONS } from "./versions.js";
47
2
  export const renderPackageJson = (options) => {
48
3
  const dependencies = {
49
4
  "covara": VERSIONS.covara,
@@ -56,6 +11,15 @@ export const renderPackageJson = (options) => {
56
11
  typescript: VERSIONS.typescript,
57
12
  };
58
13
  let scripts;
14
+ const react = options.frontend === "react";
15
+ if (react) {
16
+ dependencies.react = VERSIONS.react;
17
+ dependencies["react-dom"] = VERSIONS.reactDom;
18
+ devDependencies["@vitejs/plugin-react"] = VERSIONS.viteReactPlugin;
19
+ devDependencies["@types/react"] = VERSIONS.typesReact;
20
+ devDependencies["@types/react-dom"] = VERSIONS.typesReactDom;
21
+ devDependencies.vite = VERSIONS.vite;
22
+ }
59
23
  if (options.template === "node") {
60
24
  if (options.db === "sqlite") {
61
25
  dependencies["@libsql/client"] = VERSIONS.libsql;
@@ -65,16 +29,36 @@ export const renderPackageJson = (options) => {
65
29
  }
66
30
  devDependencies["@types/node"] = VERSIONS.typesNode;
67
31
  devDependencies.tsx = VERSIONS.tsx;
68
- scripts = {
69
- dev: "tsx watch src/index.ts",
70
- build: "tsc -p tsconfig.json",
71
- start: "node dist/index.js",
72
- test: "vitest run",
73
- lint: "tsc -p tsconfig.json --noEmit",
74
- "db:generate": "drizzle-kit generate",
75
- "db:push": "drizzle-kit push",
76
- };
77
32
  devDependencies.vitest = VERSIONS.vitest;
33
+ if (react) {
34
+ // The dev server embeds Vite in-process and routes /api + /__covara to
35
+ // the Hono app via @hono/node-server's request listener.
36
+ dependencies["@hono/node-server"] = VERSIONS.honoNodeServer;
37
+ scripts = {
38
+ // Single-process dev: Vite (HMR) + API + admin + live typegen + DB
39
+ // live-reload, no build step. NODE_ENV=development selects the Vite path;
40
+ // covara dev watches the schema and regenerates the typed client live.
41
+ dev: "NODE_ENV=development covara dev --types-out frontend/src/generated/api-types.ts",
42
+ build: "vite build --config frontend/vite.config.ts && tsc -p tsconfig.json",
43
+ start: "node dist/index.js",
44
+ test: "vitest run",
45
+ lint: "tsc -p tsconfig.json --noEmit",
46
+ types: "covara types --out frontend/src/generated/api-types.ts",
47
+ "db:generate": "drizzle-kit generate",
48
+ "db:push": "drizzle-kit push",
49
+ };
50
+ }
51
+ else {
52
+ scripts = {
53
+ dev: "tsx watch src/index.ts",
54
+ build: "tsc -p tsconfig.json",
55
+ start: "node dist/index.js",
56
+ test: "vitest run",
57
+ lint: "tsc -p tsconfig.json --noEmit",
58
+ "db:generate": "drizzle-kit generate",
59
+ "db:push": "drizzle-kit push",
60
+ };
61
+ }
78
62
  }
79
63
  else {
80
64
  if (options.db === "postgres") {
@@ -82,15 +66,33 @@ export const renderPackageJson = (options) => {
82
66
  }
83
67
  devDependencies["@cloudflare/workers-types"] = VERSIONS.workersTypes;
84
68
  devDependencies.wrangler = VERSIONS.wrangler;
85
- scripts = {
86
- dev: "wrangler dev",
87
- deploy: "wrangler deploy",
88
- typecheck: "tsc -p tsconfig.json",
89
- lint: "tsc -p tsconfig.json",
90
- "cf-typegen": "wrangler types",
91
- "db:generate": "drizzle-kit generate",
92
- "db:push": "drizzle-kit push",
93
- };
69
+ if (react) {
70
+ scripts = {
71
+ // wrangler serves the built SPA via [assets]; `dev:web` runs Vite (HMR)
72
+ // proxying /api + /__covara to `wrangler dev` on :8787.
73
+ dev: "vite build --config frontend/vite.config.ts && wrangler dev",
74
+ "dev:web": "vite --config frontend/vite.config.ts",
75
+ build: "vite build --config frontend/vite.config.ts",
76
+ deploy: "vite build --config frontend/vite.config.ts && wrangler deploy",
77
+ typecheck: "tsc -p tsconfig.json",
78
+ lint: "tsc -p tsconfig.json",
79
+ types: "covara types --out frontend/src/generated/api-types.ts",
80
+ "cf-typegen": "wrangler types",
81
+ "db:generate": "drizzle-kit generate",
82
+ "db:push": "drizzle-kit push",
83
+ };
84
+ }
85
+ else {
86
+ scripts = {
87
+ dev: "wrangler dev",
88
+ deploy: "wrangler deploy",
89
+ typecheck: "tsc -p tsconfig.json",
90
+ lint: "tsc -p tsconfig.json",
91
+ "cf-typegen": "wrangler types",
92
+ "db:generate": "drizzle-kit generate",
93
+ "db:push": "drizzle-kit push",
94
+ };
95
+ }
94
96
  }
95
97
  const pkg = {
96
98
  name: options.name,
@@ -1 +1 @@
1
- {"version":3,"file":"package-json.js","sourceRoot":"","sources":["../../../src/cli/templates/package-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,4EAA4E;AAC5E,iFAAiF;AACjF,6EAA6E;AAC7E,gFAAgF;AAChF,6DAA6D;AAC7D,MAAM,uBAAuB,GAAG,QAAQ,CAAC;AAEzC,MAAM,oBAAoB,GAAG,GAAW,EAAE;IACxC,IAAI,CAAC;QACH,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAA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EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,QAAQ;QACd,OAAO;QACP,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC;QACpC,eAAe,EAAE,QAAQ,CAAC,eAAe,CAAC;KAC3C,CAAC;IAEF,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,MAA8B,EAA0B,EAAE,CAC1E,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAC9D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,eAAO,MAAM,aAAa,scAYzB,CAAC;AAEF,eAAO,MAAM,eAAe,2XAU3B,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,SAAS,eAAe,KAAG,MACG,CAAC;AAE5D,eAAO,MAAM,iBAAiB,yiCA0B7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,klCA4B/B,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,SAAS,eAAe,KAAG,MACQ,CAAC;AAEpE,eAAO,MAAM,oBAAoB,0nCAwChC,CAAC;AAEF,eAAO,MAAM,0BAA0B,2vCA0CtC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,SAAS,eAAe,KAAG,MACqB,CAAC"}
1
+ {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,eAAO,MAAM,aAAa,scAYzB,CAAC;AAEF,eAAO,MAAM,eAAe,2XAU3B,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,SAAS,eAAe,KAAG,MACG,CAAC;AAE5D,eAAO,MAAM,iBAAiB,yiCA0B7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,klCA4B/B,CAAC;AAiFF,eAAO,MAAM,eAAe,GAAI,SAAS,eAAe,KAAG,MAG1D,CAAC;AAEF,eAAO,MAAM,oBAAoB,0nCAwChC,CAAC;AAEF,eAAO,MAAM,0BAA0B,2vCA0CtC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,SAAS,eAAe,KAAG,MACqB,CAAC"}
@@ -79,7 +79,85 @@ console.log(\`Covara running at http://localhost:\${server.port}\`);
79
79
  console.log(\`Create: curl -X POST http://localhost:\${server.port}/api/todos -H 'content-type: application/json' -d '{"title":"hello"}'\`);
80
80
  console.log(\`List: curl http://localhost:\${server.port}/api/todos\`);
81
81
  `;
82
- export const renderNodeIndex = (options) => options.db === "sqlite" ? NODE_SQLITE_INDEX : NODE_POSTGRES_INDEX;
82
+ // Node entry for the React-frontend variant: one process serves the SPA (with
83
+ // Vite HMR in dev) AND the API/admin. In dev it embeds Vite in middleware mode
84
+ // and routes /api + /__covara to the Hono app; in production it serves the
85
+ // built SPA from ../public with an SPA fallback.
86
+ const NODE_REACT_DB_SETUP_SQLITE = `import { createClient } from "@libsql/client";
87
+ import { drizzle } from "drizzle-orm/libsql";
88
+ import { createCovara } from "covara";
89
+ import { todos } from "./schema.js";
90
+
91
+ const client = createClient({
92
+ url: process.env.DB_FILE_NAME ?? "file:./dev.db",
93
+ });
94
+ const db = drizzle(client);`;
95
+ const NODE_REACT_DB_SETUP_POSTGRES = `import postgres from "postgres";
96
+ import { drizzle } from "drizzle-orm/postgres-js";
97
+ import { createCovara } from "covara";
98
+ import { todos } from "./schema.js";
99
+
100
+ if (!process.env.DATABASE_URL) {
101
+ throw new Error("DATABASE_URL is required");
102
+ }
103
+
104
+ const client = postgres(process.env.DATABASE_URL);
105
+ const db = drizzle(client);`;
106
+ const renderNodeReactIndex = (options) => {
107
+ const dbSetup = options.db === "sqlite"
108
+ ? NODE_REACT_DB_SETUP_SQLITE
109
+ : NODE_REACT_DB_SETUP_POSTGRES;
110
+ return `${dbSetup}
111
+ import { serve, getRequestListener } from "@hono/node-server";
112
+ import { serveStatic } from "@hono/node-server/serve-static";
113
+ import { createServer as createHttpServer } from "node:http";
114
+ import { fileURLToPath } from "node:url";
115
+ import path from "node:path";
116
+
117
+ const app = createCovara({ cors: true, adminUI: true }).resource(todos, {
118
+ db,
119
+ id: todos.id,
120
+ // Public CRUD so the starter works end-to-end. Lock this down with auth
121
+ // scopes before deploying: https://github.com/kahveciderin/covara#auth
122
+ auth: { public: { read: true, create: true, update: true, delete: true } },
123
+ });
124
+
125
+ const port = Number(process.env.PORT ?? 3000);
126
+ const here = path.dirname(fileURLToPath(import.meta.url));
127
+ const isApi = (p: string) => p.startsWith("/api") || p.startsWith("/__covara");
128
+
129
+ if (process.env.NODE_ENV === "development") {
130
+ // Single process: Vite (SPA + HMR) for everything else, Covara for the API.
131
+ const { createServer: createViteServer } = await import("vite");
132
+ const vite = await createViteServer({
133
+ root: path.join(here, "../frontend"),
134
+ server: { middlewareMode: true },
135
+ appType: "spa",
136
+ });
137
+ const honoListener = getRequestListener(app.fetch);
138
+ createHttpServer((req, res) => {
139
+ if (isApi(req.url ?? "/")) honoListener(req, res);
140
+ else vite.middlewares(req, res);
141
+ }).listen(port, () => {
142
+ console.log(\`Covara dev server (SPA + HMR + API) at http://localhost:\${port}\`);
143
+ console.log(\`Admin UI: http://localhost:\${port}/__covara/ui\`);
144
+ });
145
+ } else {
146
+ // Production: serve the built SPA (../public) and fall through to the API.
147
+ const publicDir = path.join(here, "../public");
148
+ app.use("*", serveStatic({ root: publicDir }));
149
+ const spa = serveStatic({ root: publicDir, path: "index.html" });
150
+ app.get("*", (c, next) => (isApi(c.req.path) ? next() : spa(c, next)));
151
+ serve({ fetch: app.fetch, port });
152
+ console.log(\`Covara running at http://localhost:\${port}\`);
153
+ }
154
+ `;
155
+ };
156
+ export const renderNodeIndex = (options) => {
157
+ if (options.frontend === "react")
158
+ return renderNodeReactIndex(options);
159
+ return options.db === "sqlite" ? NODE_SQLITE_INDEX : NODE_POSTGRES_INDEX;
160
+ };
83
161
  export const CLOUDFLARE_D1_WORKER = `import { drizzle } from "drizzle-orm/d1";
84
162
  import {
85
163
  createCovara,
@@ -1 +1 @@
1
- {"version":3,"file":"source.js","sourceRoot":"","sources":["../../../src/cli/templates/source.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;CAY5B,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;CAU9B,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAwB,EAAU,EAAE,CAC/D,OAAO,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC;AAE5D,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BhC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BlC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAwB,EAAU,EAAE,CAClE,OAAO,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,mBAAmB,CAAC;AAEpE,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCnC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;C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;QAAE,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACvE,OAAO,OAAO,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,mBAAmB,CAAC;AAC3E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCnC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CzC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAwB,EAAU,EAAE,CAC/D,OAAO,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,0BAA0B,CAAC"}
@@ -0,0 +1,24 @@
1
+ export declare const resolveCovaraVersion: () => string;
2
+ export declare const VERSIONS: {
3
+ readonly covara: string;
4
+ readonly hono: "^4.12.25";
5
+ readonly honoNodeServer: "^1.13.7";
6
+ readonly drizzleOrm: "^0.45.1";
7
+ readonly zod: "^4.3.5";
8
+ readonly libsql: "^0.17.0";
9
+ readonly postgres: "^3.4.7";
10
+ readonly typescript: "^5.9.3";
11
+ readonly tsx: "^4.21.0";
12
+ readonly drizzleKit: "^0.31.8";
13
+ readonly typesNode: "^25.0.8";
14
+ readonly wrangler: "^4.0.0";
15
+ readonly workersTypes: "^4.0.0";
16
+ readonly vitest: "^3.0.0";
17
+ readonly react: "^18.3.1";
18
+ readonly reactDom: "^18.3.1";
19
+ readonly typesReact: "^18.3.12";
20
+ readonly typesReactDom: "^18.3.1";
21
+ readonly viteReactPlugin: "^4.3.4";
22
+ readonly vite: "^6.0.5";
23
+ };
24
+ //# sourceMappingURL=versions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../src/cli/templates/versions.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,oBAAoB,QAAO,MAsBvC,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;CAqBX,CAAC"}