create-taserjs 0.0.6 → 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.
Files changed (82) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/addons/registry.cjs +3 -1
  3. package/dist/cjs/addons/registry.cjs.map +1 -1
  4. package/dist/cjs/addons/validators.cjs +10 -13
  5. package/dist/cjs/addons/validators.cjs.map +1 -1
  6. package/dist/cjs/cli.cjs +7 -5
  7. package/dist/cjs/cli.cjs.map +1 -1
  8. package/dist/cjs/commands/create.cjs +68 -48
  9. package/dist/cjs/commands/create.cjs.map +1 -1
  10. package/dist/cjs/commands/create.d.cts +2 -1
  11. package/dist/cjs/core/parse-options.cjs +48 -22
  12. package/dist/cjs/core/parse-options.cjs.map +1 -1
  13. package/dist/cjs/core/parse-options.d.cts +19 -4
  14. package/dist/cjs/core/project-config.cjs +5 -1
  15. package/dist/cjs/core/project-config.cjs.map +1 -1
  16. package/dist/cjs/core/resolve-packages.cjs +28 -66
  17. package/dist/cjs/core/resolve-packages.cjs.map +1 -1
  18. package/dist/cjs/core/resolve-packages.d.cts +1 -4
  19. package/dist/cjs/core/scaffold-engine.cjs +16 -27
  20. package/dist/cjs/core/scaffold-engine.cjs.map +1 -1
  21. package/dist/cjs/core/targets.cjs +162 -0
  22. package/dist/cjs/core/targets.cjs.map +1 -0
  23. package/dist/cjs/core/targets.d.cts +49 -0
  24. package/dist/cjs/core/types.cjs +21 -11
  25. package/dist/cjs/core/types.cjs.map +1 -1
  26. package/dist/cjs/core/types.d.cts +20 -4
  27. package/dist/cjs/frameworks/index.cjs +75 -174
  28. package/dist/cjs/frameworks/index.cjs.map +1 -1
  29. package/dist/cjs/frameworks/index.d.cts +18 -3
  30. package/dist/cjs/scaffold.d.cts +2 -2
  31. package/dist/cjs/templates/base.cjs +15 -99
  32. package/dist/cjs/templates/base.cjs.map +1 -1
  33. package/dist/cjs/templates/base.d.cts +0 -3
  34. package/dist/cjs/types.d.cts +1 -1
  35. package/dist/esm/addons/registry.js +4 -2
  36. package/dist/esm/addons/registry.js.map +1 -1
  37. package/dist/esm/addons/validators.js +10 -13
  38. package/dist/esm/addons/validators.js.map +1 -1
  39. package/dist/esm/cli.js +7 -5
  40. package/dist/esm/cli.js.map +1 -1
  41. package/dist/esm/commands/create.d.ts +2 -1
  42. package/dist/esm/commands/create.js +70 -50
  43. package/dist/esm/commands/create.js.map +1 -1
  44. package/dist/esm/core/parse-options.d.ts +19 -4
  45. package/dist/esm/core/parse-options.js +47 -23
  46. package/dist/esm/core/parse-options.js.map +1 -1
  47. package/dist/esm/core/project-config.js +5 -1
  48. package/dist/esm/core/project-config.js.map +1 -1
  49. package/dist/esm/core/resolve-packages.d.ts +1 -4
  50. package/dist/esm/core/resolve-packages.js +28 -66
  51. package/dist/esm/core/resolve-packages.js.map +1 -1
  52. package/dist/esm/core/scaffold-engine.js +18 -29
  53. package/dist/esm/core/scaffold-engine.js.map +1 -1
  54. package/dist/esm/core/targets.d.ts +49 -0
  55. package/dist/esm/core/targets.js +157 -0
  56. package/dist/esm/core/targets.js.map +1 -0
  57. package/dist/esm/core/types.d.ts +20 -4
  58. package/dist/esm/core/types.js +19 -11
  59. package/dist/esm/core/types.js.map +1 -1
  60. package/dist/esm/frameworks/index.d.ts +18 -3
  61. package/dist/esm/frameworks/index.js +72 -174
  62. package/dist/esm/frameworks/index.js.map +1 -1
  63. package/dist/esm/scaffold.d.ts +2 -2
  64. package/dist/esm/templates/base.d.ts +0 -3
  65. package/dist/esm/templates/base.js +16 -98
  66. package/dist/esm/templates/base.js.map +1 -1
  67. package/dist/esm/types.d.ts +1 -1
  68. package/package.json +3 -2
  69. package/src/addons/registry.ts +6 -2
  70. package/src/addons/validators.ts +10 -13
  71. package/src/cli.ts +6 -4
  72. package/src/commands/create.ts +82 -26
  73. package/src/core/parse-options.ts +84 -35
  74. package/src/core/project-config.ts +6 -1
  75. package/src/core/resolve-packages.ts +38 -76
  76. package/src/core/scaffold-engine.ts +41 -65
  77. package/src/core/targets.ts +202 -0
  78. package/src/core/types.ts +38 -24
  79. package/src/frameworks/index.ts +74 -182
  80. package/src/scaffold.ts +2 -2
  81. package/src/templates/base.ts +14 -98
  82. package/src/types.ts +3 -1
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Registry for the three scaffold dimensions — runtime, framework, deploy —
3
+ * plus the compatibility rules between them.
4
+ *
5
+ * Dependency direction: deploy implies the runtime family; the effective
6
+ * runtime constrains which frameworks can run. `--runtime` is an override
7
+ * available only where it is meaningful (self-hosted node-family targets).
8
+ */
9
+ import { DEPLOY_TARGETS, type DeployTarget, type Framework, type Runtime } from "./types.js";
10
+
11
+ export type PlatformFile = {
12
+ name: string;
13
+ content: string | ((ctx: { projectName: string }) => string);
14
+ };
15
+
16
+ export type DeployEntry = {
17
+ id: DeployTarget;
18
+ /** Runtime this target builds for ("workerd" = Cloudflare's V8 runtime). */
19
+ impliedRuntime: Runtime | "workerd";
20
+ /** Whether the built output is a long-running server you start locally. */
21
+ selfHosted: boolean;
22
+ /** `start` script value; null for platform-deployed targets. */
23
+ startScript: string | null;
24
+ /** Runtime/platform tooling devDependencies beyond the base set. */
25
+ devDeps: string[];
26
+ files: PlatformFile[];
27
+ };
28
+
29
+ const NODE_START = "node .output/server/index.mjs";
30
+
31
+ export const DEPLOY_ENTRIES: Record<DeployTarget, DeployEntry> = {
32
+ "node-server": {
33
+ id: "node-server",
34
+ impliedRuntime: "node",
35
+ selfHosted: true,
36
+ startScript: NODE_START,
37
+ devDeps: [],
38
+ files: [],
39
+ },
40
+ "node-cluster": {
41
+ id: "node-cluster",
42
+ impliedRuntime: "node",
43
+ selfHosted: true,
44
+ startScript: NODE_START,
45
+ devDeps: [],
46
+ files: [],
47
+ },
48
+ bun: {
49
+ id: "bun",
50
+ impliedRuntime: "bun",
51
+ selfHosted: true,
52
+ startScript: "bun .output/server/index.mjs",
53
+ devDeps: ["@types/bun"],
54
+ files: [],
55
+ },
56
+ "deno-server": {
57
+ id: "deno-server",
58
+ impliedRuntime: "deno",
59
+ selfHosted: true,
60
+ startScript: "deno run -A .output/server/index.mjs",
61
+ devDeps: [],
62
+ files: [],
63
+ },
64
+ "deno-deploy": {
65
+ id: "deno-deploy",
66
+ impliedRuntime: "deno",
67
+ selfHosted: false,
68
+ startScript: null,
69
+ devDeps: [],
70
+ files: [],
71
+ },
72
+ "cloudflare-module": {
73
+ id: "cloudflare-module",
74
+ impliedRuntime: "workerd",
75
+ selfHosted: false,
76
+ startScript: null,
77
+ devDeps: ["wrangler", "@cloudflare/workers-types"],
78
+ files: [
79
+ {
80
+ name: "wrangler.jsonc",
81
+ content: ({ projectName }) =>
82
+ `${JSON.stringify(
83
+ {
84
+ $schema: "node_modules/wrangler/config-schema.json",
85
+ name: projectName,
86
+ main: ".output/server/index.mjs",
87
+ compatibility_date: "2024-11-01",
88
+ },
89
+ null,
90
+ 2,
91
+ )}\n`,
92
+ },
93
+ ],
94
+ },
95
+ vercel: {
96
+ id: "vercel",
97
+ impliedRuntime: "node",
98
+ selfHosted: false,
99
+ startScript: null,
100
+ devDeps: ["@vercel/node"],
101
+ files: [],
102
+ },
103
+ "aws-lambda": {
104
+ id: "aws-lambda",
105
+ impliedRuntime: "node",
106
+ selfHosted: false,
107
+ startScript: null,
108
+ devDeps: ["@types/aws-lambda"],
109
+ files: [],
110
+ },
111
+ netlify: {
112
+ id: "netlify",
113
+ impliedRuntime: "node",
114
+ selfHosted: false,
115
+ startScript: null,
116
+ devDeps: [],
117
+ files: [],
118
+ },
119
+ };
120
+
121
+ /** Runtimes a `--runtime` override may select per self-hosted deploy target. */
122
+ const RUNTIME_OVERRIDES: Partial<Record<DeployTarget, readonly Runtime[]>> = {
123
+ "node-server": ["node", "bun"],
124
+ "node-cluster": ["node", "bun"],
125
+ };
126
+
127
+ export const DEFAULT_DEPLOY: DeployTarget = "node-server";
128
+ export const DEFAULT_FRAMEWORK: Framework = "none";
129
+
130
+ export function isCuratedDeploy(value: string): value is DeployTarget {
131
+ return (DEPLOY_TARGETS as readonly string[]).includes(value);
132
+ }
133
+
134
+ /**
135
+ * Resolves any preset id to its emission entry. Curated ids come from the
136
+ * registry; unknown strings pass through to Nitro verbatim as non-self-hosted
137
+ * node-family targets.
138
+ */
139
+ export function resolveDeployEntry(id: string): { entry: DeployEntry; curated: boolean } {
140
+ if (isCuratedDeploy(id)) {
141
+ return { entry: DEPLOY_ENTRIES[id], curated: true };
142
+ }
143
+ return {
144
+ entry: {
145
+ // Cast: passthrough ids are valid Nitro PresetNameInputs by contract.
146
+ id: id as DeployTarget,
147
+ impliedRuntime: "node",
148
+ selfHosted: false,
149
+ startScript: null,
150
+ devDeps: [],
151
+ files: [],
152
+ },
153
+ curated: false,
154
+ };
155
+ }
156
+
157
+ /** Runtime overrides permitted for a deploy target; empty = no override. */
158
+ export function allowedRuntimeOverrides(id: DeployTarget): readonly Runtime[] {
159
+ return RUNTIME_OVERRIDES[id] ?? [];
160
+ }
161
+
162
+ export type CombinationError = { ok: false; reason: string };
163
+ export type CombinationOk = { ok: true; runtime: Runtime | "workerd" };
164
+
165
+ /**
166
+ * Validates a runtime × framework × deploy combination.
167
+ *
168
+ * @param runtimeOverride explicit `--runtime` selection, if any
169
+ * @param deploy preset id (curated or passthrough)
170
+ */
171
+ export function validateCombination(
172
+ runtimeOverride: Runtime | undefined,
173
+ framework: Framework,
174
+ deploy: string,
175
+ ): CombinationOk | CombinationError {
176
+ const { entry } = resolveDeployEntry(deploy);
177
+
178
+ if (runtimeOverride !== undefined) {
179
+ const allowed = entry.selfHosted ? allowedRuntimeOverrides(entry.id) : [];
180
+ if (!allowed.includes(runtimeOverride)) {
181
+ return {
182
+ ok: false,
183
+ reason:
184
+ `Runtime "${runtimeOverride}" is not valid for deploy target "${entry.id}". ` +
185
+ (allowed.length > 0
186
+ ? `Allowed overrides: ${allowed.join(", ")}.`
187
+ : `It implies runtime "${String(entry.impliedRuntime)}".`),
188
+ };
189
+ }
190
+ }
191
+
192
+ const effective = runtimeOverride ?? entry.impliedRuntime;
193
+
194
+ if ((framework === "express" || framework === "fastify") && effective !== "node") {
195
+ return {
196
+ ok: false,
197
+ reason: `Framework "${framework}" requires the Node runtime, but deploy target "${entry.id}" implies "${String(effective)}".`,
198
+ };
199
+ }
200
+
201
+ return { ok: true, runtime: effective };
202
+ }
package/src/core/types.ts CHANGED
@@ -1,32 +1,39 @@
1
1
  import type { Agent } from "package-manager-detector";
