create-backon 0.6.2 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,12 +17,18 @@ Or, without the `bun create` shorthand:
17
17
  bunx create-backon
18
18
  ```
19
19
 
20
+ No Bun installed? `npx create-backon` and `npm create backon` both work too
21
+ — same scaffolder either way, generated projects still default to Bun
22
+ scripts (see [Running a generated project without Bun](#running-a-generated-project-without-bun)
23
+ if that's not an option).
24
+
20
25
  Prompts for a project name (or `.` to scaffold into the current directory,
21
26
  same as `bun create vite@latest .`), a framework (Hono or Express), a
22
27
  language (TypeScript or JavaScript), a database (Neon, Postgres, SQLite, or
23
- none — via [Drizzle](https://orm.drizzle.team)), whether to create `.env`
24
- from `.env.example` right away (default yes — skips the manual `cp` step),
25
- and any number of routes, then generates:
28
+ none — via [Drizzle](https://orm.drizzle.team)), where it's headed
29
+ ([Vercel](#deploying-to-vercel), another Node/Bun host, local-only, or not
30
+ sure yet), whether to create `.env` from `.env.example` right away (default
31
+ yes — skips the manual `cp` step), and any number of routes, then generates:
26
32
 
27
33
  ```
28
34
  my-api/
@@ -41,11 +47,14 @@ my-api/
41
47
  <route>.services.ts
42
48
  ```
43
49
 
44
- Each route's `*.routes.ts` wires HTTP methods to controller functions,
45
- `*.controller.ts` validates the request via `defineRoute` (from
46
- `@mednours/backon` or `@mednours/backon/express`, depending on the
47
- framework picked) and calls into `*.services.ts`, which is where real data
48
- access belongs. In JavaScript mode every file is generated without any
50
+ Every route starts blank — a folder mounted in `src/endpoints/index.ts`
51
+ with zero HTTP methods wired up yet. `bun run add-method` (below) adds
52
+ them one at a time: each one appends a `defineRoute`-wrapped export to
53
+ `*.controller.ts` (from `@mednours/backon` or `@mednours/backon/express`,
54
+ depending on the framework picked), a matching function to `*.services.ts`
55
+ — typed via `z.infer` off whatever schema the method declared, so the
56
+ service layer doesn't just see `unknown` — and the mount line to
57
+ `*.routes.ts`. In JavaScript mode every file is generated without any
49
58
  TypeScript-only syntax (no `import type`, no generics, no type
50
59
  annotations) — generated files are genuinely plain JavaScript rather than
51
60
  TypeScript with the types stripped, with JSDoc `@param` comments on the one
@@ -89,12 +98,40 @@ under a shorter name.)
89
98
 
90
99
  It reads the project's own `package.json` to figure out whether it's
91
100
  Hono or Express, TypeScript or JavaScript — no need to answer those again
92
- — then writes `src/endpoints/users/users.controller.ts` (or `.routes`,
93
- `.services`, matching whatever the rest of the project already generates),
101
+ — then writes a blank `src/endpoints/users/users.controller.ts` (or
102
+ `.routes`, `.services` — zero methods yet, same as the initial scaffold),
94
103
  and regenerates `src/endpoints/index.ts` so the new route is mounted next
95
104
  to the ones that were already there. It refuses to run outside a backon
96
105
  project, refuses a route name whose folder already exists, and refuses a
97
- name that's already mounted.
106
+ name that's already mounted. Run `add-method` next to give the new route
107
+ an actual GET/POST/etc.
108
+
109
+ ## Adding a method to a route
110
+
111
+ Interactive, and separate from `add-route` on purpose — this is where the
112
+ per-endpoint work happens, while `add-route`/`remove-route` stay simple
113
+ whole-folder create/delete:
114
+
115
+ ```
116
+ bun run add-method
117
+ ```
118
+
119
+ or `bunx create-backon add-method` (`method` also works). It opens with a
120
+ dashboard of every endpoint already mounted and the methods each one
121
+ actually has right now — read straight off `*.routes.ts`, colored by verb
122
+ (GET/POST/PUT/PATCH/DELETE) — then walks through: which endpoint to add
123
+ to (or spin up a new blank one on the spot), the HTTP method, the path
124
+ (`/` or `/:id`, or anything else — path params are picked up automatically
125
+ from whatever `:name` segments show up), a name for the controller export
126
+ and matching service function (suggested — `list`, `create`, `getById`,
127
+ `update`, `remove` — but editable), and whether this method validates a
128
+ request body and/or query params. Path params always get a Zod schema
129
+ (auto-derived from the path itself — no guessing there); body and query
130
+ schemas start as `z.object({})` with a `TODO` comment, same convention as
131
+ everywhere else in the generated code, for filling in by hand. Loops until
132
+ told to stop, so a whole endpoint's worth of methods is normally one
133
+ `bun run add-method` session. Refuses a method name or a verb+path pair
134
+ that's already there.
98
135
 
99
136
  ## Removing a route
100
137
 
@@ -123,7 +160,9 @@ bun run list-routes
123
160
  ```
