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,6 +1,15 @@
1
1
  import { Agent } from 'package-manager-detector';
2
- export type ProjectType = "node" | "express" | "fastify" | "hono" | "bun" | "deno" | "aws-lambda" | "cloudflare-workers" | "netlify" | "vercel" | "azure-functions" | "google-cloud-run";
3
- export declare const PROJECT_TYPES: readonly ProjectType[];
2
+ /** Host framework layered on top of pure Taser pass-through dispatch. */
3
+ export type Framework = "none" | "hono" | "express" | "fastify";
4
+ export declare const FRAMEWORKS: readonly Framework[];
5
+ export type Runtime = "node" | "bun" | "deno";
6
+ export declare const RUNTIMES: readonly Runtime[];
7
+ /**
8
+ * Deployment target. Values are Nitro preset ids (see `nitro/config`
9
+ * PresetNameInput) so `--preset` passes straight through to Nitro.
10
+ */
11
+ export type DeployTarget = "none" | "node-server" | "node-cluster" | "bun" | "deno-server" | "deno-deploy" | "cloudflare-module" | "vercel" | "aws-lambda" | "netlify";
12
+ export declare const DEPLOY_TARGETS: readonly DeployTarget[];
4
13
  export type DbOdm = "drizzle" | "prisma" | "kysely";
5
14
  export declare const DB_ODMS: readonly DbOdm[];
6
15
  export type DbDriver = "postgres" | "sqlite" | "mysql";