2
2
 
3
- export type ProjectType =
4
- | "node"
5
- | "express"
6
- | "fastify"
7
- | "hono"
3
+ /** Host framework layered on top of pure Taser pass-through dispatch. */
4
+ export type Framework = "none" | "hono" | "express" | "fastify";
5
+
6
+ export const FRAMEWORKS: readonly Framework[] = ["none", "hono", "express", "fastify"];
7
+
8
+ export type Runtime = "node" | "bun" | "deno";
9
+
10
+ export const RUNTIMES: readonly Runtime[] = ["node", "bun", "deno"];
11
+
12
+ /**
13
+ * Deployment target. Values are Nitro preset ids (see `nitro/config`
14
+ * PresetNameInput) so `--preset` passes straight through to Nitro.
15
+ */
16
+ export type DeployTarget =
17
+ | "node-server"
18
+ | "node-cluster"
8
19
  | "bun"
9
- | "deno"
10
- | "aws-lambda"
11
- | "cloudflare-workers"
12
- | "netlify"
20
+ | "deno-server"
21
+ | "deno-deploy"
22
+ | "cloudflare-module"
13
23
  | "vercel"
14
- | "azure-functions"
15
- | "google-cloud-run";
16
-
17
- export const PROJECT_TYPES: readonly ProjectType[] = [
18
- "node",
19
- "express",
20
- "fastify",
21
- "hono",
24
+ | "aws-lambda"
25
+ | "netlify";
26
+
27
+ export const DEPLOY_TARGETS: readonly DeployTarget[] = [
28
+ "node-server",
29
+ "node-cluster",
22
30
  "bun",
23
- "deno",
31
+ "deno-server",
32
+ "deno-deploy",
33
+ "cloudflare-module",
34
+ "vercel",
24
35
  "aws-lambda",
25
- "cloudflare-workers",
26
36
  "netlify",
27
- "vercel",
28
- "azure-functions",
29
- "google-cloud-run",
30
37
  ];
31
38
 
32
39
  export type DbOdm = "drizzle" | "prisma" | "kysely";
@@ -56,7 +63,12 @@ export type PackageGroups = {
56
63
  export type ScaffoldContext = {
57
64
  projectName: string;
58
65
  targetDir: string;
59
- type: ProjectType;
66
+ /** Host framework; "none" is pure Taser pass-through dispatch. Defaults to "none". */
67
+ framework?: Framework;
68
+ /** Deployment target — a Nitro preset id. Defaults to "node-server". */
69
+ preset?: DeployTarget;
70
+ /** Set only when explicitly overriding the runtime implied by the preset. */
71
+ runtime?: Runtime;
60
72
  db?: DbOdm;
61
73
  driver?: DbDriver;
62
74
  logger?: LoggerId;
@@ -71,7 +83,9 @@ export type ScaffoldOptions = ScaffoldContext & {
71
83
  export type ScaffoldResult = ScaffoldContext;
72
84
 
73
85
  export type CapabilitiesCatalog = {
74
- types: ProjectType[];
86
+ frameworks: Framework[];
87
+ deployTargets: DeployTarget[];
88
+ runtimes: Runtime[];
75
89
  db: {
76
90
  odms: DbOdm[];
77
91
  drivers: DbDriver[];
@@ -1,215 +1,107 @@
1
- import type { ProjectType } from "../core/types.js";
1
+ import type { Framework } from "../core/types.js";
2
2
 
3
- export function indexTemplate(type: ProjectType): string {
4
- switch (type) {
5
- case "express":
6
- return `import 'dotenv/config'
3
+ export function serverEntryTemplate(
4
+ framework: Framework,
5
+ ): { fileName: string; content: string } | null {
6
+ switch (framework) {
7
+ case "hono":
8
+ return {
9
+ fileName: "src/server.ts",
10
+ content: `import { Hono } from 'hono'
7
11
 
8
- import express from 'express'
9
- import { createExpressHandler } from '@taserjs/adapter-express'
12
+ const app = new Hono()
10
13
 
11
- import { routeManifest } from '#src/routeManifest.gen.js'
12
- import { t } from '#src/taser.js'
14
+ app.get('/host', (c) => {
15
+ return c.text('Hello from Hono host!')
16
+ })
13
17
 
14
- const router = t.create(routeManifest)
18
+ export default app
19
+ `,
20
+ };
21
+ case "express":
22
+ return {
23
+ fileName: "src/server.node.ts",
24
+ content: `import express from 'express'
15
25
 
16
- const taser = createExpressHandler(router)
17
26
  const app = express()
18
- taser.mount('/{*splat}', app)
19
27
 
20
- const port = Number(process.env.PORT ?? 3000)
21
- app.listen(port, () => {
22
- console.log(\`Express listening on http://localhost:\${port}\`)
28
+ app.get('/host', (_req, res) => {
29
+ res.json({ message: 'Hello from Express host!' })
23
30
  })
24
- `;
25
- case "hono":
26
- return `import 'dotenv/config'
27
-
28
- import { serve } from '@hono/node-server'
29
- import { Hono } from 'hono'
30
-
31
- import { routeManifest } from '#src/routeManifest.gen.js'
32
- import { t } from '#src/taser.js'
33
31
 
34
- const router = t.create(routeManifest)
35
-
36
- const app = new Hono()
37
- app.all('/*', c => router.fetch(c.req.raw))
38
-
39
- const port = Number(process.env.PORT ?? 3000)
40
- serve({ fetch: app.fetch, port }, () => {
41
- console.log(\`Hono listening on http://localhost:\${port}\`)
42
- })
43
- `;
32
+ export default app
33
+ `,
34
+ };
44
35
  case "fastify":
45
- return `import 'dotenv/config'
36
+ return {
37
+ fileName: "src/server.node.ts",
38
+ content: `import Fastify from 'fastify'
46
39
 
47
- import Fastify from 'fastify'
48
- import { createFastifyHandler } from '@taserjs/adapter-fastify'
49
-
50
- import { routeManifest } from '#src/routeManifest.gen.js'
51
- import { t } from '#src/taser.js'
52
-
53
- const router = t.create(routeManifest)
54
-
55
- const taser = createFastifyHandler(router)
56
40
  const app = Fastify()
57
- taser.mount('/*', app)
58
41
 
59
- const port = Number(process.env.PORT ?? 3000)
60
- await app.listen({ port })
61
- console.log(\`Fastify listening on http://localhost:\${port}\`)
62
- `;
63
- case "bun":
64
- return `import 'dotenv/config'
65
-
66
- import { routeManifest } from '#src/routeManifest.gen.js'
67
- import { t } from '#src/taser.js'
68
-
69
- const router = t.create(routeManifest)
42
+ app.get('/host', async () => {
43
+ return { message: 'Hello from Fastify host!' }
44
+ })
70
45
 
71
- const port = Number(process.env.PORT ?? 3000)
46
+ await app.ready()
72
47
 
73
- export default {
74
- port,
75
- fetch(request: Request) {
76
- return router.fetch(request)
77
- },
48
+ export default app.routing
49
+ `,
50
+ };
51
+ default:
52
+ return null;
53
+ }
78
54
  }
79
- `;
80
- case "deno":
81
- return `import 'dotenv/config'
82
-
83
- import { routeManifest } from '#src/routeManifest.gen.js'
84
- import { t } from '#src/taser.js'
85
-
86
- const router = t.create(routeManifest)
87
55
 
88
- const port = Number(process.env.PORT ?? 8000)
89
- Deno.serve({ port }, (request: Request) => router.fetch(request))
90
- `;
91
- case "aws-lambda":
92
- return `import 'dotenv/config'
93
-
94
- import { Hono } from 'hono'
95
- import { handle } from 'hono/aws-lambda'
96
-
97
- import { routeManifest } from '#src/routeManifest.gen.js'
98
- import { t } from '#src/taser.js'
99
-
100
- const router = t.create(routeManifest)
101
-
102
- const app = new Hono()
103
- app.all('/*', c => router.fetch(c.req.raw))
104
-
105
- export const handler = handle(app)
106
- `;
107
- case "cloudflare-workers":
108
- return `import 'dotenv/config'
109
-
110
- import { routeManifest } from '#src/routeManifest.gen.js'
111
- import { t } from '#src/taser.js'
112
-
113
- const router = t.create(routeManifest)
114
-
115
- export default {
116
- fetch(request: Request, env: unknown, ctx: unknown) {
117
- return router.fetch(request, env, ctx)
56
+ export type FrameworkEntry = {
57
+ id: Framework;
58
+ serverEntry: { fileName: string; content: string } | null;
59
+ deps: string[];
60
+ devDeps: string[];
61
+ };
62
+
63
+ export const FRAMEWORK_ENTRIES: Record<Framework, FrameworkEntry> = {
64
+ none: { id: "none", serverEntry: null, deps: [], devDeps: [] },
65
+ hono: { id: "hono", serverEntry: serverEntryTemplate("hono"), deps: ["hono"], devDeps: [] },
66
+ express: {
67
+ id: "express",
68
+ serverEntry: serverEntryTemplate("express"),
69
+ deps: ["express", "srvx"],
70
+ devDeps: ["@types/express"],
118
71
  },
119
- }
120
- `;
121
- case "netlify":
122
- return `import 'dotenv/config'
123
-
124
- import { Hono } from 'hono'
125
- import { handle } from 'hono/netlify'
126
-
127
- import { routeManifest } from '#src/routeManifest.gen.js'
128
- import { t } from '#src/taser.js'
129
-
130
- const router = t.create(routeManifest)
131
-
132
- const app = new Hono()
133
- app.all('/*', c => router.fetch(c.req.raw))
134
-
135
- export default handle(app)
136
- `;
137
- case "vercel":
138
- return `import 'dotenv/config'
139
-
140
- import { Hono } from 'hono'
141
- import { handle } from 'hono/vercel'
142
-
143
- import { routeManifest } from '#src/routeManifest.gen.js'
144
- import { t } from '#src/taser.js'
145
-
146
- const router = t.create(routeManifest)
147
-
148
- const app = new Hono()
149
- app.all('/*', c => router.fetch(c.req.raw))
150
-
151
- export default handle(app)
152
- `;
153
- case "azure-functions":
154
- return `import 'dotenv/config'
155
-
156
- import { app } from '@azure/functions'
157
- import { Hono } from 'hono'
158
- import { azureHonoHandler } from '@marplex/hono-azurefunc-adapter'
159
-
160
- import { routeManifest } from '#src/routeManifest.gen.js'
161
- import { t } from '#src/taser.js'
162
-
163
- const router = t.create(routeManifest)
164
-
165
- const honoApp = new Hono()
166
- honoApp.all('/*', c => router.fetch(c.req.raw))
167
-
168
- app.http('httpTrigger', {
169
- methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'],
170
- authLevel: 'anonymous',
171
- route: '{*proxy}',
172
- handler: azureHonoHandler(honoApp.fetch),
173
- })
174
- `;
175
- case "google-cloud-run":
176
- return `import 'dotenv/config'
177
-
178
- import { serve } from '@hono/node-server'
179
-
180
- import { routeManifest } from '#src/routeManifest.gen.js'
181
- import { t } from '#src/taser.js'
72
+ fastify: {
73
+ id: "fastify",
74
+ // srvx bridges the Fastify Node handler to fetch (see compose codegen).
75
+ serverEntry: serverEntryTemplate("fastify"),
76
+ deps: ["fastify", "srvx"],
77
+ devDeps: [],
78
+ },
79
+ };
182
80
 
183
- const router = t.create(routeManifest)
81
+ export function nitroConfigTemplate(nitroPreset: string): string {
82
+ return `import { defineConfig } from 'nitro/config'
184
83
 
185
- const port = Number(process.env.PORT ?? 8080)
186
- serve({ fetch: router.fetch, port }, () => {
187
- console.log(\`Cloud Run listening on http://localhost:\${port}\`)
84
+ export default defineConfig({
85
+ preset: '${nitroPreset}',
188
86
  })
189
87
  `;
190
- case "node":
191
- default:
192
- return `import 'dotenv/config'
193
-
194
- import { serve } from '@hono/node-server'
195
-
196
- import { routeManifest } from '#src/routeManifest.gen.js'
197
- import { t } from '#src/taser.js'
88
+ }
198
89
 
199
- const router = t.create(routeManifest)
90
+ export function viteConfigTemplate(): string {
91
+ return `import { defineConfig } from 'vite'
92
+ import { nitro } from 'nitro/vite'
93
+ import { taser } from '@taserjs/router-plugin/vite'
200
94
 
201
- const port = Number(process.env.PORT ?? 3000)
202
- serve({ fetch: router.fetch, port }, () => {
203
- console.log(\`Node listening on http://localhost:\${port}\`)
95
+ export default defineConfig({
96
+ plugins: [taser(), nitro()],
204
97
  })
205
98
  `;
206
- }
207
99
  }
208
100
 
209
- export function taserTsTemplate(_type: ProjectType = "node"): string {
101
+ export function taserTsTemplate(): string {
210
102
  return `import { createTaserApp } from '@taserjs/router'
211
103
 
212
- import { context } from '#src/context.js'
104
+ import { context } from './context.js'
213
105
 
214
106
  export const t = createTaserApp({
215
107
  response: { validate: true },
package/src/scaffold.ts CHANGED
@@ -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";