124
161
 
125
162
  or `bunx create-backon list-routes` (`routes` also works). Read-only —
126
- prints every route currently mounted in `src/endpoints/index.ts`.
163
+ the same dashboard `add-method` opens with: every route mounted in
164
+ `src/endpoints/index.ts`, and the HTTP methods each one actually has,
165
+ colored by verb.
127
166
 
128
167
  ## Checking a project for drift
129
168
 
@@ -141,6 +180,45 @@ comes from hand-editing `index.ts`, deleting a route folder without using
141
180
  `doctor` only reports issues — it doesn't fix them — and exits non-zero if
142
181
  it finds any, so it's usable in a pre-commit hook or CI step.
143
182
 
183
+ ## Project overview
184
+
185
+ ```
186
+ bun run project
187
+ ```
188
+
189
+ or `bunx create-backon project`. Read-only, one shot — not a loop, nothing
190
+ here writes to disk. Prints three things: the database driver actually wired
191
+ up in `src/config/db.<ext>` and whether it has what it needs (a config
192
+ check, not a live connection attempt — for Neon/Postgres that means
193
+ `DATABASE_URL` is set in `.env`; SQLite is always "ready" since it falls
194
+ back to `./dev.db`; "none" means no database is configured, which is also
195
+ "ready"), the same per-endpoint, per-method dashboard `list-routes` shows,
196
+ and a one-line doctor summary. Point of this command is answering "what's
197
+ actually going on in this project" in one glance, without needing to
198
+ remember which of `list-routes`/`doctor`/checking `.env` by hand to run.
199
+
200
+ ## Managing endpoints and methods interactively
201
+
202
+ ```
203
+ bun run server-config
204
+ ```
205
+
206
+ or `bunx create-backon server-config`. The interactive alternative to
207
+ running `add-route`/`add-method`/`remove-route` individually — opens with
208
+ the same endpoint dashboard `project` shows, then a menu: add a new
209
+ endpoint, remove one, add a method, remove a method, or modify a method
210
+ (change its path, name, or body/query validation in place — the one thing
211
+ none of the standalone commands offer, since it's a checked
212
+ remove-then-re-add rather than a new codegen path). Loops back to the menu
213
+ after each action, re-reading the endpoint list fresh every time, until
214
+ told to stop. `project` and `server-config` are deliberately two separate
215
+ commands rather than one combined dashboard — "show me what's here" and
216
+ "let me start changing things" are different intents, and an overview that
217
+ can also accidentally edit something isn't actually a safe overview.
218
+ `add-route`/`add-method`/`remove-route`/`list-routes`/`doctor` all keep
219
+ working exactly as documented above; `server-config` is a wrapper around
220
+ the same underlying logic, not a replacement for them.
221
+
144
222
  ## Generating API docs
