flowdoc-gen 0.1.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 ADDED
@@ -0,0 +1,89 @@
1
+ # flowdoc
2
+
3
+ Auto-generate beautiful API documentation from your Express codebase — no annotations required.
4
+
5
+ flowdoc scans your TypeScript source files, extracts Express routes, infers Zod schemas, and produces an interactive docs UI served directly from your server.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install flowdoc-gen
11
+ # or
12
+ pnpm add flowdoc-gen
13
+ ```
14
+
15
+ ## Quick start
16
+
17
+ ### 1. Scaffold a config
18
+
19
+ ```bash
20
+ npx flowdoc init
21
+ ```
22
+
23
+ This creates `flowdoc.config.ts` in your project root.
24
+
25
+ ### 2. Serve docs from your own Express server
26
+
27
+ ```ts
28
+ import express from "express";
29
+ import { flowdoc } from "flowdoc-gen";
30
+
31
+ const app = express();
32
+ app.use("/docs", flowdoc());
33
+
34
+ app.listen(3000);
35
+ // Docs are live at http://localhost:3000/docs
36
+ ```
37
+
38
+ The `baseUrl` is auto-detected from every incoming request — no manual config needed.
39
+
40
+ ### 3. Or generate a static site
41
+
42
+ ```bash
43
+ npx flowdoc generate # writes docs-output/
44
+ npx flowdoc serve # generate + open in browser
45
+ npx flowdoc serve --watch # re-generate on file changes
46
+ ```
47
+
48
+ ## CLI reference
49
+
50
+ | Command | Description |
51
+ |---------|-------------|
52
+ | `flowdoc init` | Scaffold `flowdoc.config.ts` |
53
+ | `flowdoc generate` | Parse routes and write `docs-output/` |
54
+ | `flowdoc serve` | Generate and open docs in browser |
55
+ | `flowdoc serve --watch` | Same, but re-generates on source changes |
56
+ | `flowdoc serve --port 5000` | Custom port (default 4000) |
57
+
58
+ ## Config
59
+
60
+ ```ts
61
+ // flowdoc.config.ts
62
+ import { defineConfig } from "flowdoc-gen";
63
+
64
+ export default defineConfig({
65
+ name: "My API",
66
+ entry: "src/**/*.ts",
67
+ framework: "express",
68
+ output: "docs-output",
69
+ groups: [
70
+ { name: "Auth", match: "/auth/**" },
71
+ { name: "Users", match: "/users/**" },
72
+ ],
73
+ theme: {
74
+ brand: "#6366f1",
75
+ darkMode: true,
76
+ },
77
+ });
78
+ ```
79
+
80
+ ## What gets inferred automatically
81
+
82
+ - All Express routes (`app.get`, `app.post`, `router.use`, etc.)
83
+ - Path parameters (`/users/:id` → `id: string` in path params)
84
+ - Zod request body schemas passed to validation middleware
85
+ - Route grouping by path prefix
86
+
87
+ ## License
88
+
89
+ MIT
package/dist/bin.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/bin.js ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ #!/usr/bin/env node
3
+
4
+ // src/bin.ts
5
+ import { program } from "commander";
6
+ import { readFileSync } from "fs";
7
+ import { fileURLToPath } from "url";
8
+ import { dirname, join } from "path";
9
+ var __dirname = dirname(fileURLToPath(import.meta.url));
10
+ var pkg = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"));
11
+ program.name("flowdoc").description("Auto-generate beautiful API documentation from your Express codebase").version(pkg.version);
12
+ program.command("init").description("Scaffold a flowdoc.config.ts in the current directory").action(async () => {
13
+ const { init } = await import("./init-27XS6ADW.js");
14
+ init();
15
+ });
16
+ program.command("generate").description("Parse your routes and write docs to the output folder").option("-c, --config <path>", "Path to flowdoc config file").option("-o, --output <path>", "Override output directory").option("-q, --quiet", "Suppress output").action(async (opts) => {
17
+ const { generate } = await import("./generate-J6FGBLQ4.js");
18
+ await generate(opts);
19
+ });
20
+ program.command("serve").description("Generate docs and serve them locally").option("-c, --config <path>", "Path to flowdoc config file").option("-o, --output <path>", "Override output directory").option("-p, --port <number>", "Port to serve on (default: 4000)", "4000").option("-w, --watch", "Re-generate docs on source file changes").option("--no-open", "Don't open browser automatically").action(async (opts) => {
21
+ const { serve } = await import("./serve-Y4E3DTAJ.js");
22
+ const serveOpts = {
23
+ port: opts.port ? parseInt(opts.port, 10) : 4e3,
24
+ noOpen: !opts.open,
25
+ watch: opts.watch ?? false
26
+ };
27
+ if (opts.config !== void 0) serveOpts.config = opts.config;
28
+ if (opts.output !== void 0) serveOpts.output = opts.output;
29
+ await serve(serveOpts);
30
+ });
31
+ program.parse();