create-taserjs 0.0.6 → 0.1.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 (92) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/addons/prisma/index.cjs +12 -5
  3. package/dist/cjs/addons/prisma/index.cjs.map +1 -1
  4. package/dist/cjs/addons/registry.cjs +3 -1
  5. package/dist/cjs/addons/registry.cjs.map +1 -1
  6. package/dist/cjs/addons/validators.cjs +10 -13
  7. package/dist/cjs/addons/validators.cjs.map +1 -1
  8. package/dist/cjs/cli.cjs +7 -5
  9. package/dist/cjs/cli.cjs.map +1 -1
  10. package/dist/cjs/commands/create.cjs +72 -49
  11. package/dist/cjs/commands/create.cjs.map +1 -1
  12. package/dist/cjs/commands/create.d.cts +2 -1
  13. package/dist/cjs/core/parse-options.cjs +48 -22
  14. package/dist/cjs/core/parse-options.cjs.map +1 -1
  15. package/dist/cjs/core/parse-options.d.cts +19 -4
  16. package/dist/cjs/core/project-config.cjs +5 -1
  17. package/dist/cjs/core/project-config.cjs.map +1 -1
  18. package/dist/cjs/core/resolve-packages.cjs +35 -65
  19. package/dist/cjs/core/resolve-packages.cjs.map +1 -1
  20. package/dist/cjs/core/resolve-packages.d.cts +1 -4
  21. package/dist/cjs/core/scaffold-engine.cjs +16 -27
  22. package/dist/cjs/core/scaffold-engine.cjs.map +1 -1
  23. package/dist/cjs/core/targets.cjs +171 -0
  24. package/dist/cjs/core/targets.cjs.map +1 -0
  25. package/dist/cjs/core/targets.d.cts +49 -0
  26. package/dist/cjs/core/types.cjs +22 -11
  27. package/dist/cjs/core/types.cjs.map +1 -1
  28. package/dist/cjs/core/types.d.cts +20 -4
  29. package/dist/cjs/core/validate-project-name.cjs +0 -1
  30. package/dist/cjs/core/validate-project-name.cjs.map +1 -1
  31. package/dist/cjs/frameworks/index.cjs +79 -171
  32. package/dist/cjs/frameworks/index.cjs.map +1 -1
  33. package/dist/cjs/frameworks/index.d.cts +18 -3
  34. package/dist/cjs/scaffold.d.cts +2 -2
  35. package/dist/cjs/templates/base.cjs +15 -99
  36. package/dist/cjs/templates/base.cjs.map +1 -1
  37. package/dist/cjs/templates/base.d.cts +0 -3
  38. package/dist/cjs/types.d.cts +1 -1
  39. package/dist/esm/addons/prisma/index.js +12 -5
  40. package/dist/esm/addons/prisma/index.js.map +1 -1
  41. package/dist/esm/addons/registry.js +4 -2
  42. package/dist/esm/addons/registry.js.map +1 -1
  43. package/dist/esm/addons/validators.js +10 -13
  44. package/dist/esm/addons/validators.js.map +1 -1
  45. package/dist/esm/cli.js +7 -5
  46. package/dist/esm/cli.js.map +1 -1
  47. package/dist/esm/commands/create.d.ts +2 -1
  48. package/dist/esm/commands/create.js +74 -51
  49. package/dist/esm/commands/create.js.map +1 -1
  50. package/dist/esm/core/parse-options.d.ts +19 -4
  51. package/dist/esm/core/parse-options.js +47 -23
  52. package/dist/esm/core/parse-options.js.map +1 -1
  53. package/dist/esm/core/project-config.js +5 -1
  54. package/dist/esm/core/project-config.js.map +1 -1
  55. package/dist/esm/core/resolve-packages.d.ts +1 -4
  56. package/dist/esm/core/resolve-packages.js +35 -65
  57. package/dist/esm/core/resolve-packages.js.map +1 -1
  58. package/dist/esm/core/scaffold-engine.js +18 -29
  59. package/dist/esm/core/scaffold-engine.js.map +1 -1
  60. package/dist/esm/core/targets.d.ts +49 -0
  61. package/dist/esm/core/targets.js +166 -0
  62. package/dist/esm/core/targets.js.map +1 -0
  63. package/dist/esm/core/types.d.ts +20 -4
  64. package/dist/esm/core/types.js +20 -11
  65. package/dist/esm/core/types.js.map +1 -1
  66. package/dist/esm/core/validate-project-name.js +0 -1
  67. package/dist/esm/core/validate-project-name.js.map +1 -1
  68. package/dist/esm/frameworks/index.d.ts +18 -3
  69. package/dist/esm/frameworks/index.js +76 -171
  70. package/dist/esm/frameworks/index.js.map +1 -1
  71. package/dist/esm/scaffold.d.ts +2 -2
  72. package/dist/esm/templates/base.d.ts +0 -3
  73. package/dist/esm/templates/base.js +16 -98
  74. package/dist/esm/templates/base.js.map +1 -1
  75. package/dist/esm/types.d.ts +1 -1
  76. package/package.json +3 -2
  77. package/src/addons/prisma/index.ts +12 -5
  78. package/src/addons/registry.ts +6 -2
  79. package/src/addons/validators.ts +10 -13
  80. package/src/cli.ts +6 -4
  81. package/src/commands/create.ts +92 -26
  82. package/src/core/parse-options.ts +84 -35
  83. package/src/core/project-config.ts +6 -1
  84. package/src/core/resolve-packages.ts +37 -74
  85. package/src/core/scaffold-engine.ts +41 -65
  86. package/src/core/targets.ts +211 -0
  87. package/src/core/types.ts +40 -24
  88. package/src/core/validate-project-name.ts +0 -4
  89. package/src/frameworks/index.ts +80 -178
  90. package/src/scaffold.ts +2 -2
  91. package/src/templates/base.ts +14 -98
  92. package/src/types.ts +3 -1
@@ -1,17 +1,26 @@
1
1
  //#region src/core/types.ts