145
223
 
146
224
  Every generated project includes a `docs` script:
@@ -164,6 +242,57 @@ same spec and reference page as live routes on a running server instead of
164
242
  writing them to disk — useful for CI, static hosting, or feeding the spec
165
243
  into an external tool, where `serveApiDocs`'s live routes don't apply.
166
244
 
245
+ ## Deploying to Vercel
246
+
247
+ Picking Vercel at the "Where's this headed?" prompt adds two things, both
248
+ additive — nothing about running the project locally changes:
249
+
250
+ - `src/app.<ext>` gets a default export (`export default app;`), which is
251
+ all [Vercel's zero-config Hono/Express support](https://vercel.com/docs/frameworks/backend/hono)
252
+ needs — it already lives at one of Vercel's recognized entry paths.
253
+ `index.<ext>`'s `serve(app)` call is untouched and keeps working for
254
+ `bun run dev`/`start` anywhere else; Vercel just never runs that file.
255
+ - `vercel.json` pins the [Bun runtime](https://vercel.com/docs/functions/runtimes/bun)
256
+ (`{ "bunVersion": "1.x" }`), so the deployed function runs on the same
257
+ runtime as local dev. Not required for the zero-config detection itself —
258
+ only there so the runtime doesn't silently switch between local and
259
+ deployed.
260
+
261
+ Connect the repo at [vercel.com/new](https://vercel.com/new) or run
262
+ `vercel deploy`; `vercel dev` runs it locally the same way it runs once
263
+ deployed. Missed the prompt, or already have a project? Add both by hand —
264
+ `export default app;` at the end of `src/app.<ext>`, and a `vercel.json`
265
+ with `{ "bunVersion": "1.x" }` — no need to re-scaffold.
266
+
267
+ ## Running a generated project without Bun
268
+
269
+ Generated projects still default to Bun (`bun install`, `bun run dev`) —
270
+ that hasn't changed. But the underlying pieces are genuinely Node-capable
271
+ now, if Bun isn't an option:
272
+
273
+ - `@mednours/backon` itself (0.7.0+) runs on Node — its Hono adapter's
274
+ `serve()` uses [`@hono/node-server`](https://github.com/honojs/node-server)
275
+ under Node instead of `Bun.serve()`, detected automatically. Install it
276
+ yourself (`npm install @hono/node-server`) — it's an optional peer
277
+ dependency, so `npm install` alone won't pull it in.
278
+ - `create-backon` itself runs via `npx create-backon`/`npm create backon`
279
+ now too, not just `bunx`/`bun create` — see the badge on
280
+ [npmjs.com/package/create-backon](https://www.npmjs.com/package/create-backon)
281
+ if in doubt about which runtimes are supported.
282
+ - The one piece that's still Bun-flavored: generated source uses
283
+ extensionless relative imports (`./src/app`, not `./src/app.ts` or
284
+ `./src/app.js`) — fine for Bun's bundler-style resolution, but plain
285
+ `node index.ts`/`node index.js` refuses those outright (Node's ESM loader
286
+ requires a real extension on every relative import, full stop — this
287
+ isn't a TypeScript thing, it fails the exact same way in JavaScript
288
+ mode). [`tsx`](https://github.com/privatenumber/tsx) resolves imports the
289
+ same permissive way Bun does, so `npx tsx index.ts` (or `npx tsx watch
290
+ index.ts` for the `bun run dev` equivalent) runs a generated project
291
+ under plain Node with no other changes — verified against a real
292
+ generated project, Hono and Express, TypeScript and JavaScript mode, all
293
+ four combinations. `npm test` still needs a real Node test runner in
294
+ place of `bun test`, which isn't wired up here — that part's on you.
295
+
167
296
  ## Requirements
168
297
 
169
298
  Bun >= 1.3.