@@ -18,7 +27,12 @@ export type PackageGroups = {
18
27
  export type ScaffoldContext = {
19
28
  projectName: string;
20
29
  targetDir: string;
21
- type: ProjectType;
30
+ /** Host framework; "none" is pure Taser pass-through dispatch. Defaults to "none". */
31
+ framework?: Framework;
32
+ /** Deployment target — a Nitro preset id. Defaults to "node-server". */
33
+ preset?: DeployTarget;
34
+ /** Set only when explicitly overriding the runtime implied by the preset. */
35
+ runtime?: Runtime;
22
36
  db?: DbOdm;
23
37
  driver?: DbDriver;
24
38
  logger?: LoggerId;
@@ -30,7 +44,9 @@ export type ScaffoldOptions = ScaffoldContext & {
30
44
  };
31
45
  export type ScaffoldResult = ScaffoldContext;
32
46
  export type CapabilitiesCatalog = {
33
- types: ProjectType[];
47
+ frameworks: Framework[];
48
+ deployTargets: DeployTarget[];
49
+ runtimes: Runtime[];
34
50
  db: {
35
51
  odms: DbOdm[];
36
52
  drivers: DbDriver[];
@@ -31,7 +31,6 @@ function validateProjectName(name, cwd = process.cwd()) {
31
31
  const trimmed = name.trim();
32
32
  if (!trimmed) return "Project name is required";
33
33
  if (trimmed.includes("..")) return "Project name cannot contain \"..\"";
34
- if (trimmed.includes("/") || trimmed.includes("\\")) return "Project name cannot contain path separators";
35
34
  if (trimmed.startsWith(".") || trimmed.endsWith(".")) return "Project name cannot start or end with a dot";
36
35
  const baseName = trimmed.split(".")[0]?.toUpperCase();
37
36
  if (baseName && RESERVED_WINDOWS_NAMES.has(baseName)) return `Project name "${trimmed}" is reserved on Windows`;
@@ -1 +1 @@
1
- {"version":3,"file":"validate-project-name.cjs","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,UAAA,QAAK,QAAQ,KAAK,OAAO;CAC3C,MAAM,WAAW,UAAA,QAAK,SAAS,KAAK,SAAS;CAC7C,IAAI,SAAS,WAAW,IAAI,KAAK,UAAA,QAAK,WAAW,QAAQ,GACvD,OAAO;AAIX"}
1
+ {"version":3,"file":"validate-project-name.cjs","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,UAAA,QAAK,QAAQ,KAAK,OAAO;CAC3C,MAAM,WAAW,UAAA,QAAK,SAAS,KAAK,SAAS;CAC7C,IAAI,SAAS,WAAW,IAAI,KAAK,UAAA,QAAK,WAAW,QAAQ,GACvD,OAAO;AAIX"}
@@ -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,7 +107,10 @@ export const t = createTaserApp({
202
107
  `;
203
108
  }
204
109
  //#endregion
205
- exports.indexTemplate = indexTemplate;
110
+ exports.FRAMEWORK_ENTRIES = FRAMEWORK_ENTRIES;
111
+ exports.nitroConfigTemplate = nitroConfigTemplate;
112
+ exports.serverEntryTemplate = serverEntryTemplate;
206
113
  exports.taserTsTemplate = taserTsTemplate;
114
+ exports.viteConfigTemplate = viteConfigTemplate;
207
115
 
208
116
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","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.cjs","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,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,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';
@@ -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,83 +82,17 @@ 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
97
  exports.contextTemplate = contextTemplate;
180
98
  exports.gitignoreTemplate = gitignoreTemplate;
@@ -182,8 +100,6 @@ exports.healthRouteTemplate = healthRouteTemplate;
182
100
  exports.indexRouteTemplate = indexRouteTemplate;
183
101
  exports.packageJsonTemplate = packageJsonTemplate;
184
102
  exports.rootLayoutTemplate = rootLayoutTemplate;
185
- exports.starterManifestTemplate = starterManifestTemplate;
186
103
  exports.tsconfigTemplate = tsconfigTemplate;
187
- exports.tsdownConfigTemplate = tsdownConfigTemplate;
188
104
 
189
105
  //# sourceMappingURL=base.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.cjs","names":[],"sources":["../../../src/templates/base.ts"],"sourcesContent":["import type { BootBinding } from \"../addons/types.js\";\nimport type { ScaffoldContext } from \"../core/types.js\";\n\nexport function packageJsonTemplate(\n projectName: string,\n scripts: Record<string, string> = {},\n): string {\n const pkg = {\n name: projectName,\n version: \"1.0.0\",\n private: true,\n type: \"module\",\n imports: {\n \"#src/*\": \"./src/*\",\n },\n scripts: {\n dev: \"run-p dev:server dev:taser\",\n \"dev:server\": \"tsx watch src/index.ts\",\n \"dev:taser\": \"taser watch\",\n start: \"tsx src/index.ts\",\n generate: \"taser generate\",\n build: \"taser generate && tsdown\",\n serve: \"node dist/index.mjs\",\n typecheck: \"tsc --noEmit -p tsconfig.json\",\n ...scripts,\n },\n };\n\n return `${JSON.stringify(pkg, null, 2)}\\n`;\n}\n\nexport function tsdownConfigTemplate(): string {\n return `import { defineConfig } from 'tsdown'\n\nexport default defineConfig({\n entry: ['./src/index.ts'],\n platform: 'node',\n outDir: 'dist',\n clean: true,\n sourcemap: true,\n})\n`;\n}\n\nexport function tsconfigTemplate(): string {\n return `${JSON.stringify(\n {\n compilerOptions: {\n target: \"ES2022\",\n module: \"NodeNext\",\n paths: {\n \"#src/*\": [\"./src/*\"],\n },\n strict: true,\n skipLibCheck: true,\n verbatimModuleSyntax: true,\n isolatedModules: true,\n noEmit: true,\n types: [\"node\"],\n },\n include: [\"src\"],\n },\n null,\n 2,\n )}\\n`;\n}\n\nexport function gitignoreTemplate(): string {\n return `node_modules\ndist\n.DS_Store\n*.log\n.env\nlocal.db\ndrizzle\n`;\n}\n\nexport function contextTemplate(bindings: BootBinding[]): string {\n const imports = bindings.map(\n (binding) => `import { ${binding.factoryName} } from '${binding.importPath}'`,\n );\n\n const bootBody =\n bindings.length > 0\n ? bindings.map((binding) => ` ${binding.key}: ${binding.factoryName}(),`).join(\"\\n\")\n : \"\";\n\n const bootBlock = bindings.length > 0 ? ` boot: () => ({\\n${bootBody}\\n }),` : \"\";\n\n const importBlock = imports.length > 0 ? `${imports.join(\"\\n\")}\\n\\n` : \"\";\n\n return `${importBlock}import { createContext } from '@taserjs/router'\n\nexport const context = createContext({\n${bootBlock}\n request: () => ({\n requestId: crypto.randomUUID(),\n }),\n})\n`;\n}\n\nexport function rootLayoutTemplate(): string {\n return `import { cors } from '@taserjs/router/cors'\n\nimport { t } from '#src/taser.js'\n\nexport const Middleware = t.middleware('/$')\n .use(cors())\n`;\n}\n\nexport function indexRouteTemplate(): string {\n return `import { reply } from '@taserjs/router'\nimport { t } from '#src/taser.js'\n\nconst GET = t.get('/')\n\nexport type RouteContext = typeof GET.$Infer.Context\nexport const Route = GET.handler((_ctx) => {\n return reply.json({ message: 'Welcome to Taser' })\n})\n`;\n}\n\nexport function healthRouteTemplate(ctx: ScaffoldContext): string {\n const lines: string[] = [];\n\n if (ctx.logger) {\n lines.push(\" ctx.logger.info('health check')\");\n }\n\n if (ctx.db) {\n lines.push(\" // ctx.db is available from context boot\");\n }\n\n const body = lines.length > 0 ? `${lines.join(\"\\n\")}\\n` : \"\";\n const ctxArg = lines.length > 0 ? \"(ctx)\" : \"(_ctx)\";\n\n return `import { reply } from '@taserjs/router'\nimport { t } from '#src/taser.js'\n\nconst GET = t.get('/health')\n\nexport type RouteContext = typeof GET.$Infer.Context\nexport const Route = GET.handler(${ctxArg} => {\n${body} return reply.json({ ok: true })\n})\n`;\n}\n\n/** Minimal placeholder until `taser generate` runs. */\nexport function starterManifestTemplate(): string {\n return `/* eslint-disable */\n// Run \\`pnpm generate\\` (taser generate) to replace this file.\nimport { Middleware as RootSplatLayoutImport } from './routes/$.js'\nimport { Route as RootIndexGetRouteImport } from './routes/index.get.js'\nimport { Route as HealthGetRouteImport } from './routes/health.get.js'\n\nexport const routeManifest = {\n layouts: {\n '/$': {\n middlewares: RootSplatLayoutImport,\n },\n },\n routes: {\n '/': {\n GET: {\n layoutChain: ['/$'],\n route: RootIndexGetRouteImport,\n },\n },\n '/health': {\n GET: {\n layoutChain: ['/$'],\n route: HealthGetRouteImport,\n },\n },\n },\n} as const\n\nexport type RoutePathGen = '/' | '/health'\nexport type LayoutIdGen = '/$'\nexport type LayoutTreeGen = {\n '/$': {\n parent: null\n middlewares: typeof RootSplatLayoutImport\n }\n}\nexport type RouteByPathMethodGen = {\n '/': {\n GET: {\n parent: '/$'\n layoutChain: ['/$']\n route: typeof RootIndexGetRouteImport\n }\n }\n '/health': {\n GET: {\n parent: '/$'\n layoutChain: ['/$']\n route: typeof HealthGetRouteImport\n }\n }\n}\nexport type RouteManifest = typeof routeManifest\n\ndeclare module '@taserjs/router' {\n interface RouterRegister {\n RoutePath: RoutePathGen\n LayoutId: LayoutIdGen\n LayoutTree: LayoutTreeGen\n RouteByPathMethod: RouteByPathMethodGen\n }\n}\n`;\n}\n"],"mappings":";AAGA,SAAgB,oBACd,aACA,UAAkC,CAAC,GAC3B;CACR,MAAM,MAAM;EACV,MAAM;EACN,SAAS;EACT,SAAS;EACT,MAAM;EACN,SAAS,EACP,UAAU,UACZ;EACA,SAAS;GACP,KAAK;GACL,cAAc;GACd,aAAa;GACb,OAAO;GACP,UAAU;GACV,OAAO;GACP,OAAO;GACP,WAAW;GACX,GAAG;EACL;CACF;CAEA,OAAO,GAAG,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE;AACzC;AAEA,SAAgB,uBAA+B;CAC7C,OAAO;;;;;;;;;;AAUT;AAEA,SAAgB,mBAA2B;CACzC,OAAO,GAAG,KAAK,UACb;EACE,iBAAiB;GACf,QAAQ;GACR,QAAQ;GACR,OAAO,EACL,UAAU,CAAC,SAAS,EACtB;GACA,QAAQ;GACR,cAAc;GACd,sBAAsB;GACtB,iBAAiB;GACjB,QAAQ;GACR,OAAO,CAAC,MAAM;EAChB;EACA,SAAS,CAAC,KAAK;CACjB,GACA,MACA,CACF,EAAE;AACJ;AAEA,SAAgB,oBAA4B;CAC1C,OAAO;;;;;;;;AAQT;AAEA,SAAgB,gBAAgB,UAAiC;CAC/D,MAAM,UAAU,SAAS,KACtB,YAAY,YAAY,QAAQ,YAAY,WAAW,QAAQ,WAAW,EAC7E;CAEA,MAAM,WACJ,SAAS,SAAS,IACd,SAAS,KAAK,YAAY,OAAO,QAAQ,IAAI,IAAI,QAAQ,YAAY,IAAI,CAAC,CAAC,KAAK,IAAI,IACpF;CAEN,MAAM,YAAY,SAAS,SAAS,IAAI,qBAAqB,SAAS,WAAW;CAIjF,OAAO,GAFa,QAAQ,SAAS,IAAI,GAAG,QAAQ,KAAK,IAAI,EAAE,QAAQ,GAEjD;;;EAGtB,UAAU;;;;;;AAMZ;AAEA,SAAgB,qBAA6B;CAC3C,OAAO;;;;;;;AAOT;AAEA,SAAgB,qBAA6B;CAC3C,OAAO;;;;;;;;;;AAUT;AAEA,SAAgB,oBAAoB,KAA8B;CAChE,MAAM,QAAkB,CAAC;CAEzB,IAAI,IAAI,QACN,MAAM,KAAK,mCAAmC;CAGhD,IAAI,IAAI,IACN,MAAM,KAAK,4CAA4C;CAGzD,MAAM,OAAO,MAAM,SAAS,IAAI,GAAG,MAAM,KAAK,IAAI,EAAE,MAAM;CAG1D,OAAO;;;;;;mCAFQ,MAAM,SAAS,IAAI,UAAU,SAQJ;EACxC,KAAK;;;AAGP;;AAGA,SAAgB,0BAAkC;CAChD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DT"}
1
+ {"version":3,"file":"base.cjs","names":[],"sources":["../../../src/templates/base.ts"],"sourcesContent":["import type { BootBinding } from \"../addons/types.js\";\nimport type { ScaffoldContext } from \"../core/types.js\";\n\nexport function packageJsonTemplate(\n projectName: string,\n scripts: Record<string, string> = {},\n): string {\n const pkg = {\n name: projectName,\n version: \"1.0.0\",\n private: true,\n type: \"module\",\n imports: {\n \"#taserjs/router\": \"./src/taser.ts\",\n },\n scripts: {\n dev: \"vite\",\n build: \"vite build\",\n typecheck: \"tsc --noEmit -p tsconfig.json\",\n ...scripts,\n },\n };\n\n return `${JSON.stringify(pkg, null, 2)}\\n`;\n}\n\nexport function tsconfigTemplate(): string {\n return `${JSON.stringify(\n {\n compilerOptions: {\n target: \"ES2022\",\n module: \"NodeNext\",\n paths: {\n \"#taserjs/router\": [\"./src/taser.ts\"],\n },\n strict: true,\n skipLibCheck: true,\n verbatimModuleSyntax: true,\n isolatedModules: true,\n noEmit: true,\n },\n include: [\"src\", \".taser/types/**/*.d.ts\"],\n },\n null,\n 2,\n )}\\n`;\n}\n\nexport function gitignoreTemplate(): string {\n return `node_modules\ndist\n.output\n.taser\n.DS_Store\n*.log\n.env\nlocal.db\ndrizzle\n`;\n}\n\nexport function contextTemplate(bindings: BootBinding[]): string {\n const imports = bindings.map(\n (binding) => `import { ${binding.factoryName} } from '${binding.importPath}'`,\n );\n\n const bootBody =\n bindings.length > 0\n ? bindings.map((binding) => ` ${binding.key}: ${binding.factoryName}(),`).join(\"\\n\")\n : \"\";\n\n const bootBlock = bindings.length > 0 ? ` boot: () => ({\\n${bootBody}\\n }),` : \"\";\n\n const importBlock = imports.length > 0 ? `${imports.join(\"\\n\")}\\n\\n` : \"\";\n\n return `${importBlock}import { createContext } from '@taserjs/router'\n\nexport const context = createContext({\n${bootBlock}\n request: () => ({\n requestId: crypto.randomUUID(),\n }),\n})\n`;\n}\n\nexport function rootLayoutTemplate(): string {\n return `import { cors } from '@taserjs/router/cors'\n\nimport { t } from '#taserjs/router'\n\nexport const Middleware = t.middleware('/$')\n .use(cors())\n`;\n}\n\nexport function indexRouteTemplate(): string {\n return `import { json } from '@taserjs/router/reply'\nimport { t } from '#taserjs/router'\n\nconst GET = t.get('/')\n\nexport type RouteContext = typeof GET.$Infer.Context\nexport const Route = GET.handler((_ctx) => {\n return json({ message: 'Welcome to Taser' })\n})\n`;\n}\n\nexport function healthRouteTemplate(ctx: ScaffoldContext): string {\n const lines: string[] = [];\n\n if (ctx.logger) {\n lines.push(\" ctx.logger.info('health check')\");\n }\n\n if (ctx.db) {\n lines.push(\" // ctx.db is available from context boot\");\n }\n\n const body = lines.length > 0 ? `${lines.join(\"\\n\")}\\n` : \"\";\n const ctxArg = lines.length > 0 ? \"(ctx)\" : \"(_ctx)\";\n\n return `import { json } from '@taserjs/router/reply'\nimport { t } from '#taserjs/router'\n\nconst GET = t.get('/health')\n\nexport type RouteContext = typeof GET.$Infer.Context\nexport const Route = GET.handler(${ctxArg} => {\n${body} return json({ ok: true })\n})\n`;\n}\n"],"mappings":";AAGA,SAAgB,oBACd,aACA,UAAkC,CAAC,GAC3B;CACR,MAAM,MAAM;EACV,MAAM;EACN,SAAS;EACT,SAAS;EACT,MAAM;EACN,SAAS,EACP,mBAAmB,iBACrB;EACA,SAAS;GACP,KAAK;GACL,OAAO;GACP,WAAW;GACX,GAAG;EACL;CACF;CAEA,OAAO,GAAG,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE;AACzC;AAEA,SAAgB,mBAA2B;CACzC,OAAO,GAAG,KAAK,UACb;EACE,iBAAiB;GACf,QAAQ;GACR,QAAQ;GACR,OAAO,EACL,mBAAmB,CAAC,gBAAgB,EACtC;GACA,QAAQ;GACR,cAAc;GACd,sBAAsB;GACtB,iBAAiB;GACjB,QAAQ;EACV;EACA,SAAS,CAAC,OAAO,wBAAwB;CAC3C,GACA,MACA,CACF,EAAE;AACJ;AAEA,SAAgB,oBAA4B;CAC1C,OAAO;;;;;;;;;;AAUT;AAEA,SAAgB,gBAAgB,UAAiC;CAC/D,MAAM,UAAU,SAAS,KACtB,YAAY,YAAY,QAAQ,YAAY,WAAW,QAAQ,WAAW,EAC7E;CAEA,MAAM,WACJ,SAAS,SAAS,IACd,SAAS,KAAK,YAAY,OAAO,QAAQ,IAAI,IAAI,QAAQ,YAAY,IAAI,CAAC,CAAC,KAAK,IAAI,IACpF;CAEN,MAAM,YAAY,SAAS,SAAS,IAAI,qBAAqB,SAAS,WAAW;CAIjF,OAAO,GAFa,QAAQ,SAAS,IAAI,GAAG,QAAQ,KAAK,IAAI,EAAE,QAAQ,GAEjD;;;EAGtB,UAAU;;;;;;AAMZ;AAEA,SAAgB,qBAA6B;CAC3C,OAAO;;;;;;;AAOT;AAEA,SAAgB,qBAA6B;CAC3C,OAAO;;;;;;;;;;AAUT;AAEA,SAAgB,oBAAoB,KAA8B;CAChE,MAAM,QAAkB,CAAC;CAEzB,IAAI,IAAI,QACN,MAAM,KAAK,mCAAmC;CAGhD,IAAI,IAAI,IACN,MAAM,KAAK,4CAA4C;CAGzD,MAAM,OAAO,MAAM,SAAS,IAAI,GAAG,MAAM,KAAK,IAAI,EAAE,MAAM;CAG1D,OAAO;;;;;;mCAFQ,MAAM,SAAS,IAAI,UAAU,SAQJ;EACxC,KAAK;;;AAGP"}
@@ -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;