2
- var PROJECT_TYPES = [
3
- "node",
4
- "express",
5
- "fastify",
2
+ var FRAMEWORKS = [
3
+ "none",
6
4
  "hono",
5
+ "express",
6
+ "fastify"
7
+ ];
8
+ var RUNTIMES = [
9
+ "node",
7
10
  "bun",
8
- "deno",
9
- "aws-lambda",
10
- "cloudflare-workers",
11
- "netlify",
11
+ "deno"
12
+ ];
13
+ var DEPLOY_TARGETS = [
14
+ "none",
15
+ "node-server",
16
+ "node-cluster",
17
+ "bun",
18
+ "deno-server",
19
+ "deno-deploy",
20
+ "cloudflare-module",
12
21
  "vercel",
13
- "azure-functions",
14
- "google-cloud-run"
22
+ "aws-lambda",
23
+ "netlify"
15
24
  ];
16
25
  var DB_ODMS = [
17
26
  "drizzle",
@@ -31,6 +40,6 @@ var VALIDATORS = [
31
40
  "valibot"
32
41
  ];
33
42
  //#endregion
34
- export { DB_DRIVERS, DB_ODMS, DEFAULT_DB_DRIVER, LOGGERS, PROJECT_TYPES, VALIDATORS };
43
+ export { DB_DRIVERS, DB_ODMS, DEFAULT_DB_DRIVER, DEPLOY_TARGETS, FRAMEWORKS, LOGGERS, RUNTIMES, VALIDATORS };
35
44
 
36
45
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/core/types.ts"],"sourcesContent":["import type { Agent } from \"package-manager-detector\";\n\nexport type ProjectType =\n | \"node\"\n | \"express\"\n | \"fastify\"\n | \"hono\"\n | \"bun\"\n | \"deno\"\n | \"aws-lambda\"\n | \"cloudflare-workers\"\n | \"netlify\"\n | \"vercel\"\n | \"azure-functions\"\n | \"google-cloud-run\";\n\nexport const PROJECT_TYPES: readonly ProjectType[] = [\n \"node\",\n \"express\",\n \"fastify\",\n \"hono\",\n \"bun\",\n \"deno\",\n \"aws-lambda\",\n \"cloudflare-workers\",\n \"netlify\",\n \"vercel\",\n \"azure-functions\",\n \"google-cloud-run\",\n];\n\nexport type DbOdm = \"drizzle\" | \"prisma\" | \"kysely\";\n\nexport const DB_ODMS: readonly DbOdm[] = [\"drizzle\", \"prisma\", \"kysely\"];\n\nexport type DbDriver = \"postgres\" | \"sqlite\" | \"mysql\";\n\nexport const DB_DRIVERS: readonly DbDriver[] = [\"postgres\", \"sqlite\", \"mysql\"];\n\nexport const DEFAULT_DB_DRIVER: DbDriver = \"sqlite\";\n\nexport type LoggerId = \"pino\" | \"winston\";\n\nexport const LOGGERS: readonly LoggerId[] = [\"pino\", \"winston\"];\n\nexport type ValidatorId = \"zod\" | \"arktype\" | \"valibot\";\n\nexport const VALIDATORS: readonly ValidatorId[] = [\"zod\", \"arktype\", \"valibot\"];\n\nexport type PackageGroups = {\n dependencies: string[];\n devDependencies: string[];\n scripts: Record<string, string>;\n};\n\nexport type ScaffoldContext = {\n projectName: string;\n targetDir: string;\n type: ProjectType;\n db?: DbOdm;\n driver?: DbDriver;\n logger?: LoggerId;\n validator?: ValidatorId;\n};\n\nexport type ScaffoldOptions = ScaffoldContext & {\n skipInstall?: boolean;\n agent?: Agent;\n};\n\nexport type ScaffoldResult = ScaffoldContext;\n\nexport type CapabilitiesCatalog = {\n types: ProjectType[];\n db: {\n odms: DbOdm[];\n drivers: DbDriver[];\n defaultDriver: DbDriver;\n };\n loggers: LoggerId[];\n validators: ValidatorId[];\n};\n"],"mappings":";AAgBA,IAAa,gBAAwC;CACnD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAa,UAA4B;CAAC;CAAW;CAAU;AAAQ;AAIvE,IAAa,aAAkC;CAAC;CAAY;CAAU;AAAO;AAE7E,IAAa,oBAA8B;AAI3C,IAAa,UAA+B,CAAC,QAAQ,SAAS;AAI9D,IAAa,aAAqC;CAAC;CAAO;CAAW;AAAS"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/core/types.ts"],"sourcesContent":["import type { Agent } from \"package-manager-detector\";\n\n/** Host framework layered on top of pure Taser pass-through dispatch. */\nexport type Framework = \"none\" | \"hono\" | \"express\" | \"fastify\";\n\nexport const FRAMEWORKS: readonly Framework[] = [\"none\", \"hono\", \"express\", \"fastify\"];\n\nexport type Runtime = \"node\" | \"bun\" | \"deno\";\n\nexport const RUNTIMES: readonly Runtime[] = [\"node\", \"bun\", \"deno\"];\n\n/**\n * Deployment target. Values are Nitro preset ids (see `nitro/config`\n * PresetNameInput) so `--preset` passes straight through to Nitro.\n */\nexport type DeployTarget =\n | \"none\"\n | \"node-server\"\n | \"node-cluster\"\n | \"bun\"\n | \"deno-server\"\n | \"deno-deploy\"\n | \"cloudflare-module\"\n | \"vercel\"\n | \"aws-lambda\"\n | \"netlify\";\n\nexport const DEPLOY_TARGETS: readonly DeployTarget[] = [\n \"none\",\n \"node-server\",\n \"node-cluster\",\n \"bun\",\n \"deno-server\",\n \"deno-deploy\",\n \"cloudflare-module\",\n \"vercel\",\n \"aws-lambda\",\n \"netlify\",\n];\n\nexport type DbOdm = \"drizzle\" | \"prisma\" | \"kysely\";\n\nexport const DB_ODMS: readonly DbOdm[] = [\"drizzle\", \"prisma\", \"kysely\"];\n\nexport type DbDriver = \"postgres\" | \"sqlite\" | \"mysql\";\n\nexport const DB_DRIVERS: readonly DbDriver[] = [\"postgres\", \"sqlite\", \"mysql\"];\n\nexport const DEFAULT_DB_DRIVER: DbDriver = \"sqlite\";\n\nexport type LoggerId = \"pino\" | \"winston\";\n\nexport const LOGGERS: readonly LoggerId[] = [\"pino\", \"winston\"];\n\nexport type ValidatorId = \"zod\" | \"arktype\" | \"valibot\";\n\nexport const VALIDATORS: readonly ValidatorId[] = [\"zod\", \"arktype\", \"valibot\"];\n\nexport type PackageGroups = {\n dependencies: string[];\n devDependencies: string[];\n scripts: Record<string, string>;\n};\n\nexport type ScaffoldContext = {\n projectName: string;\n targetDir: string;\n /** Host framework; \"none\" is pure Taser pass-through dispatch. Defaults to \"none\". */\n framework?: Framework;\n /** Deployment target — a Nitro preset id. Defaults to \"node-server\". */\n preset?: DeployTarget;\n /** Set only when explicitly overriding the runtime implied by the preset. */\n runtime?: Runtime;\n db?: DbOdm;\n driver?: DbDriver;\n logger?: LoggerId;\n validator?: ValidatorId;\n};\n\nexport type ScaffoldOptions = ScaffoldContext & {\n skipInstall?: boolean;\n agent?: Agent;\n};\n\nexport type ScaffoldResult = ScaffoldContext;\n\nexport type CapabilitiesCatalog = {\n frameworks: Framework[];\n deployTargets: DeployTarget[];\n runtimes: Runtime[];\n db: {\n odms: DbOdm[];\n drivers: DbDriver[];\n defaultDriver: DbDriver;\n };\n loggers: LoggerId[];\n validators: ValidatorId[];\n};\n"],"mappings":";AAKA,IAAa,aAAmC;CAAC;CAAQ;CAAQ;CAAW;AAAS;AAIrF,IAAa,WAA+B;CAAC;CAAQ;CAAO;AAAM;AAkBlE,IAAa,iBAA0C;CACrD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAa,UAA4B;CAAC;CAAW;CAAU;AAAQ;AAIvE,IAAa,aAAkC;CAAC;CAAY;CAAU;AAAO;AAE7E,IAAa,oBAA8B;AAI3C,IAAa,UAA+B,CAAC,QAAQ,SAAS;AAI9D,IAAa,aAAqC;CAAC;CAAO;CAAW;AAAS"}
@@ -29,7 +29,6 @@ function validateProjectName(name, cwd = process.cwd()) {
29
29
  const trimmed = name.trim();
30
30
  if (!trimmed) return "Project name is required";
31
31
  if (trimmed.includes("..")) return "Project name cannot contain \"..\"";
32
- if (trimmed.includes("/") || trimmed.includes("\\")) return "Project name cannot contain path separators";
33
32
  if (trimmed.startsWith(".") || trimmed.endsWith(".")) return "Project name cannot start or end with a dot";
34
33
  const baseName = trimmed.split(".")[0]?.toUpperCase();
35
34
  if (baseName && RESERVED_WINDOWS_NAMES.has(baseName)) return `Project name "${trimmed}" is reserved on Windows`;
@@ -1 +1 @@
1
- {"version":3,"file":"validate-project-name.js","names":[],"sources":["../../../src/core/validate-project-name.ts"],"sourcesContent":["import path from \"node:path\";\n\nconst RESERVED_WINDOWS_NAMES = new Set([\n \"CON\",\n \"PRN\",\n \"AUX\",\n \"NVR\",\n \"NULL\",\n \"COM1\",\n \"COM2\",\n \"COM3\",\n \"COM4\",\n \"COM5\",\n \"COM6\",\n \"COM7\",\n \"COM8\",\n \"COM9\",\n \"LPT1\",\n \"LPT2\",\n \"LPT3\",\n \"LPT4\",\n \"LPT5\",\n \"LPT6\",\n \"LPT7\",\n \"LPT8\",\n \"LPT9\",\n]);\n\nexport function validateProjectName(name: string, cwd = process.cwd()): string | undefined {\n const trimmed = name.trim();\n if (!trimmed) {\n return \"Project name is required\";\n }\n\n if (trimmed.includes(\"..\")) {\n return 'Project name cannot contain \"..\"';\n }\n\n if (trimmed.includes(\"/\") || trimmed.includes(\"\\\\\")) {\n return \"Project name cannot contain path separators\";\n }\n\n if (trimmed.startsWith(\".\") || trimmed.endsWith(\".\")) {\n return \"Project name cannot start or end with a dot\";\n }\n\n const baseName = trimmed.split(\".\")[0]?.toUpperCase();\n if (baseName && RESERVED_WINDOWS_NAMES.has(baseName)) {\n return `Project name \"${trimmed}\" is reserved on Windows`;\n }\n\n const targetDir = path.resolve(cwd, trimmed);\n const relative = path.relative(cwd, targetDir);\n if (relative.startsWith(\"..\") || path.isAbsolute(relative)) {\n return \"Project name resolves outside the current directory\";\n }\n\n return undefined;\n}\n"],"mappings":";;AAEA,IAAM,yCAAyB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,oBAAoB,MAAc,MAAM,QAAQ,IAAI,GAAuB;CACzF,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,CAAC,SACH,OAAO;CAGT,IAAI,QAAQ,SAAS,IAAI,GACvB,OAAO;CAGT,IAAI,QAAQ,SAAS,GAAG,KAAK,QAAQ,SAAS,IAAI,GAChD,OAAO;CAGT,IAAI,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG,GACjD,OAAO;CAGT,MAAM,WAAW,QAAQ,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,YAAY;CACpD,IAAI,YAAY,uBAAuB,IAAI,QAAQ,GACjD,OAAO,iBAAiB,QAAQ;CAGlC,MAAM,YAAY,KAAK,QAAQ,KAAK,OAAO;CAC3C,MAAM,WAAW,KAAK,SAAS,KAAK,SAAS;CAC7C,IAAI,SAAS,WAAW,IAAI,KAAK,KAAK,WAAW,QAAQ,GACvD,OAAO;AAIX"}
1
+ {"version":3,"file":"validate-project-name.js","names":[],"sources":["../../../src/core/validate-project-name.ts"],"sourcesContent":["import path from \"node:path\";\n\nconst RESERVED_WINDOWS_NAMES = new Set([\n \"CON\",\n \"PRN\",\n \"AUX\",\n \"NVR\",\n \"NULL\",\n \"COM1\",\n \"COM2\",\n \"COM3\",\n \"COM4\",\n \"COM5\",\n \"COM6\",\n \"COM7\",\n \"COM8\",\n \"COM9\",\n \"LPT1\",\n \"LPT2\",\n \"LPT3\",\n \"LPT4\",\n \"LPT5\",\n \"LPT6\",\n \"LPT7\",\n \"LPT8\",\n \"LPT9\",\n]);\n\nexport function validateProjectName(name: string, cwd = process.cwd()): string | undefined {\n const trimmed = name.trim();\n if (!trimmed) {\n return \"Project name is required\";\n }\n\n if (trimmed.includes(\"..\")) {\n return 'Project name cannot contain \"..\"';\n }\n\n if (trimmed.startsWith(\".\") || trimmed.endsWith(\".\")) {\n return \"Project name cannot start or end with a dot\";\n }\n\n const baseName = trimmed.split(\".\")[0]?.toUpperCase();\n if (baseName && RESERVED_WINDOWS_NAMES.has(baseName)) {\n return `Project name \"${trimmed}\" is reserved on Windows`;\n }\n\n const targetDir = path.resolve(cwd, trimmed);\n const relative = path.relative(cwd, targetDir);\n if (relative.startsWith(\"..\") || path.isAbsolute(relative)) {\n return \"Project name resolves outside the current directory\";\n }\n\n return undefined;\n}\n"],"mappings":";;AAEA,IAAM,yCAAyB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,oBAAoB,MAAc,MAAM,QAAQ,IAAI,GAAuB;CACzF,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,CAAC,SACH,OAAO;CAGT,IAAI,QAAQ,SAAS,IAAI,GACvB,OAAO;CAGT,IAAI,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG,GACjD,OAAO;CAGT,MAAM,WAAW,QAAQ,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,YAAY;CACpD,IAAI,YAAY,uBAAuB,IAAI,QAAQ,GACjD,OAAO,iBAAiB,QAAQ;CAGlC,MAAM,YAAY,KAAK,QAAQ,KAAK,OAAO;CAC3C,MAAM,WAAW,KAAK,SAAS,KAAK,SAAS;CAC7C,IAAI,SAAS,WAAW,IAAI,KAAK,KAAK,WAAW,QAAQ,GACvD,OAAO;AAIX"}
@@ -1,3 +1,18 @@
1
- import { ProjectType } from '../core/types.js';
2
- export declare function indexTemplate(type: ProjectType): string;
3
- export declare function taserTsTemplate(_type?: ProjectType): string;
1
+ import { DeployTarget, Framework } from '../core/types.js';
2
+ export declare function serverEntryTemplate(framework: Framework): {
3
+ fileName: string;
4
+ content: string;
5
+ } | null;
6
+ export type FrameworkEntry = {
7
+ id: Framework;
8
+ serverEntry: {
9
+ fileName: string;
10
+ content: string;
11
+ } | null;
12
+ deps: string[];
13
+ devDeps: string[];
14
+ };
15
+ export declare const FRAMEWORK_ENTRIES: Record<Framework, FrameworkEntry>;
16
+ export declare function nitroConfigTemplate(nitroPreset: string): string;
17
+ export declare function viteConfigTemplate(preset?: DeployTarget): string;
18
+ export declare function taserTsTemplate(): string;
@@ -1,200 +1,105 @@
1
1
  //#region src/frameworks/index.ts
2
- function indexTemplate(type) {
3
- switch (type) {
4
- case "express": return `import 'dotenv/config'
2
+ function serverEntryTemplate(framework) {
3
+ switch (framework) {
4
+ case "hono": return {
5
+ fileName: "src/server.ts",
6
+ content: `import { Hono } from 'hono'
5
7
 
6
- import express from 'express'
7
- import { createExpressHandler } from '@taserjs/adapter-express'
8
-
9
- import { routeManifest } from '#src/routeManifest.gen.js'
10
- import { t } from '#src/taser.js'
11
-
12
- const router = t.create(routeManifest)
13
-
14
- const taser = createExpressHandler(router)
15
- const app = express()
16
- taser.mount('/{*splat}', app)
8
+ const app = new Hono()
17
9
 
18
- const port = Number(process.env.PORT ?? 3000)
19
- app.listen(port, () => {
20
- console.log(\`Express listening on http://localhost:\${port}\`)
10
+ app.get('/host', (c) => {
11
+ return c.text('Hello from Hono host!')
21
12
  })
22
- `;
23
- case "hono": return `import 'dotenv/config'
24
-
25
- import { serve } from '@hono/node-server'
26
- import { Hono } from 'hono'
27
-
28
- import { routeManifest } from '#src/routeManifest.gen.js'
29
- import { t } from '#src/taser.js'
30
13
 
31
- const router = t.create(routeManifest)
14
+ export default app
15
+ `
16
+ };
17
+ case "express": return {
18
+ fileName: "src/server.node.ts",
19
+ content: `import express from 'express'
32
20
 
33
- const app = new Hono()
34
- app.all('/*', c => router.fetch(c.req.raw))
21
+ const app = express()
35
22
 
36
- const port = Number(process.env.PORT ?? 3000)
37
- serve({ fetch: app.fetch, port }, () => {
38
- console.log(\`Hono listening on http://localhost:\${port}\`)
23
+ app.get('/host', (_req, res) => {
24
+ res.json({ message: 'Hello from Express host!' })
39
25
  })
40
- `;
41
- case "fastify": return `import 'dotenv/config'
42
-
43
- import Fastify from 'fastify'
44
- import { createFastifyHandler } from '@taserjs/adapter-fastify'
45
26
 
46
- import { routeManifest } from '#src/routeManifest.gen.js'
47
- import { t } from '#src/taser.js'
27
+ export default app
28
+ `
29
+ };
30
+ case "fastify": return {
31
+ fileName: "src/server.node.ts",
32
+ content: `import Fastify from 'fastify'
48
33
 
49
- const router = t.create(routeManifest)
50
-
51
- const taser = createFastifyHandler(router)
52
34
  const app = Fastify()
53
- taser.mount('/*', app)
54
-
55
- const port = Number(process.env.PORT ?? 3000)
56
- await app.listen({ port })
57
- console.log(\`Fastify listening on http://localhost:\${port}\`)
58
- `;
59
- case "bun": return `import 'dotenv/config'
60
-
61
- import { routeManifest } from '#src/routeManifest.gen.js'
62
- import { t } from '#src/taser.js'
63
-
64
- const router = t.create(routeManifest)
65
-
66
- const port = Number(process.env.PORT ?? 3000)
67
-
68
- export default {
69
- port,
70
- fetch(request: Request) {
71
- return router.fetch(request)
72
- },
73
- }
74
- `;
75
- case "deno": return `import 'dotenv/config'
76
-
77
- import { routeManifest } from '#src/routeManifest.gen.js'
78
- import { t } from '#src/taser.js'
79
-
80
- const router = t.create(routeManifest)
81
-
82
- const port = Number(process.env.PORT ?? 8000)
83
- Deno.serve({ port }, (request: Request) => router.fetch(request))
84
- `;
85
- case "aws-lambda": return `import 'dotenv/config'
86
-
87
- import { Hono } from 'hono'
88
- import { handle } from 'hono/aws-lambda'
89
-
90
- import { routeManifest } from '#src/routeManifest.gen.js'
91
- import { t } from '#src/taser.js'
92
-
93
- const router = t.create(routeManifest)
94
-
95
- const app = new Hono()
96
- app.all('/*', c => router.fetch(c.req.raw))
97
-
98
- export const handler = handle(app)
99
- `;
100
- case "cloudflare-workers": return `import 'dotenv/config'
101
35
 
102
- import { routeManifest } from '#src/routeManifest.gen.js'
103
- import { t } from '#src/taser.js'
36
+ app.get('/host', async () => {
37
+ return { message: 'Hello from Fastify host!' }
38
+ })
104
39
 
105
- const router = t.create(routeManifest)
40
+ await app.ready()
106
41
 
107
- export default {
108
- fetch(request: Request, env: unknown, ctx: unknown) {
109
- return router.fetch(request, env, ctx)
110
- },
42
+ export default app.routing
43
+ `
44
+ };
45
+ default: return null;
46
+ }
111
47
  }
112
- `;
113
- case "netlify": return `import 'dotenv/config'
114
-
115
- import { Hono } from 'hono'
116
- import { handle } from 'hono/netlify'
117
-
118
- import { routeManifest } from '#src/routeManifest.gen.js'
119
- import { t } from '#src/taser.js'
120
-
121
- const router = t.create(routeManifest)
122
-
123
- const app = new Hono()
124
- app.all('/*', c => router.fetch(c.req.raw))
125
-
126
- export default handle(app)
127
- `;
128
- case "vercel": return `import 'dotenv/config'
129
-
130
- import { Hono } from 'hono'
131
- import { handle } from 'hono/vercel'
132
-
133
- import { routeManifest } from '#src/routeManifest.gen.js'
134
- import { t } from '#src/taser.js'
135
-
136
- const router = t.create(routeManifest)
137
-
138
- const app = new Hono()
139
- app.all('/*', c => router.fetch(c.req.raw))
140
-
141
- export default handle(app)
142
- `;
143
- case "azure-functions": return `import 'dotenv/config'
144
-
145
- import { app } from '@azure/functions'
146
- import { Hono } from 'hono'
147
- import { azureHonoHandler } from '@marplex/hono-azurefunc-adapter'
148
-
149
- import { routeManifest } from '#src/routeManifest.gen.js'
150
- import { t } from '#src/taser.js'
151
-
152
- const router = t.create(routeManifest)
153
-
154
- const honoApp = new Hono()
155
- honoApp.all('/*', c => router.fetch(c.req.raw))
48
+ var FRAMEWORK_ENTRIES = {
49
+ none: {
50
+ id: "none",
51
+ serverEntry: null,
52
+ deps: [],
53
+ devDeps: []
54
+ },
55
+ hono: {
56
+ id: "hono",
57
+ serverEntry: serverEntryTemplate("hono"),
58
+ deps: ["hono"],
59
+ devDeps: []
60
+ },
61
+ express: {
62
+ id: "express",
63
+ serverEntry: serverEntryTemplate("express"),
64
+ deps: ["express"],
65
+ devDeps: ["@types/express"]
66
+ },
67
+ fastify: {
68
+ id: "fastify",
69
+ serverEntry: serverEntryTemplate("fastify"),
70
+ deps: ["fastify"],
71
+ devDeps: []
72
+ }
73
+ };
74
+ function nitroConfigTemplate(nitroPreset) {
75
+ return `import { defineConfig } from 'nitro/config'
156
76
 
157
- app.http('httpTrigger', {
158
- methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'],
159
- authLevel: 'anonymous',
160
- route: '{*proxy}',
161
- handler: azureHonoHandler(honoApp.fetch),
77
+ export default defineConfig({
78
+ preset: '${nitroPreset}',
162
79
  })
163
80
  `;
164
- case "google-cloud-run": return `import 'dotenv/config'
165
-
166
- import { serve } from '@hono/node-server'
167
-
168
- import { routeManifest } from '#src/routeManifest.gen.js'
169
- import { t } from '#src/taser.js'
170
-
171
- const router = t.create(routeManifest)
81
+ }
82
+ function viteConfigTemplate(preset) {
83
+ if (preset === "none") return `import { defineConfig } from 'vite'
84
+ import { taser } from '@taserjs/router-plugin/vite'
172
85
 
173
- const port = Number(process.env.PORT ?? 8080)
174
- serve({ fetch: router.fetch, port }, () => {
175
- console.log(\`Cloud Run listening on http://localhost:\${port}\`)
86
+ export default defineConfig({
87
+ plugins: [taser()],
176
88
  })
177
89
  `;
178
- default: return `import 'dotenv/config'
179
-
180
- import { serve } from '@hono/node-server'
90
+ return `import { defineConfig } from 'vite'
91
+ import { nitro } from 'nitro/vite'
92
+ import { taser } from '@taserjs/router-plugin/vite'
181
93
 
182
- import { routeManifest } from '#src/routeManifest.gen.js'
183
- import { t } from '#src/taser.js'
184
-
185
- const router = t.create(routeManifest)
186
-
187
- const port = Number(process.env.PORT ?? 3000)
188
- serve({ fetch: router.fetch, port }, () => {
189
- console.log(\`Node listening on http://localhost:\${port}\`)
94
+ export default defineConfig({
95
+ plugins: [taser(), nitro()],
190
96
  })
191
97
  `;
192
- }
193
98
  }
194
- function taserTsTemplate(_type = "node") {
99
+ function taserTsTemplate() {
195
100
  return `import { createTaserApp } from '@taserjs/router'
196
101
 
197
- import { context } from '#src/context.js'
102
+ import { context } from './context.js'
198
103
 
199
104
  export const t = createTaserApp({
200
105
  response: { validate: true },
@@ -202,6 +107,6 @@ export const t = createTaserApp({
202
107
  `;
203
108
  }
204
109
  //#endregion
205
- export { indexTemplate, taserTsTemplate };
110
+ export { FRAMEWORK_ENTRIES, nitroConfigTemplate, serverEntryTemplate, taserTsTemplate, viteConfigTemplate };
206
111
 
207
112
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/frameworks/index.ts"],"sourcesContent":["import type { ProjectType } from \"../core/types.js\";\n\nexport function indexTemplate(type: ProjectType): string {\n switch (type) {\n case \"express\":\n return `import 'dotenv/config'\n\nimport express from 'express'\nimport { createExpressHandler } from '@taserjs/adapter-express'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst taser = createExpressHandler(router)\nconst app = express()\ntaser.mount('/{*splat}', app)\n\nconst port = Number(process.env.PORT ?? 3000)\napp.listen(port, () => {\n console.log(\\`Express listening on http://localhost:\\${port}\\`)\n})\n`;\n case \"hono\":\n return `import 'dotenv/config'\n\nimport { serve } from '@hono/node-server'\nimport { Hono } from 'hono'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst app = new Hono()\napp.all('/*', c => router.fetch(c.req.raw))\n\nconst port = Number(process.env.PORT ?? 3000)\nserve({ fetch: app.fetch, port }, () => {\n console.log(\\`Hono listening on http://localhost:\\${port}\\`)\n})\n`;\n case \"fastify\":\n return `import 'dotenv/config'\n\nimport Fastify from 'fastify'\nimport { createFastifyHandler } from '@taserjs/adapter-fastify'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst taser = createFastifyHandler(router)\nconst app = Fastify()\ntaser.mount('/*', app)\n\nconst port = Number(process.env.PORT ?? 3000)\nawait app.listen({ port })\nconsole.log(\\`Fastify listening on http://localhost:\\${port}\\`)\n`;\n case \"bun\":\n return `import 'dotenv/config'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst port = Number(process.env.PORT ?? 3000)\n\nexport default {\n port,\n fetch(request: Request) {\n return router.fetch(request)\n },\n}\n`;\n case \"deno\":\n return `import 'dotenv/config'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst port = Number(process.env.PORT ?? 8000)\nDeno.serve({ port }, (request: Request) => router.fetch(request))\n`;\n case \"aws-lambda\":\n return `import 'dotenv/config'\n\nimport { Hono } from 'hono'\nimport { handle } from 'hono/aws-lambda'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst app = new Hono()\napp.all('/*', c => router.fetch(c.req.raw))\n\nexport const handler = handle(app)\n`;\n case \"cloudflare-workers\":\n return `import 'dotenv/config'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nexport default {\n fetch(request: Request, env: unknown, ctx: unknown) {\n return router.fetch(request, env, ctx)\n },\n}\n`;\n case \"netlify\":\n return `import 'dotenv/config'\n\nimport { Hono } from 'hono'\nimport { handle } from 'hono/netlify'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst app = new Hono()\napp.all('/*', c => router.fetch(c.req.raw))\n\nexport default handle(app)\n`;\n case \"vercel\":\n return `import 'dotenv/config'\n\nimport { Hono } from 'hono'\nimport { handle } from 'hono/vercel'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst app = new Hono()\napp.all('/*', c => router.fetch(c.req.raw))\n\nexport default handle(app)\n`;\n case \"azure-functions\":\n return `import 'dotenv/config'\n\nimport { app } from '@azure/functions'\nimport { Hono } from 'hono'\nimport { azureHonoHandler } from '@marplex/hono-azurefunc-adapter'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst honoApp = new Hono()\nhonoApp.all('/*', c => router.fetch(c.req.raw))\n\napp.http('httpTrigger', {\n methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'],\n authLevel: 'anonymous',\n route: '{*proxy}',\n handler: azureHonoHandler(honoApp.fetch),\n})\n`;\n case \"google-cloud-run\":\n return `import 'dotenv/config'\n\nimport { serve } from '@hono/node-server'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst port = Number(process.env.PORT ?? 8080)\nserve({ fetch: router.fetch, port }, () => {\n console.log(\\`Cloud Run listening on http://localhost:\\${port}\\`)\n})\n`;\n case \"node\":\n default:\n return `import 'dotenv/config'\n\nimport { serve } from '@hono/node-server'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst port = Number(process.env.PORT ?? 3000)\nserve({ fetch: router.fetch, port }, () => {\n console.log(\\`Node listening on http://localhost:\\${port}\\`)\n})\n`;\n }\n}\n\nexport function taserTsTemplate(_type: ProjectType = \"node\"): string {\n return `import { createTaserApp } from '@taserjs/router'\n\nimport { context } from '#src/context.js'\n\nexport const t = createTaserApp({\n response: { validate: true },\n}).context(context)\n`;\n}\n"],"mappings":";AAEA,SAAgB,cAAc,MAA2B;CACvD,QAAQ,MAAR;EACE,KAAK,WACH,OAAO;;;;;;;;;;;;;;;;;;;EAmBT,KAAK,QACH,OAAO;;;;;;;;;;;;;;;;;;EAkBT,KAAK,WACH,OAAO;;;;;;;;;;;;;;;;;;EAkBT,KAAK,OACH,OAAO;;;;;;;;;;;;;;;;EAgBT,KAAK,QACH,OAAO;;;;;;;;;;EAUT,KAAK,cACH,OAAO;;;;;;;;;;;;;;;EAeT,KAAK,sBACH,OAAO;;;;;;;;;;;;;EAaT,KAAK,WACH,OAAO;;;;;;;;;;;;;;;EAeT,KAAK,UACH,OAAO;;;;;;;;;;;;;;;EAeT,KAAK,mBACH,OAAO;;;;;;;;;;;;;;;;;;;;;EAqBT,KAAK,oBACH,OAAO;;;;;;;;;;;;;;EAeT,SACE,OAAO;;;;;;;;;;;;;;CAcX;AACF;AAEA,SAAgB,gBAAgB,QAAqB,QAAgB;CACnE,OAAO;;;;;;;;AAQT"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/frameworks/index.ts"],"sourcesContent":["import type { DeployTarget, Framework } from \"../core/types.js\";\n\nexport function serverEntryTemplate(\n framework: Framework,\n): { fileName: string; content: string } | null {\n switch (framework) {\n case \"hono\":\n return {\n fileName: \"src/server.ts\",\n content: `import { Hono } from 'hono'\n\nconst app = new Hono()\n\napp.get('/host', (c) => {\n return c.text('Hello from Hono host!')\n})\n\nexport default app\n`,\n };\n case \"express\":\n return {\n fileName: \"src/server.node.ts\",\n content: `import express from 'express'\n\nconst app = express()\n\napp.get('/host', (_req, res) => {\n res.json({ message: 'Hello from Express host!' })\n})\n\nexport default app\n`,\n };\n case \"fastify\":\n return {\n fileName: \"src/server.node.ts\",\n content: `import Fastify from 'fastify'\n\nconst app = Fastify()\n\napp.get('/host', async () => {\n return { message: 'Hello from Fastify host!' }\n})\n\nawait app.ready()\n\nexport default app.routing\n`,\n };\n default:\n return null;\n }\n}\n\nexport type FrameworkEntry = {\n id: Framework;\n serverEntry: { fileName: string; content: string } | null;\n deps: string[];\n devDeps: string[];\n};\n\nexport const FRAMEWORK_ENTRIES: Record<Framework, FrameworkEntry> = {\n none: { id: \"none\", serverEntry: null, deps: [], devDeps: [] },\n hono: { id: \"hono\", serverEntry: serverEntryTemplate(\"hono\"), deps: [\"hono\"], devDeps: [] },\n express: {\n id: \"express\",\n serverEntry: serverEntryTemplate(\"express\"),\n deps: [\"express\"],\n devDeps: [\"@types/express\"],\n },\n fastify: {\n id: \"fastify\",\n // srvx bridges the Fastify Node handler to fetch (see compose codegen).\n serverEntry: serverEntryTemplate(\"fastify\"),\n deps: [\"fastify\"],\n devDeps: [],\n },\n};\n\nexport function nitroConfigTemplate(nitroPreset: string): string {\n return `import { defineConfig } from 'nitro/config'\n\nexport default defineConfig({\n preset: '${nitroPreset}',\n})\n`;\n}\n\nexport function viteConfigTemplate(preset?: DeployTarget): string {\n if (preset === \"none\") {\n return `import { defineConfig } from 'vite'\nimport { taser } from '@taserjs/router-plugin/vite'\n\nexport default defineConfig({\n plugins: [taser()],\n})\n`;\n }\n\n return `import { defineConfig } from 'vite'\nimport { nitro } from 'nitro/vite'\nimport { taser } from '@taserjs/router-plugin/vite'\n\nexport default defineConfig({\n plugins: [taser(), nitro()],\n})\n`;\n}\n\nexport function taserTsTemplate(): string {\n return `import { createTaserApp } from '@taserjs/router'\n\nimport { context } from './context.js'\n\nexport const t = createTaserApp({\n response: { validate: true },\n}).context(context)\n`;\n}\n"],"mappings":";AAEA,SAAgB,oBACd,WAC8C;CAC9C,QAAQ,WAAR;EACE,KAAK,QACH,OAAO;GACL,UAAU;GACV,SAAS;;;;;;;;;;EAUX;EACF,KAAK,WACH,OAAO;GACL,UAAU;GACV,SAAS;;;;;;;;;;EAUX;EACF,KAAK,WACH,OAAO;GACL,UAAU;GACV,SAAS;;;;;;;;;;;;EAYX;EACF,SACE,OAAO;CACX;AACF;AASA,IAAa,oBAAuD;CAClE,MAAM;EAAE,IAAI;EAAQ,aAAa;EAAM,MAAM,CAAC;EAAG,SAAS,CAAC;CAAE;CAC7D,MAAM;EAAE,IAAI;EAAQ,aAAa,oBAAoB,MAAM;EAAG,MAAM,CAAC,MAAM;EAAG,SAAS,CAAC;CAAE;CAC1F,SAAS;EACP,IAAI;EACJ,aAAa,oBAAoB,SAAS;EAC1C,MAAM,CAAC,SAAS;EAChB,SAAS,CAAC,gBAAgB;CAC5B;CACA,SAAS;EACP,IAAI;EAEJ,aAAa,oBAAoB,SAAS;EAC1C,MAAM,CAAC,SAAS;EAChB,SAAS,CAAC;CACZ;AACF;AAEA,SAAgB,oBAAoB,aAA6B;CAC/D,OAAO;;;aAGI,YAAY;;;AAGzB;AAEA,SAAgB,mBAAmB,QAA+B;CAChE,IAAI,WAAW,QACb,OAAO;;;;;;;CAST,OAAO;;;;;;;;AAQT;AAEA,SAAgB,kBAA0B;CACxC,OAAO;;;;;;;;AAQT"}
@@ -1,3 +1,3 @@
1
1
  export { scaffoldProject } from './core/scaffold-engine.js';
2
- export { getPackageGroups, resolvePackages } from './core/resolve-packages.js';
3
- export type { PackageGroups, ProjectType, ScaffoldOptions, ScaffoldResult } from './core/types.js';
2
+ export { resolvePackages } from './core/resolve-packages.js';
3
+ export type { PackageGroups, ScaffoldOptions, ScaffoldResult } from './core/types.js';
@@ -1,12 +1,9 @@
1
1
  import { BootBinding } from '../addons/types.js';
2
2
  import { ScaffoldContext } from '../core/types.js';
3
3
  export declare function packageJsonTemplate(projectName: string, scripts?: Record<string, string>): string;
4
- export declare function tsdownConfigTemplate(): string;
5
4
  export declare function tsconfigTemplate(): string;
6
5
  export declare function gitignoreTemplate(): string;
7
6
  export declare function contextTemplate(bindings: BootBinding[]): string;
8
7
  export declare function rootLayoutTemplate(): string;
9
8
  export declare function indexRouteTemplate(): string;
10
9
  export declare function healthRouteTemplate(ctx: ScaffoldContext): string;
11
- /** Minimal placeholder until `taser generate` runs. */
12
- export declare function starterManifestTemplate(): string;
@@ -5,52 +5,36 @@ function packageJsonTemplate(projectName, scripts = {}) {
5
5
  version: "1.0.0",
6
6
  private: true,
7
7
  type: "module",
8
- imports: { "#src/*": "./src/*" },
8
+ imports: { "#taserjs/router": "./src/taser.ts" },
9
9
  scripts: {
10
- dev: "run-p dev:server dev:taser",
11
- "dev:server": "tsx watch src/index.ts",
12
- "dev:taser": "taser watch",
13
- start: "tsx src/index.ts",
14
- generate: "taser generate",
15
- build: "taser generate && tsdown",
16
- serve: "node dist/index.mjs",
10
+ dev: "vite",
11
+ build: "vite build",
17
12
  typecheck: "tsc --noEmit -p tsconfig.json",
18
13
  ...scripts
19
14
  }
20
15
  };
21
16
  return `${JSON.stringify(pkg, null, 2)}\n`;
22
17
  }
23
- function tsdownConfigTemplate() {
24
- return `import { defineConfig } from 'tsdown'
25
-
26
- export default defineConfig({
27
- entry: ['./src/index.ts'],
28
- platform: 'node',
29
- outDir: 'dist',
30
- clean: true,
31
- sourcemap: true,
32
- })
33
- `;
34
- }
35
18
  function tsconfigTemplate() {
36
19
  return `${JSON.stringify({
37
20
  compilerOptions: {
38
21
  target: "ES2022",
39
22
  module: "NodeNext",
40
- paths: { "#src/*": ["./src/*"] },
23
+ paths: { "#taserjs/router": ["./src/taser.ts"] },
41
24
  strict: true,
42
25
  skipLibCheck: true,
43
26
  verbatimModuleSyntax: true,
44
27
  isolatedModules: true,
45
- noEmit: true,
46
- types: ["node"]
28
+ noEmit: true
47
29
  },
48
- include: ["src"]
30
+ include: ["src", ".taser/types/**/*.d.ts"]
49
31
  }, null, 2)}\n`;
50
32
  }
51
33
  function gitignoreTemplate() {
52
34
  return `node_modules
53
35
  dist
36
+ .output
37
+ .taser
54
38
  .DS_Store
55
39
  *.log
56
40
  .env
@@ -75,21 +59,21 @@ ${bootBlock}
75
59
  function rootLayoutTemplate() {
76
60
  return `import { cors } from '@taserjs/router/cors'
77
61
 
78
- import { t } from '#src/taser.js'
62
+ import { t } from '#taserjs/router'
79
63
 
80
64
  export const Middleware = t.middleware('/$')
81
65
  .use(cors())
82
66
  `;
83
67
  }
84
68
  function indexRouteTemplate() {
85
- return `import { reply } from '@taserjs/router'
86
- import { t } from '#src/taser.js'
69
+ return `import { json } from '@taserjs/router/reply'
70
+ import { t } from '#taserjs/router'
87
71
 
88
72
  const GET = t.get('/')
89
73
 
90
74
  export type RouteContext = typeof GET.$Infer.Context
91
75
  export const Route = GET.handler((_ctx) => {
92
- return reply.json({ message: 'Welcome to Taser' })
76
+ return json({ message: 'Welcome to Taser' })
93
77
  })
94
78
  `;
95
79
  }
@@ -98,84 +82,18 @@ function healthRouteTemplate(ctx) {
98
82
  if (ctx.logger) lines.push(" ctx.logger.info('health check')");
99
83
  if (ctx.db) lines.push(" // ctx.db is available from context boot");
100
84
  const body = lines.length > 0 ? `${lines.join("\n")}\n` : "";
101
- return `import { reply } from '@taserjs/router'
102
- import { t } from '#src/taser.js'
85
+ return `import { json } from '@taserjs/router/reply'
86
+ import { t } from '#taserjs/router'
103
87
 
104
88
  const GET = t.get('/health')
105
89
 
106
90
  export type RouteContext = typeof GET.$Infer.Context
107
91
  export const Route = GET.handler(${lines.length > 0 ? "(ctx)" : "(_ctx)"} => {
108
- ${body} return reply.json({ ok: true })
92
+ ${body} return json({ ok: true })
109
93
  })
110
94
  `;
111
95
  }
112
- /** Minimal placeholder until `taser generate` runs. */
113
- function starterManifestTemplate() {
114
- return `/* eslint-disable */
115
- // Run \`pnpm generate\` (taser generate) to replace this file.
116
- import { Middleware as RootSplatLayoutImport } from './routes/$.js'
117
- import { Route as RootIndexGetRouteImport } from './routes/index.get.js'
118
- import { Route as HealthGetRouteImport } from './routes/health.get.js'
119
-
120
- export const routeManifest = {
121
- layouts: {
122
- '/$': {
123
- middlewares: RootSplatLayoutImport,
124
- },
125
- },
126
- routes: {
127
- '/': {
128
- GET: {
129
- layoutChain: ['/$'],
130
- route: RootIndexGetRouteImport,
131
- },
132
- },
133
- '/health': {
134
- GET: {
135
- layoutChain: ['/$'],
136
- route: HealthGetRouteImport,
137
- },
138
- },
139
- },
140
- } as const
141
-
142
- export type RoutePathGen = '/' | '/health'
143
- export type LayoutIdGen = '/$'
144
- export type LayoutTreeGen = {
145
- '/$': {
146
- parent: null
147
- middlewares: typeof RootSplatLayoutImport
148
- }
149
- }
150
- export type RouteByPathMethodGen = {
151
- '/': {
152
- GET: {
153
- parent: '/$'
154
- layoutChain: ['/$']
155
- route: typeof RootIndexGetRouteImport
156
- }
157
- }
158
- '/health': {
159
- GET: {
160
- parent: '/$'
161
- layoutChain: ['/$']
162
- route: typeof HealthGetRouteImport
163
- }
164
- }
165
- }
166
- export type RouteManifest = typeof routeManifest
167
-
168
- declare module '@taserjs/router' {
169
- interface RouterRegister {
170
- RoutePath: RoutePathGen
171
- LayoutId: LayoutIdGen
172
- LayoutTree: LayoutTreeGen
173
- RouteByPathMethod: RouteByPathMethodGen
174
- }
175
- }
176
- `;
177
- }
178
96
  //#endregion
179
- export { contextTemplate, gitignoreTemplate, healthRouteTemplate, indexRouteTemplate, packageJsonTemplate, rootLayoutTemplate, starterManifestTemplate, tsconfigTemplate, tsdownConfigTemplate };
97
+ export { contextTemplate, gitignoreTemplate, healthRouteTemplate, indexRouteTemplate, packageJsonTemplate, rootLayoutTemplate, tsconfigTemplate };
180
98
 
181
99
  //# sourceMappingURL=base.js.map