create-taserjs 0.0.5 → 0.0.6

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.
@@ -45,14 +45,11 @@ function resolveAddons(ctx) {
45
45
  if (!loggerAddon) throw new Error(`Unknown logger addon "${ctx.logger}"`);
46
46
  selected.push(loggerAddon);
47
47
  }
48
- if (selected.filter((addon) => addon.category === "database").length > 1) throw new Error("Only one database addon can be selected");
49
- if (selected.filter((addon) => addon.category === "logger").length > 1) throw new Error("Only one logger addon can be selected");
50
48
  if (ctx.validator) {
51
49
  const validatorAddon = VALIDATOR_ADDONS.find((addon) => addon.id === ctx.validator);
52
50
  if (!validatorAddon) throw new Error(`Unknown validator addon "${ctx.validator}"`);
53
51
  selected.push(validatorAddon);
54
52
  }
55
- if (selected.filter((addon) => addon.category === "validator").length > 1) throw new Error("Only one validator addon can be selected");
56
53
  return selected;
57
54
  }
58
55
  function collectBootBindings(ctx) {
@@ -1 +1 @@
1
- {"version":3,"file":"registry.cjs","names":[],"sources":["../../../src/addons/registry.ts"],"sourcesContent":["import { arktypeAddon } from \"./arktype/index.js\";\nimport { drizzleAddon } from \"./drizzle/index.js\";\nimport { kyselyAddon } from \"./kysely/index.js\";\nimport { pinoAddon } from \"./pino/index.js\";\nimport { prismaAddon } from \"./prisma/index.js\";\nimport { valibotAddon } from \"./valibot/index.js\";\nimport { winstonAddon } from \"./winston/index.js\";\nimport { zodAddon } from \"./zod/index.js\";\nimport type { AddonDefinition } from \"./types.js\";\nimport type { CapabilitiesCatalog, ScaffoldContext } from \"../core/types.js\";\nimport {\n DB_DRIVERS,\n DB_ODMS,\n DEFAULT_DB_DRIVER,\n LOGGERS,\n PROJECT_TYPES,\n VALIDATORS,\n} from \"../core/types.js\";\n\nconst ALL_ADDONS: AddonDefinition[] = [\n drizzleAddon,\n prismaAddon,\n kyselyAddon,\n pinoAddon,\n winstonAddon,\n zodAddon,\n arktypeAddon,\n valibotAddon,\n];\n\nconst DB_ADDONS = ALL_ADDONS.filter((addon) => addon.category === \"database\");\nconst LOGGER_ADDONS = ALL_ADDONS.filter((addon) => addon.category === \"logger\");\nconst VALIDATOR_ADDONS = ALL_ADDONS.filter((addon) => addon.category === \"validator\");\n\nexport function getCapabilitiesCatalog(): CapabilitiesCatalog {\n return {\n types: [...PROJECT_TYPES],\n db: {\n odms: [...DB_ODMS],\n drivers: [...DB_DRIVERS],\n defaultDriver: DEFAULT_DB_DRIVER,\n },\n loggers: [...LOGGERS],\n validators: [...VALIDATORS],\n };\n}\n\nexport function resolveAddons(ctx: ScaffoldContext): AddonDefinition[] {\n const selected: AddonDefinition[] = [];\n\n if (ctx.db) {\n const dbAddon = DB_ADDONS.find((addon) => addon.id === ctx.db);\n if (!dbAddon) {\n throw new Error(`Unknown database addon \"${ctx.db}\"`);\n }\n selected.push(dbAddon);\n }\n\n if (ctx.logger) {\n const loggerAddon = LOGGER_ADDONS.find((addon) => addon.id === ctx.logger);\n if (!loggerAddon) {\n throw new Error(`Unknown logger addon \"${ctx.logger}\"`);\n }\n selected.push(loggerAddon);\n }\n\n const dbCount = selected.filter((addon) => addon.category === \"database\").length;\n if (dbCount > 1) {\n throw new Error(\"Only one database addon can be selected\");\n }\n\n const loggerCount = selected.filter((addon) => addon.category === \"logger\").length;\n if (loggerCount > 1) {\n throw new Error(\"Only one logger addon can be selected\");\n }\n\n if (ctx.validator) {\n const validatorAddon = VALIDATOR_ADDONS.find((addon) => addon.id === ctx.validator);\n if (!validatorAddon) {\n throw new Error(`Unknown validator addon \"${ctx.validator}\"`);\n }\n selected.push(validatorAddon);\n }\n\n const validatorCount = selected.filter((addon) => addon.category === \"validator\").length;\n if (validatorCount > 1) {\n throw new Error(\"Only one validator addon can be selected\");\n }\n\n return selected;\n}\n\nexport function collectBootBindings(ctx: ScaffoldContext) {\n return resolveAddons(ctx)\n .map((addon) => addon.bootBinding?.(ctx))\n .filter((v): v is NonNullable<typeof v> => Boolean(v));\n}\n"],"mappings":";;;;;;;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AiB,MAAM,UAAU,MAAM,OAAO,IAAI,SAAS;EAClF,IAAI,CAAC,gBACH,MAAM,IAAI,MAAM,4BAA4B,IAAI,UAAU,EAAE;EAE9D,SAAS,KAAK,cAAc;CAC9B;CAGA,IADuB,SAAS,QAAQ,UAAU,MAAM,aAAa,WAAW,CAAC,CAAC,SAC7D,GACnB,MAAM,IAAI,MAAM,0CAA0C;CAG5D,OAAO;AACT;AAEA,SAAgB,oBAAoB,KAAsB;CACxD,OAAO,cAAc,GAAG,CAAC,CACtB,KAAK,UAAU,MAAM,cAAc,GAAG,CAAC,CAAC,CACxC,QAAQ,MAAkC,QAAQ,CAAC,CAAC;AACzD"}
1
+ {"version":3,"file":"registry.cjs","names":[],"sources":["../../../src/addons/registry.ts"],"sourcesContent":["import { arktypeAddon } from \"./arktype/index.js\";\nimport { drizzleAddon } from \"./drizzle/index.js\";\nimport { kyselyAddon } from \"./kysely/index.js\";\nimport { pinoAddon } from \"./pino/index.js\";\nimport { prismaAddon } from \"./prisma/index.js\";\nimport { valibotAddon } from \"./valibot/index.js\";\nimport { winstonAddon } from \"./winston/index.js\";\nimport { zodAddon } from \"./zod/index.js\";\nimport type { AddonDefinition } from \"./types.js\";\nimport type { CapabilitiesCatalog, ScaffoldContext } from \"../core/types.js\";\nimport {\n DB_DRIVERS,\n DB_ODMS,\n DEFAULT_DB_DRIVER,\n LOGGERS,\n PROJECT_TYPES,\n VALIDATORS,\n} from \"../core/types.js\";\n\nconst ALL_ADDONS: AddonDefinition[] = [\n drizzleAddon,\n prismaAddon,\n kyselyAddon,\n pinoAddon,\n winstonAddon,\n zodAddon,\n arktypeAddon,\n valibotAddon,\n];\n\nconst DB_ADDONS = ALL_ADDONS.filter((addon) => addon.category === \"database\");\nconst LOGGER_ADDONS = ALL_ADDONS.filter((addon) => addon.category === \"logger\");\nconst VALIDATOR_ADDONS = ALL_ADDONS.filter((addon) => addon.category === \"validator\");\n\nexport function getCapabilitiesCatalog(): CapabilitiesCatalog {\n return {\n types: [...PROJECT_TYPES],\n db: {\n odms: [...DB_ODMS],\n drivers: [...DB_DRIVERS],\n defaultDriver: DEFAULT_DB_DRIVER,\n },\n loggers: [...LOGGERS],\n validators: [...VALIDATORS],\n };\n}\n\nexport function resolveAddons(ctx: ScaffoldContext): AddonDefinition[] {\n const selected: AddonDefinition[] = [];\n\n if (ctx.db) {\n const dbAddon = DB_ADDONS.find((addon) => addon.id === ctx.db);\n if (!dbAddon) {\n throw new Error(`Unknown database addon \"${ctx.db}\"`);\n }\n selected.push(dbAddon);\n }\n\n if (ctx.logger) {\n const loggerAddon = LOGGER_ADDONS.find((addon) => addon.id === ctx.logger);\n if (!loggerAddon) {\n throw new Error(`Unknown logger addon \"${ctx.logger}\"`);\n }\n selected.push(loggerAddon);\n }\n\n if (ctx.validator) {\n const validatorAddon = VALIDATOR_ADDONS.find((addon) => addon.id === ctx.validator);\n if (!validatorAddon) {\n throw new Error(`Unknown validator addon \"${ctx.validator}\"`);\n }\n selected.push(validatorAddon);\n }\n\n return selected;\n}\n\nexport function collectBootBindings(ctx: ScaffoldContext) {\n return resolveAddons(ctx)\n .map((addon) => addon.bootBinding?.(ctx))\n .filter((v): v is NonNullable<typeof v> => Boolean(v));\n}\n"],"mappings":";;;;;;;;;;AAmBA,IAAM,aAAgC;CACpC,gBAAA;CACA,gBAAA;CACA,gBAAA;CACA,gBAAA;CACA,gBAAA;CACA,gBAAA;CACA,cAAA;CACA,gBAAA;AACF;AAEA,IAAM,YAAY,WAAW,QAAQ,UAAU,MAAM,aAAa,UAAU;AAC5E,IAAM,gBAAgB,WAAW,QAAQ,UAAU,MAAM,aAAa,QAAQ;AAC9E,IAAM,mBAAmB,WAAW,QAAQ,UAAU,MAAM,aAAa,WAAW;AAEpF,SAAgB,yBAA8C;CAC5D,OAAO;EACL,OAAO,CAAC,GAAG,cAAA,aAAa;EACxB,IAAI;GACF,MAAM,CAAC,GAAG,cAAA,OAAO;GACjB,SAAS,CAAC,GAAG,cAAA,UAAU;GACvB,eAAe,cAAA;EACjB;EACA,SAAS,CAAC,GAAG,cAAA,OAAO;EACpB,YAAY,CAAC,GAAG,cAAA,UAAU;CAC5B;AACF;AAEA,SAAgB,cAAc,KAAyC;CACrE,MAAM,WAA8B,CAAC;CAErC,IAAI,IAAI,IAAI;EACV,MAAM,UAAU,UAAU,MAAM,UAAU,MAAM,OAAO,IAAI,EAAE;EAC7D,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,2BAA2B,IAAI,GAAG,EAAE;EAEtD,SAAS,KAAK,OAAO;CACvB;CAEA,IAAI,IAAI,QAAQ;EACd,MAAM,cAAc,cAAc,MAAM,UAAU,MAAM,OAAO,IAAI,MAAM;EACzE,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,yBAAyB,IAAI,OAAO,EAAE;EAExD,SAAS,KAAK,WAAW;CAC3B;CAEA,IAAI,IAAI,WAAW;EACjB,MAAM,iBAAiB,iBAAiB,MAAM,UAAU,MAAM,OAAO,IAAI,SAAS;EAClF,IAAI,CAAC,gBACH,MAAM,IAAI,MAAM,4BAA4B,IAAI,UAAU,EAAE;EAE9D,SAAS,KAAK,cAAc;CAC9B;CAEA,OAAO;AACT;AAEA,SAAgB,oBAAoB,KAAsB;CACxD,OAAO,cAAc,GAAG,CAAC,CACtB,KAAK,UAAU,MAAM,cAAc,GAAG,CAAC,CAAC,CACxC,QAAQ,MAAkC,QAAQ,CAAC,CAAC;AACzD"}
@@ -6,13 +6,13 @@ var IMPORT_LINES = {
6
6
  };
7
7
  var VALIDATION_BLOCK_TEMPLATE = {
8
8
  zod: `, {
9
- query: z.object({ name: z.string() }),
9
+ query: z.object({ name: z.string().default('Taser') }),
10
10
  }`,
11
11
  arktype: `, {
12
- query: type({ name: 'string' }),
12
+ query: type({ 'name?': 'string = "Taser"' }),
13
13
  }`,
14
14
  valibot: `, {
15
- query: v.object({ name: v.string() }),
15
+ query: v.object({ name: v.optional(v.string(), 'Taser') }),
16
16
  }`
17
17
  };
18
18
  var ROUTE_TEMPLATE = (validator) => `import { reply } from '@taserjs/router'
@@ -1 +1 @@
1
- {"version":3,"file":"validators.cjs","names":[],"sources":["../../../src/addons/validators.ts"],"sourcesContent":["import type { ValidatorId } from \"../core/types\";\nimport type { AddonDefinition } from \"./types\";\n\nexport const IMPORT_LINES: Record<ValidatorId, string> = {\n zod: `import { z } from 'zod'`,\n arktype: `import { type } from 'arktype'`,\n valibot: `import * as v from 'valibot'`,\n};\n\nexport const VALIDATION_BLOCK_TEMPLATE: Record<ValidatorId, string> = {\n zod: `, {\n query: z.object({ name: z.string() }),\n}`,\n arktype: `, {\n query: type({ name: 'string' }),\n}`,\n valibot: `, {\n query: v.object({ name: v.string() }),\n}`,\n};\n\nconst ROUTE_TEMPLATE = (validator: ValidatorId) => `import { reply } from '@taserjs/router'\nimport { t } from '#src/taser.js'\n${IMPORT_LINES[validator]}\n\nconst GET = t.get('/'${VALIDATION_BLOCK_TEMPLATE[validator]})\n\nexport type RouteContext = typeof GET.$Infer.Context\nexport const Route = GET.handler((ctx) => {\n return reply.json({ message: \\`Hello, \\${ctx.query.name}!\\` })\n})\n`;\n\nexport const ValidatorAddon = (validator: ValidatorId): AddonDefinition => {\n return {\n id: validator,\n category: \"validator\",\n dependencies: () => [validator],\n devDependencies: () => [],\n apply: (ctx, write) => write(\"src/routes/index.get.ts\", ROUTE_TEMPLATE(validator)),\n };\n};\n"],"mappings":";AAGA,IAAa,eAA4C;CACvD,KAAK;CACL,SAAS;CACT,SAAS;AACX;AAEA,IAAa,4BAAyD;CACpE,KAAK;;;CAGL,SAAS;;;CAGT,SAAS;;;AAGX;AAEA,IAAM,kBAAkB,cAA2B;;EAEjD,aAAa,WAAW;;uBAEH,0BAA0B,WAAW;;;;;;;AAQ5D,IAAa,kBAAkB,cAA4C;CACzE,OAAO;EACL,IAAI;EACJ,UAAU;EACV,oBAAoB,CAAC,SAAS;EAC9B,uBAAuB,CAAC;EACxB,QAAQ,KAAK,UAAU,MAAM,2BAA2B,eAAe,SAAS,CAAC;CACnF;AACF"}
1
+ {"version":3,"file":"validators.cjs","names":[],"sources":["../../../src/addons/validators.ts"],"sourcesContent":["import type { ValidatorId } from \"../core/types\";\nimport type { AddonDefinition } from \"./types\";\n\nexport const IMPORT_LINES: Record<ValidatorId, string> = {\n zod: `import { z } from 'zod'`,\n arktype: `import { type } from 'arktype'`,\n valibot: `import * as v from 'valibot'`,\n};\n\nexport const VALIDATION_BLOCK_TEMPLATE: Record<ValidatorId, string> = {\n zod: `, {\n query: z.object({ name: z.string().default('Taser') }),\n}`,\n arktype: `, {\n query: type({ 'name?': 'string = \"Taser\"' }),\n}`,\n valibot: `, {\n query: v.object({ name: v.optional(v.string(), 'Taser') }),\n}`,\n};\n\nconst ROUTE_TEMPLATE = (validator: ValidatorId) => `import { reply } from '@taserjs/router'\nimport { t } from '#src/taser.js'\n${IMPORT_LINES[validator]}\n\nconst GET = t.get('/'${VALIDATION_BLOCK_TEMPLATE[validator]})\n\nexport type RouteContext = typeof GET.$Infer.Context\nexport const Route = GET.handler((ctx) => {\n return reply.json({ message: \\`Hello, \\${ctx.query.name}!\\` })\n})\n`;\n\nexport const ValidatorAddon = (validator: ValidatorId): AddonDefinition => {\n return {\n id: validator,\n category: \"validator\",\n dependencies: () => [validator],\n devDependencies: () => [],\n apply: (ctx, write) => write(\"src/routes/index.get.ts\", ROUTE_TEMPLATE(validator)),\n };\n};\n"],"mappings":";AAGA,IAAa,eAA4C;CACvD,KAAK;CACL,SAAS;CACT,SAAS;AACX;AAEA,IAAa,4BAAyD;CACpE,KAAK;;;CAGL,SAAS;;;CAGT,SAAS;;;AAGX;AAEA,IAAM,kBAAkB,cAA2B;;EAEjD,aAAa,WAAW;;uBAEH,0BAA0B,WAAW;;;;;;;AAQ5D,IAAa,kBAAkB,cAA4C;CACzE,OAAO;EACL,IAAI;EACJ,UAAU;EACV,oBAAoB,CAAC,SAAS;EAC9B,uBAAuB,CAAC;EACxB,QAAQ,KAAK,UAAU,MAAM,2BAA2B,eAAe,SAAS,CAAC;CACnF;AACF"}
@@ -69,33 +69,13 @@ async function scaffoldProject(options) {
69
69
  await (0, node_fs_promises.copyFile)(node_path.default.join(root, ".env.example"), node_path.default.join(root, ".env"));
70
70
  } catch {}
71
71
  await require_project_config.writeProjectConfig(root, ctx);
72
- if (options.skipInstall) return {
73
- projectName: ctx.projectName,
74
- targetDir: root,
75
- type: ctx.type,
76
- ...ctx.db ? {
77
- db: ctx.db,
78
- driver: ctx.driver
79
- } : {},
80
- ...ctx.logger ? { logger: ctx.logger } : {},
81
- ...ctx.validator ? { validator: ctx.validator } : {}
82
- };
72
+ if (options.skipInstall) return ctx;
83
73
  const agent = options.agent ?? require_package_manager.resolveUserAgent();
84
74
  await require_package_manager.installPackages(agent, root, {
85
75
  dependencies: packages.dependencies,
86
76
  devDependencies: packages.devDependencies
87
77
  });
88
- return {
89
- projectName: ctx.projectName,
90
- targetDir: root,
91
- type: ctx.type,
92
- ...ctx.db ? {
93
- db: ctx.db,
94
- driver: ctx.driver
95
- } : {},
96
- ...ctx.logger ? { logger: ctx.logger } : {},
97
- ...ctx.validator ? { validator: ctx.validator } : {}
98
- };
78
+ return ctx;
99
79
  }
100
80
  //#endregion
101
81
  exports.scaffoldProject = scaffoldProject;
@@ -1 +1 @@
1
- {"version":3,"file":"scaffold-engine.cjs","names":[],"sources":["../../../src/core/scaffold-engine.ts"],"sourcesContent":["import { copyFile, mkdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { collectBootBindings, resolveAddons } from \"../addons/registry.js\";\nimport { indexTemplate, taserTsTemplate } from \"../frameworks/index.js\";\nimport { installPackages, resolveUserAgent } from \"./package-manager.js\";\nimport { writeProjectConfig } from \"./project-config.js\";\nimport { resolvePackages } from \"./resolve-packages.js\";\nimport type { ScaffoldOptions, ScaffoldResult } from \"./types.js\";\nimport {\n contextTemplate,\n gitignoreTemplate,\n healthRouteTemplate,\n indexRouteTemplate,\n packageJsonTemplate,\n rootLayoutTemplate,\n starterManifestTemplate,\n tsconfigTemplate,\n tsdownConfigTemplate,\n} from \"../templates/base.js\";\n\nasync function write(filePath: string, contents: string): Promise<void> {\n await mkdir(path.dirname(filePath), { recursive: true });\n await writeFile(filePath, contents, \"utf8\");\n}\n\nexport async function scaffoldProject(options: ScaffoldOptions): Promise<ScaffoldResult> {\n const root = options.targetDir;\n const ctx = {\n projectName: options.projectName,\n targetDir: root,\n type: options.type,\n ...(options.db ? { db: options.db, driver: options.driver } : {}),\n ...(options.logger ? { logger: options.logger } : {}),\n ...(options.validator ? { validator: options.validator } : {}),\n };\n\n const addons = resolveAddons(ctx);\n const packages = resolvePackages(ctx);\n const bootBindings = collectBootBindings(ctx);\n\n await write(\n path.join(root, \"package.json\"),\n packageJsonTemplate(options.projectName, packages.scripts),\n );\n await write(path.join(root, \"tsconfig.json\"), tsconfigTemplate());\n await write(path.join(root, \"tsdown.config.ts\"), tsdownConfigTemplate());\n await write(path.join(root, \".gitignore\"), gitignoreTemplate());\n await write(path.join(root, \"src/context.ts\"), contextTemplate(bootBindings));\n await write(path.join(root, \"src/taser.ts\"), taserTsTemplate(options.type));\n await write(path.join(root, \"src/index.ts\"), indexTemplate(options.type));\n await write(path.join(root, \"src/routes/$.ts\"), rootLayoutTemplate());\n await write(path.join(root, \"src/routes/index.get.ts\"), indexRouteTemplate());\n await write(path.join(root, \"src/routes/health.get.ts\"), healthRouteTemplate(ctx));\n await write(path.join(root, \"src/routeManifest.gen.ts\"), starterManifestTemplate());\n\n if (options.type === \"cloudflare-workers\") {\n await write(\n path.join(root, \"wrangler.jsonc\"),\n JSON.stringify(\n {\n $schema: \"node_modules/wrangler/config-schema.json\",\n name: options.projectName,\n main: \"src/index.ts\",\n compatibility_date: \"2024-11-01\",\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n if (options.type === \"vercel\") {\n await write(\n path.join(root, \"vercel.json\"),\n JSON.stringify(\n {\n rewrites: [{ source: \"/(.*)\", destination: \"/src/index.ts\" }],\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n if (options.type === \"azure-functions\") {\n await write(\n path.join(root, \"host.json\"),\n JSON.stringify(\n {\n version: \"2.0\",\n logging: {\n applicationInsights: {\n samplingSettings: {\n isEnabled: true,\n excludedTypes: \"Request\",\n },\n },\n },\n extensionBundle: {\n id: \"Microsoft.Azure.Functions.ExtensionBundle\",\n version: \"[4.*, 5.0.0)\",\n },\n extensions: {\n http: {\n routePrefix: \"\",\n },\n },\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n await Promise.all(\n addons.map(async (addon) => {\n await addon.apply(ctx, (filePath, contents) => write(path.join(root, filePath), contents));\n }),\n );\n\n try {\n await copyFile(path.join(root, \".env.example\"), path.join(root, \".env\"));\n } catch {\n // .env.example was not created\n }\n\n await writeProjectConfig(root, ctx);\n\n if (options.skipInstall) {\n return {\n projectName: ctx.projectName,\n targetDir: root,\n type: ctx.type,\n ...(ctx.db ? { db: ctx.db, driver: ctx.driver } : {}),\n ...(ctx.logger ? { logger: ctx.logger } : {}),\n ...(ctx.validator ? { validator: ctx.validator } : {}),\n };\n }\n\n const agent = options.agent ?? resolveUserAgent();\n await installPackages(agent, root, {\n dependencies: packages.dependencies,\n devDependencies: packages.devDependencies,\n });\n\n return {\n projectName: ctx.projectName,\n targetDir: root,\n type: ctx.type,\n ...(ctx.db ? { db: ctx.db, driver: ctx.driver } : {}),\n ...(ctx.logger ? { logger: ctx.logger } : {}),\n ...(ctx.validator ? { validator: ctx.validator } : {}),\n };\n}\n"],"mappings":";;;;;;;;;;;AAqBA,eAAe,MAAM,UAAkB,UAAiC;CACtE,OAAA,GAAM,iBAAA,MAAA,CAAM,UAAA,QAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;CACvD,OAAA,GAAM,iBAAA,UAAA,CAAU,UAAU,UAAU,MAAM;AAC5C;AAEA,eAAsB,gBAAgB,SAAmD;CACvF,MAAM,OAAO,QAAQ;CACrB,MAAM,MAAM;EACV,aAAa,QAAQ;E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O,IAAI,CAAC;EAC3C,GAAI,IAAI,YAAY,EAAE,WAAW,IAAI,UAAU,IAAI,CAAC;CACtD;CAGF,MAAM,QAAQ,QAAQ,SAAS,wBAAA,iBAAiB;CAChD,MAAM,wBAAA,gBAAgB,OAAO,MAAM;EACjC,cAAc,SAAS;EACvB,iBAAiB,SAAS;CAC5B,CAAC;CAED,OAAO;EACL,aAAa,IAAI;EACjB,WAAW;EACX,MAAM,IAAI;EACV,GAAI,IAAI,KAAK;GAAE,IAAI,IAAI;GAAI,QAAQ,IAAI;EAAO,IAAI,CAAC;EACnD,GAAI,IAAI,SAAS,EAAE,QAAQ,IAAI,OAAO,IAAI,CAAC;EAC3C,GAAI,IAAI,YAAY,EAAE,WAAW,IAAI,UAAU,IAAI,CAAC;CACtD;AACF"}
1
+ {"version":3,"file":"scaffold-engine.cjs","names":[],"sources":["../../../src/core/scaffold-engine.ts"],"sourcesContent":["import { copyFile, mkdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { collectBootBindings, resolveAddons } from \"../addons/registry.js\";\nimport { indexTemplate, taserTsTemplate } from \"../frameworks/index.js\";\nimport { installPackages, resolveUserAgent } from \"./package-manager.js\";\nimport { writeProjectConfig } from \"./project-config.js\";\nimport { resolvePackages } from \"./resolve-packages.js\";\nimport type { ScaffoldOptions, ScaffoldResult } from \"./types.js\";\nimport {\n contextTemplate,\n gitignoreTemplate,\n healthRouteTemplate,\n indexRouteTemplate,\n packageJsonTemplate,\n rootLayoutTemplate,\n starterManifestTemplate,\n tsconfigTemplate,\n tsdownConfigTemplate,\n} from \"../templates/base.js\";\n\nasync function write(filePath: string, contents: string): Promise<void> {\n await mkdir(path.dirname(filePath), { recursive: true });\n await writeFile(filePath, contents, \"utf8\");\n}\n\nexport async function scaffoldProject(options: ScaffoldOptions): Promise<ScaffoldResult> {\n const root = options.targetDir;\n const ctx = {\n projectName: options.projectName,\n targetDir: root,\n type: options.type,\n ...(options.db ? { db: options.db, driver: options.driver } : {}),\n ...(options.logger ? { logger: options.logger } : {}),\n ...(options.validator ? { validator: options.validator } : {}),\n };\n\n const addons = resolveAddons(ctx);\n const packages = resolvePackages(ctx);\n const bootBindings = collectBootBindings(ctx);\n\n await write(\n path.join(root, \"package.json\"),\n packageJsonTemplate(options.projectName, packages.scripts),\n );\n await write(path.join(root, \"tsconfig.json\"), tsconfigTemplate());\n await write(path.join(root, \"tsdown.config.ts\"), tsdownConfigTemplate());\n await write(path.join(root, \".gitignore\"), gitignoreTemplate());\n await write(path.join(root, \"src/context.ts\"), contextTemplate(bootBindings));\n await write(path.join(root, \"src/taser.ts\"), taserTsTemplate(options.type));\n await write(path.join(root, \"src/index.ts\"), indexTemplate(options.type));\n await write(path.join(root, \"src/routes/$.ts\"), rootLayoutTemplate());\n await write(path.join(root, \"src/routes/index.get.ts\"), indexRouteTemplate());\n await write(path.join(root, \"src/routes/health.get.ts\"), healthRouteTemplate(ctx));\n await write(path.join(root, \"src/routeManifest.gen.ts\"), starterManifestTemplate());\n\n if (options.type === \"cloudflare-workers\") {\n await write(\n path.join(root, \"wrangler.jsonc\"),\n JSON.stringify(\n {\n $schema: \"node_modules/wrangler/config-schema.json\",\n name: options.projectName,\n main: \"src/index.ts\",\n compatibility_date: \"2024-11-01\",\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n if (options.type === \"vercel\") {\n await write(\n path.join(root, \"vercel.json\"),\n JSON.stringify(\n {\n rewrites: [{ source: \"/(.*)\", destination: \"/src/index.ts\" }],\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n if (options.type === \"azure-functions\") {\n await write(\n path.join(root, \"host.json\"),\n JSON.stringify(\n {\n version: \"2.0\",\n logging: {\n applicationInsights: {\n samplingSettings: {\n isEnabled: true,\n excludedTypes: \"Request\",\n },\n },\n },\n extensionBundle: {\n id: \"Microsoft.Azure.Functions.ExtensionBundle\",\n version: \"[4.*, 5.0.0)\",\n },\n extensions: {\n http: {\n routePrefix: \"\",\n },\n },\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n await Promise.all(\n addons.map(async (addon) => {\n await addon.apply(ctx, (filePath, contents) => write(path.join(root, filePath), contents));\n }),\n );\n\n try {\n await copyFile(path.join(root, \".env.example\"), path.join(root, \".env\"));\n } catch {\n // .env.example was not created\n }\n\n await writeProjectConfig(root, ctx);\n\n if (options.skipInstall) {\n return ctx as ScaffoldResult;\n }\n\n const agent = options.agent ?? resolveUserAgent();\n await installPackages(agent, root, {\n dependencies: packages.dependencies,\n devDependencies: packages.devDependencies,\n });\n\n return ctx as ScaffoldResult;\n}\n"],"mappings":";;;;;;;;;;;AAqBA,eAAe,MAAM,UAAkB,UAAiC;CACtE,OAAA,GAAM,iBAAA,MAAA,CAAM,UAAA,QAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;CACvD,OAAA,GAAM,iBAAA,UAAA,CAAU,UAAU,UAAU,MAAM;AAC5C;AAEA,eAAsB,gBAAgB,SAAmD;CACvF,MAAM,OAAO,QAAQ;CACrB,MAAM,MAAM;EACV,aAAa,QAAQ;EACrB,WAAW;EACX,MAAM,QAAQ;EACd,GAAI,QAAQ,KAAK;GAAE,IAAI,QAAQ;GAAI,QAAQ,QAAQ;EAAO,IAAI,CAAC;EAC/D,GAAI,QAAQ,SAAS,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EACnD,GAAI,QAAQ,YAAY,EAAE,WAAW,QAAQ,UAAU,IAAI,CAAC;CAC9D;CAEA,MAAM,SAAS,iBAAA,cAAc,GAAG;CAChC,MAAM,WAAW,yBAAA,gBAAgB,GAAG;CACpC,MAAM,eAAe,iBAAA,oBAAoB,GAAG;CAE5C,MAAM,MACJ,UAAA,QAAK,KAAK,MAAM,cAAc,GAC9B,aAAA,oBAAoB,QAAQ,aAAa,SAAS,OAAO,CAC3D;CACA,MAAM,MAAM,UAAA,QAAK,KAAK,MAAM,eAAe,GAAG,aAAA,iBAAiB,CAAC;CAChE,MAAM,MAAM,UAAA,QA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,EACF;EACA,iBAAiB;GACf,IAAI;GACJ,SAAS;EACX;EACA,YAAY,EACV,MAAM,EACJ,aAAa,GACf,EACF;CACF,GACA,MACA,CACF,IAAI,IACN;CAGF,MAAM,QAAQ,IACZ,OAAO,IAAI,OAAO,UAAU;EAC1B,MAAM,MAAM,MAAM,MAAM,UAAU,aAAa,MAAM,UAAA,QAAK,KAAK,MAAM,QAAQ,GAAG,QAAQ,CAAC;CAC3F,CAAC,CACH;CAEA,IAAI;EACF,OAAA,GAAM,iBAAA,SAAA,CAAS,UAAA,QAAK,KAAK,MAAM,cAAc,GAAG,UAAA,QAAK,KAAK,MAAM,MAAM,CAAC;CACzE,QAAQ,CAER;CAEA,MAAM,uBAAA,mBAAmB,MAAM,GAAG;CAElC,IAAI,QAAQ,aACV,OAAO;CAGT,MAAM,QAAQ,QAAQ,SAAS,wBAAA,iBAAiB;CAChD,MAAM,wBAAA,gBAAgB,OAAO,MAAM;EACjC,cAAc,SAAS;EACvB,iBAAiB,SAAS;CAC5B,CAAC;CAED,OAAO;AACT"}
@@ -31,7 +31,7 @@ import { t } from '#src/taser.js'
31
31
  const router = t.create(routeManifest)
32
32
 
33
33
  const app = new Hono()
34
- app.all('/*', c => router.native(c).fetch(c.req.raw))
34
+ app.all('/*', c => router.fetch(c.req.raw))
35
35
 
36
36
  const port = Number(process.env.PORT ?? 3000)
37
37
  serve({ fetch: app.fetch, port }, () => {
@@ -93,7 +93,7 @@ import { t } from '#src/taser.js'
93
93
  const router = t.create(routeManifest)
94
94
 
95
95
  const app = new Hono()
96
- app.all('/*', c => router.native(c).fetch(c.req.raw))
96
+ app.all('/*', c => router.fetch(c.req.raw))
97
97
 
98
98
  export const handler = handle(app)
99
99
  `;
@@ -121,7 +121,7 @@ import { t } from '#src/taser.js'
121
121
  const router = t.create(routeManifest)
122
122
 
123
123
  const app = new Hono()
124
- app.all('/*', c => router.native(c).fetch(c.req.raw))
124
+ app.all('/*', c => router.fetch(c.req.raw))
125
125
 
126
126
  export default handle(app)
127
127
  `;
@@ -136,7 +136,7 @@ import { t } from '#src/taser.js'
136
136
  const router = t.create(routeManifest)
137
137
 
138
138
  const app = new Hono()
139
- app.all('/*', c => router.native(c).fetch(c.req.raw))
139
+ app.all('/*', c => router.fetch(c.req.raw))
140
140
 
141
141
  export default handle(app)
142
142
  `;
@@ -152,7 +152,7 @@ import { t } from '#src/taser.js'
152
152
  const router = t.create(routeManifest)
153
153
 
154
154
  const honoApp = new Hono()
155
- honoApp.all('/*', c => router.native(c).fetch(c.req.raw))
155
+ honoApp.all('/*', c => router.fetch(c.req.raw))
156
156
 
157
157
  app.http('httpTrigger', {
158
158
  methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'],
@@ -191,33 +191,14 @@ serve({ fetch: router.fetch, port }, () => {
191
191
  `;
192
192
  }
193
193
  }
194
- function taserTsTemplate(type = "node") {
195
- if (type === "hono" || type === "aws-lambda" || type === "netlify" || type === "vercel" || type === "azure-functions") return `import type { Context } from 'hono'
196
- import { createTaserApp, type InferAppContext } from '@taserjs/router'
194
+ function taserTsTemplate(_type = "node") {
195
+ return `import { createTaserApp } from '@taserjs/router'
197
196
 
198
197
  import { context } from '#src/context.js'
199
198
 
200
- declare module '@taserjs/router' {
201
- interface RouterRegister {
202
- NativeContext: Context
203
- }
204
- }
205
-
206
199
  export const t = createTaserApp({
207
200
  response: { validate: true },
208
201
  }).context(context)
209
-
210
- export type AppContext = InferAppContext<typeof context>
211
- `;
212
- return `import { createTaserApp, type InferAppContext } from '@taserjs/router'
213
-
214
- import { context } from '#src/context.js'
215
-
216
- export const t = createTaserApp({
217
- response: { validate: true },
218
- }).context(context)
219
-
220
- export type AppContext = InferAppContext<typeof context>
221
202
  `;
222
203
  }
223
204
  //#endregion
@@ -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.native(c).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.native(c).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.native(c).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.native(c).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.native(c).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 if (\n type === \"hono\" ||\n type === \"aws-lambda\" ||\n type === \"netlify\" ||\n type === \"vercel\" ||\n type === \"azure-functions\"\n ) {\n return `import type { Context } from 'hono'\nimport { createTaserApp, type InferAppContext } from '@taserjs/router'\n\nimport { context } from '#src/context.js'\n\ndeclare module '@taserjs/router' {\n interface RouterRegister {\n NativeContext: Context\n }\n}\n\nexport const t = createTaserApp({\n response: { validate: true },\n}).context(context)\n\nexport type AppContext = InferAppContext<typeof context>\n`;\n }\n\n return `import { createTaserApp, type InferAppContext } from '@taserjs/router'\n\nimport { context } from '#src/context.js'\n\nexport const t = createTaserApp({\n response: { validate: true },\n}).context(context)\n\nexport type AppContext = InferAppContext<typeof 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,OAAoB,QAAgB;CAClE,IACE,SAAS,UACT,SAAS,gBACT,SAAS,aACT,SAAS,YACT,SAAS,mBAET,OAAO;;;;;;;;;;;;;;;;;CAmBT,OAAO;;;;;;;;;;AAUT"}
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,3 +1,3 @@
1
1
  import { ProjectType } from '../core/types.js';
2
2
  export declare function indexTemplate(type: ProjectType): string;
3
- export declare function taserTsTemplate(type?: ProjectType): string;
3
+ export declare function taserTsTemplate(_type?: ProjectType): string;
@@ -45,14 +45,11 @@ function resolveAddons(ctx) {
45
45
  if (!loggerAddon) throw new Error(`Unknown logger addon "${ctx.logger}"`);
46
46
  selected.push(loggerAddon);
47
47
  }
48
- if (selected.filter((addon) => addon.category === "database").length > 1) throw new Error("Only one database addon can be selected");
49
- if (selected.filter((addon) => addon.category === "logger").length > 1) throw new Error("Only one logger addon can be selected");
50
48
  if (ctx.validator) {
51
49
  const validatorAddon = VALIDATOR_ADDONS.find((addon) => addon.id === ctx.validator);
52
50
  if (!validatorAddon) throw new Error(`Unknown validator addon "${ctx.validator}"`);
53
51
  selected.push(validatorAddon);
54
52
  }
55
- if (selected.filter((addon) => addon.category === "validator").length > 1) throw new Error("Only one validator addon can be selected");
56
53
  return selected;
57
54
  }
58
55
  function collectBootBindings(ctx) {
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","names":[],"sources":["../../../src/addons/registry.ts"],"sourcesContent":["import { arktypeAddon } from \"./arktype/index.js\";\nimport { drizzleAddon } from \"./drizzle/index.js\";\nimport { kyselyAddon } from \"./kysely/index.js\";\nimport { pinoAddon } from \"./pino/index.js\";\nimport { prismaAddon } from \"./prisma/index.js\";\nimport { valibotAddon } from \"./valibot/index.js\";\nimport { winstonAddon } from \"./winston/index.js\";\nimport { zodAddon } from \"./zod/index.js\";\nimport type { AddonDefinition } from \"./types.js\";\nimport type { CapabilitiesCatalog, ScaffoldContext } from \"../core/types.js\";\nimport {\n DB_DRIVERS,\n DB_ODMS,\n DEFAULT_DB_DRIVER,\n LOGGERS,\n PROJECT_TYPES,\n VALIDATORS,\n} from \"../core/types.js\";\n\nconst ALL_ADDONS: AddonDefinition[] = [\n drizzleAddon,\n prismaAddon,\n kyselyAddon,\n pinoAddon,\n winstonAddon,\n zodAddon,\n arktypeAddon,\n valibotAddon,\n];\n\nconst DB_ADDONS = ALL_ADDONS.filter((addon) => addon.category === \"database\");\nconst LOGGER_ADDONS = ALL_ADDONS.filter((addon) => addon.category === \"logger\");\nconst VALIDATOR_ADDONS = ALL_ADDONS.filter((addon) => addon.category === \"validator\");\n\nexport function getCapabilitiesCatalog(): CapabilitiesCatalog {\n return {\n types: [...PROJECT_TYPES],\n db: {\n odms: [...DB_ODMS],\n drivers: [...DB_DRIVERS],\n defaultDriver: DEFAULT_DB_DRIVER,\n },\n loggers: [...LOGGERS],\n validators: [...VALIDATORS],\n };\n}\n\nexport function resolveAddons(ctx: ScaffoldContext): AddonDefinition[] {\n const selected: AddonDefinition[] = [];\n\n if (ctx.db) {\n const dbAddon = DB_ADDONS.find((addon) => addon.id === ctx.db);\n if (!dbAddon) {\n throw new Error(`Unknown database addon \"${ctx.db}\"`);\n }\n selected.push(dbAddon);\n }\n\n if (ctx.logger) {\n const loggerAddon = LOGGER_ADDONS.find((addon) => addon.id === ctx.logger);\n if (!loggerAddon) {\n throw new Error(`Unknown logger addon \"${ctx.logger}\"`);\n }\n selected.push(loggerAddon);\n }\n\n const dbCount = selected.filter((addon) => addon.category === \"database\").length;\n if (dbCount > 1) {\n throw new Error(\"Only one database addon can be selected\");\n }\n\n const loggerCount = selected.filter((addon) => addon.category === \"logger\").length;\n if (loggerCount > 1) {\n throw new Error(\"Only one logger addon can be selected\");\n }\n\n if (ctx.validator) {\n const validatorAddon = VALIDATOR_ADDONS.find((addon) => addon.id === ctx.validator);\n if (!validatorAddon) {\n throw new Error(`Unknown validator addon \"${ctx.validator}\"`);\n }\n selected.push(validatorAddon);\n }\n\n const validatorCount = selected.filter((addon) => addon.category === \"validator\").length;\n if (validatorCount > 1) {\n throw new Error(\"Only one validator addon can be selected\");\n }\n\n return selected;\n}\n\nexport function collectBootBindings(ctx: ScaffoldContext) {\n return resolveAddons(ctx)\n .map((addon) => addon.bootBinding?.(ctx))\n .filter((v): v is NonNullable<typeof v> => Boolean(v));\n}\n"],"mappings":";;;;;;;;;;AAmBA,IAAM,aAAgC;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAM,YAAY,WAAW,QAAQ,UAAU,MAAM,aAAa,UAAU;AAC5E,IAAM,gBAAgB,WAAW,QAAQ,UAAU,MAAM,aAAa,QAAQ;AAC9E,IAAM,mBAAmB,WAAW,QAAQ,UAAU,MAAM,aAAa,WAAW;AAEpF,SAAgB,yBAA8C;CAC5D,OAAO;EACL,OAAO,CAAC,GAAG,aAAa;EACxB,IAAI;GACF,MAAM,CAAC,GAAG,OAAO;GACjB,SAAS,CAAC,GAAG,UAAU;GACvB,eAAe;EACjB;EACA,SAAS,CAAC,GAAG,OAAO;EACpB,YAAY,CAAC,GAAG,UAAU;CAC5B;AACF;AAEA,SAAgB,cAAc,KAAyC;CACrE,MAAM,WAA8B,CAAC;CAErC,IAAI,IAAI,IAAI;EACV,MAAM,UAAU,UAAU,MAAM,UAAU,MAAM,OAAO,IAAI,EAAE;EAC7D,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,2BAA2B,IAAI,GAAG,EAAE;EAEtD,SAAS,KAAK,OAAO;CACvB;CAEA,IAAI,IAAI,QAAQ;EACd,MAAM,cAAc,cAAc,MAAM,UAAU,MAAM,OAAO,IAAI,MAAM;EACzE,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,yBAAyB,IAAI,OAAO,EAAE;EAExD,SAAS,KAAK,WAAW;CAC3B;CAGA,IADgB,SAAS,QAAQ,UAAU,MAAM,aAAa,UAAU,CAAC,CAAC,SAC5D,GACZ,MAAM,IAAI,MAAM,yCAAyC;CAI3D,IADoB,SAAS,QAAQ,UAAU,MAAM,aAAa,QAAQ,CAAC,CAAC,SAC1D,GAChB,MAAM,IAAI,MAAM,uCAAuC;CAGzD,IAAI,IAAI,WAAW;EACjB,MAAM,iBAAiB,iBAAiB,MAAM,UAAU,MAAM,OAAO,IAAI,SAAS;EAClF,IAAI,CAAC,gBACH,MAAM,IAAI,MAAM,4BAA4B,IAAI,UAAU,EAAE;EAE9D,SAAS,KAAK,cAAc;CAC9B;CAGA,IADuB,SAAS,QAAQ,UAAU,MAAM,aAAa,WAAW,CAAC,CAAC,SAC7D,GACnB,MAAM,IAAI,MAAM,0CAA0C;CAG5D,OAAO;AACT;AAEA,SAAgB,oBAAoB,KAAsB;CACxD,OAAO,cAAc,GAAG,CAAC,CACtB,KAAK,UAAU,MAAM,cAAc,GAAG,CAAC,CAAC,CACxC,QAAQ,MAAkC,QAAQ,CAAC,CAAC;AACzD"}
1
+ {"version":3,"file":"registry.js","names":[],"sources":["../../../src/addons/registry.ts"],"sourcesContent":["import { arktypeAddon } from \"./arktype/index.js\";\nimport { drizzleAddon } from \"./drizzle/index.js\";\nimport { kyselyAddon } from \"./kysely/index.js\";\nimport { pinoAddon } from \"./pino/index.js\";\nimport { prismaAddon } from \"./prisma/index.js\";\nimport { valibotAddon } from \"./valibot/index.js\";\nimport { winstonAddon } from \"./winston/index.js\";\nimport { zodAddon } from \"./zod/index.js\";\nimport type { AddonDefinition } from \"./types.js\";\nimport type { CapabilitiesCatalog, ScaffoldContext } from \"../core/types.js\";\nimport {\n DB_DRIVERS,\n DB_ODMS,\n DEFAULT_DB_DRIVER,\n LOGGERS,\n PROJECT_TYPES,\n VALIDATORS,\n} from \"../core/types.js\";\n\nconst ALL_ADDONS: AddonDefinition[] = [\n drizzleAddon,\n prismaAddon,\n kyselyAddon,\n pinoAddon,\n winstonAddon,\n zodAddon,\n arktypeAddon,\n valibotAddon,\n];\n\nconst DB_ADDONS = ALL_ADDONS.filter((addon) => addon.category === \"database\");\nconst LOGGER_ADDONS = ALL_ADDONS.filter((addon) => addon.category === \"logger\");\nconst VALIDATOR_ADDONS = ALL_ADDONS.filter((addon) => addon.category === \"validator\");\n\nexport function getCapabilitiesCatalog(): CapabilitiesCatalog {\n return {\n types: [...PROJECT_TYPES],\n db: {\n odms: [...DB_ODMS],\n drivers: [...DB_DRIVERS],\n defaultDriver: DEFAULT_DB_DRIVER,\n },\n loggers: [...LOGGERS],\n validators: [...VALIDATORS],\n };\n}\n\nexport function resolveAddons(ctx: ScaffoldContext): AddonDefinition[] {\n const selected: AddonDefinition[] = [];\n\n if (ctx.db) {\n const dbAddon = DB_ADDONS.find((addon) => addon.id === ctx.db);\n if (!dbAddon) {\n throw new Error(`Unknown database addon \"${ctx.db}\"`);\n }\n selected.push(dbAddon);\n }\n\n if (ctx.logger) {\n const loggerAddon = LOGGER_ADDONS.find((addon) => addon.id === ctx.logger);\n if (!loggerAddon) {\n throw new Error(`Unknown logger addon \"${ctx.logger}\"`);\n }\n selected.push(loggerAddon);\n }\n\n if (ctx.validator) {\n const validatorAddon = VALIDATOR_ADDONS.find((addon) => addon.id === ctx.validator);\n if (!validatorAddon) {\n throw new Error(`Unknown validator addon \"${ctx.validator}\"`);\n }\n selected.push(validatorAddon);\n }\n\n return selected;\n}\n\nexport function collectBootBindings(ctx: ScaffoldContext) {\n return resolveAddons(ctx)\n .map((addon) => addon.bootBinding?.(ctx))\n .filter((v): v is NonNullable<typeof v> => Boolean(v));\n}\n"],"mappings":";;;;;;;;;;AAmBA,IAAM,aAAgC;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAM,YAAY,WAAW,QAAQ,UAAU,MAAM,aAAa,UAAU;AAC5E,IAAM,gBAAgB,WAAW,QAAQ,UAAU,MAAM,aAAa,QAAQ;AAC9E,IAAM,mBAAmB,WAAW,QAAQ,UAAU,MAAM,aAAa,WAAW;AAEpF,SAAgB,yBAA8C;CAC5D,OAAO;EACL,OAAO,CAAC,GAAG,aAAa;EACxB,IAAI;GACF,MAAM,CAAC,GAAG,OAAO;GACjB,SAAS,CAAC,GAAG,UAAU;GACvB,eAAe;EACjB;EACA,SAAS,CAAC,GAAG,OAAO;EACpB,YAAY,CAAC,GAAG,UAAU;CAC5B;AACF;AAEA,SAAgB,cAAc,KAAyC;CACrE,MAAM,WAA8B,CAAC;CAErC,IAAI,IAAI,IAAI;EACV,MAAM,UAAU,UAAU,MAAM,UAAU,MAAM,OAAO,IAAI,EAAE;EAC7D,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,2BAA2B,IAAI,GAAG,EAAE;EAEtD,SAAS,KAAK,OAAO;CACvB;CAEA,IAAI,IAAI,QAAQ;EACd,MAAM,cAAc,cAAc,MAAM,UAAU,MAAM,OAAO,IAAI,MAAM;EACzE,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,yBAAyB,IAAI,OAAO,EAAE;EAExD,SAAS,KAAK,WAAW;CAC3B;CAEA,IAAI,IAAI,WAAW;EACjB,MAAM,iBAAiB,iBAAiB,MAAM,UAAU,MAAM,OAAO,IAAI,SAAS;EAClF,IAAI,CAAC,gBACH,MAAM,IAAI,MAAM,4BAA4B,IAAI,UAAU,EAAE;EAE9D,SAAS,KAAK,cAAc;CAC9B;CAEA,OAAO;AACT;AAEA,SAAgB,oBAAoB,KAAsB;CACxD,OAAO,cAAc,GAAG,CAAC,CACtB,KAAK,UAAU,MAAM,cAAc,GAAG,CAAC,CAAC,CACxC,QAAQ,MAAkC,QAAQ,CAAC,CAAC;AACzD"}
@@ -6,13 +6,13 @@ var IMPORT_LINES = {
6
6
  };
7
7
  var VALIDATION_BLOCK_TEMPLATE = {
8
8
  zod: `, {
9
- query: z.object({ name: z.string() }),
9
+ query: z.object({ name: z.string().default('Taser') }),
10
10
  }`,
11
11
  arktype: `, {
12
- query: type({ name: 'string' }),
12
+ query: type({ 'name?': 'string = "Taser"' }),
13
13
  }`,
14
14
  valibot: `, {
15
- query: v.object({ name: v.string() }),
15
+ query: v.object({ name: v.optional(v.string(), 'Taser') }),
16
16
  }`
17
17
  };
18
18
  var ROUTE_TEMPLATE = (validator) => `import { reply } from '@taserjs/router'
@@ -1 +1 @@
1
- {"version":3,"file":"validators.js","names":[],"sources":["../../../src/addons/validators.ts"],"sourcesContent":["import type { ValidatorId } from \"../core/types\";\nimport type { AddonDefinition } from \"./types\";\n\nexport const IMPORT_LINES: Record<ValidatorId, string> = {\n zod: `import { z } from 'zod'`,\n arktype: `import { type } from 'arktype'`,\n valibot: `import * as v from 'valibot'`,\n};\n\nexport const VALIDATION_BLOCK_TEMPLATE: Record<ValidatorId, string> = {\n zod: `, {\n query: z.object({ name: z.string() }),\n}`,\n arktype: `, {\n query: type({ name: 'string' }),\n}`,\n valibot: `, {\n query: v.object({ name: v.string() }),\n}`,\n};\n\nconst ROUTE_TEMPLATE = (validator: ValidatorId) => `import { reply } from '@taserjs/router'\nimport { t } from '#src/taser.js'\n${IMPORT_LINES[validator]}\n\nconst GET = t.get('/'${VALIDATION_BLOCK_TEMPLATE[validator]})\n\nexport type RouteContext = typeof GET.$Infer.Context\nexport const Route = GET.handler((ctx) => {\n return reply.json({ message: \\`Hello, \\${ctx.query.name}!\\` })\n})\n`;\n\nexport const ValidatorAddon = (validator: ValidatorId): AddonDefinition => {\n return {\n id: validator,\n category: \"validator\",\n dependencies: () => [validator],\n devDependencies: () => [],\n apply: (ctx, write) => write(\"src/routes/index.get.ts\", ROUTE_TEMPLATE(validator)),\n };\n};\n"],"mappings":";AAGA,IAAa,eAA4C;CACvD,KAAK;CACL,SAAS;CACT,SAAS;AACX;AAEA,IAAa,4BAAyD;CACpE,KAAK;;;CAGL,SAAS;;;CAGT,SAAS;;;AAGX;AAEA,IAAM,kBAAkB,cAA2B;;EAEjD,aAAa,WAAW;;uBAEH,0BAA0B,WAAW;;;;;;;AAQ5D,IAAa,kBAAkB,cAA4C;CACzE,OAAO;EACL,IAAI;EACJ,UAAU;EACV,oBAAoB,CAAC,SAAS;EAC9B,uBAAuB,CAAC;EACxB,QAAQ,KAAK,UAAU,MAAM,2BAA2B,eAAe,SAAS,CAAC;CACnF;AACF"}
1
+ {"version":3,"file":"validators.js","names":[],"sources":["../../../src/addons/validators.ts"],"sourcesContent":["import type { ValidatorId } from \"../core/types\";\nimport type { AddonDefinition } from \"./types\";\n\nexport const IMPORT_LINES: Record<ValidatorId, string> = {\n zod: `import { z } from 'zod'`,\n arktype: `import { type } from 'arktype'`,\n valibot: `import * as v from 'valibot'`,\n};\n\nexport const VALIDATION_BLOCK_TEMPLATE: Record<ValidatorId, string> = {\n zod: `, {\n query: z.object({ name: z.string().default('Taser') }),\n}`,\n arktype: `, {\n query: type({ 'name?': 'string = \"Taser\"' }),\n}`,\n valibot: `, {\n query: v.object({ name: v.optional(v.string(), 'Taser') }),\n}`,\n};\n\nconst ROUTE_TEMPLATE = (validator: ValidatorId) => `import { reply } from '@taserjs/router'\nimport { t } from '#src/taser.js'\n${IMPORT_LINES[validator]}\n\nconst GET = t.get('/'${VALIDATION_BLOCK_TEMPLATE[validator]})\n\nexport type RouteContext = typeof GET.$Infer.Context\nexport const Route = GET.handler((ctx) => {\n return reply.json({ message: \\`Hello, \\${ctx.query.name}!\\` })\n})\n`;\n\nexport const ValidatorAddon = (validator: ValidatorId): AddonDefinition => {\n return {\n id: validator,\n category: \"validator\",\n dependencies: () => [validator],\n devDependencies: () => [],\n apply: (ctx, write) => write(\"src/routes/index.get.ts\", ROUTE_TEMPLATE(validator)),\n };\n};\n"],"mappings":";AAGA,IAAa,eAA4C;CACvD,KAAK;CACL,SAAS;CACT,SAAS;AACX;AAEA,IAAa,4BAAyD;CACpE,KAAK;;;CAGL,SAAS;;;CAGT,SAAS;;;AAGX;AAEA,IAAM,kBAAkB,cAA2B;;EAEjD,aAAa,WAAW;;uBAEH,0BAA0B,WAAW;;;;;;;AAQ5D,IAAa,kBAAkB,cAA4C;CACzE,OAAO;EACL,IAAI;EACJ,UAAU;EACV,oBAAoB,CAAC,SAAS;EAC9B,uBAAuB,CAAC;EACxB,QAAQ,KAAK,UAAU,MAAM,2BAA2B,eAAe,SAAS,CAAC;CACnF;AACF"}
@@ -67,33 +67,13 @@ async function scaffoldProject(options) {
67
67
  await copyFile(path.join(root, ".env.example"), path.join(root, ".env"));
68
68
  } catch {}
69
69
  await writeProjectConfig(root, ctx);
70
- if (options.skipInstall) return {
71
- projectName: ctx.projectName,
72
- targetDir: root,
73
- type: ctx.type,
74
- ...ctx.db ? {
75
- db: ctx.db,
76
- driver: ctx.driver
77
- } : {},
78
- ...ctx.logger ? { logger: ctx.logger } : {},
79
- ...ctx.validator ? { validator: ctx.validator } : {}
80
- };
70
+ if (options.skipInstall) return ctx;
81
71
  const agent = options.agent ?? resolveUserAgent();
82
72
  await installPackages(agent, root, {
83
73
  dependencies: packages.dependencies,
84
74
  devDependencies: packages.devDependencies
85
75
  });
86
- return {
87
- projectName: ctx.projectName,
88
- targetDir: root,
89
- type: ctx.type,
90
- ...ctx.db ? {
91
- db: ctx.db,
92
- driver: ctx.driver
93
- } : {},
94
- ...ctx.logger ? { logger: ctx.logger } : {},
95
- ...ctx.validator ? { validator: ctx.validator } : {}
96
- };
76
+ return ctx;
97
77
  }
98
78
  //#endregion
99
79
  export { scaffoldProject };
@@ -1 +1 @@
1
- {"version":3,"file":"scaffold-engine.js","names":[],"sources":["../../../src/core/scaffold-engine.ts"],"sourcesContent":["import { copyFile, mkdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { collectBootBindings, resolveAddons } from \"../addons/registry.js\";\nimport { indexTemplate, taserTsTemplate } from \"../frameworks/index.js\";\nimport { installPackages, resolveUserAgent } from \"./package-manager.js\";\nimport { writeProjectConfig } from \"./project-config.js\";\nimport { resolvePackages } from \"./resolve-packages.js\";\nimport type { ScaffoldOptions, ScaffoldResult } from \"./types.js\";\nimport {\n contextTemplate,\n gitignoreTemplate,\n healthRouteTemplate,\n indexRouteTemplate,\n packageJsonTemplate,\n rootLayoutTemplate,\n starterManifestTemplate,\n tsconfigTemplate,\n tsdownConfigTemplate,\n} from \"../templates/base.js\";\n\nasync function write(filePath: string, contents: string): Promise<void> {\n await mkdir(path.dirname(filePath), { recursive: true });\n await writeFile(filePath, contents, \"utf8\");\n}\n\nexport async function scaffoldProject(options: ScaffoldOptions): Promise<ScaffoldResult> {\n const root = options.targetDir;\n const ctx = {\n projectName: options.projectName,\n targetDir: root,\n type: options.type,\n ...(options.db ? { db: options.db, driver: options.driver } : {}),\n ...(options.logger ? { logger: options.logger } : {}),\n ...(options.validator ? { validator: options.validator } : {}),\n };\n\n const addons = resolveAddons(ctx);\n const packages = resolvePackages(ctx);\n const bootBindings = collectBootBindings(ctx);\n\n await write(\n path.join(root, \"package.json\"),\n packageJsonTemplate(options.projectName, packages.scripts),\n );\n await write(path.join(root, \"tsconfig.json\"), tsconfigTemplate());\n await write(path.join(root, \"tsdown.config.ts\"), tsdownConfigTemplate());\n await write(path.join(root, \".gitignore\"), gitignoreTemplate());\n await write(path.join(root, \"src/context.ts\"), contextTemplate(bootBindings));\n await write(path.join(root, \"src/taser.ts\"), taserTsTemplate(options.type));\n await write(path.join(root, \"src/index.ts\"), indexTemplate(options.type));\n await write(path.join(root, \"src/routes/$.ts\"), rootLayoutTemplate());\n await write(path.join(root, \"src/routes/index.get.ts\"), indexRouteTemplate());\n await write(path.join(root, \"src/routes/health.get.ts\"), healthRouteTemplate(ctx));\n await write(path.join(root, \"src/routeManifest.gen.ts\"), starterManifestTemplate());\n\n if (options.type === \"cloudflare-workers\") {\n await write(\n path.join(root, \"wrangler.jsonc\"),\n JSON.stringify(\n {\n $schema: \"node_modules/wrangler/config-schema.json\",\n name: options.projectName,\n main: \"src/index.ts\",\n compatibility_date: \"2024-11-01\",\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n if (options.type === \"vercel\") {\n await write(\n path.join(root, \"vercel.json\"),\n JSON.stringify(\n {\n rewrites: [{ source: \"/(.*)\", destination: \"/src/index.ts\" }],\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n if (options.type === \"azure-functions\") {\n await write(\n path.join(root, \"host.json\"),\n JSON.stringify(\n {\n version: \"2.0\",\n logging: {\n applicationInsights: {\n samplingSettings: {\n isEnabled: true,\n excludedTypes: \"Request\",\n },\n },\n },\n extensionBundle: {\n id: \"Microsoft.Azure.Functions.ExtensionBundle\",\n version: \"[4.*, 5.0.0)\",\n },\n extensions: {\n http: {\n routePrefix: \"\",\n },\n },\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n await Promise.all(\n addons.map(async (addon) => {\n await addon.apply(ctx, (filePath, contents) => write(path.join(root, filePath), contents));\n }),\n );\n\n try {\n await copyFile(path.join(root, \".env.example\"), path.join(root, \".env\"));\n } catch {\n // .env.example was not created\n }\n\n await writeProjectConfig(root, ctx);\n\n if (options.skipInstall) {\n return {\n projectName: ctx.projectName,\n targetDir: root,\n type: ctx.type,\n ...(ctx.db ? { db: ctx.db, driver: ctx.driver } : {}),\n ...(ctx.logger ? { logger: ctx.logger } : {}),\n ...(ctx.validator ? { validator: ctx.validator } : {}),\n };\n }\n\n const agent = options.agent ?? resolveUserAgent();\n await installPackages(agent, root, {\n dependencies: packages.dependencies,\n devDependencies: packages.devDependencies,\n });\n\n return {\n projectName: ctx.projectName,\n targetDir: root,\n type: ctx.type,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AAI;EACjB,WAAW;EACX,MAAM,IAAI;EACV,GAAI,IAAI,KAAK;GAAE,IAAI,IAAI;GAAI,QAAQ,IAAI;EAAO,IAAI,CAAC;EACnD,GAAI,IAAI,SAAS,EAAE,QAAQ,IAAI,OAAO,IAAI,CAAC;EAC3C,GAAI,IAAI,YAAY,EAAE,WAAW,IAAI,UAAU,IAAI,CAAC;CACtD;CAGF,MAAM,QAAQ,QAAQ,SAAS,iBAAiB;CAChD,MAAM,gBAAgB,OAAO,MAAM;EACjC,cAAc,SAAS;EACvB,iBAAiB,SAAS;CAC5B,CAAC;CAED,OAAO;EACL,aAAa,IAAI;EACjB,WAAW;EACX,MAAM,IAAI;EACV,GAAI,IAAI,KAAK;GAAE,IAAI,IAAI;GAAI,QAAQ,IAAI;EAAO,IAAI,CAAC;EACnD,GAAI,IAAI,SAAS,EAAE,QAAQ,IAAI,OAAO,IAAI,CAAC;EAC3C,GAAI,IAAI,YAAY,EAAE,WAAW,IAAI,UAAU,IAAI,CAAC;CACtD;AACF"}
1
+ {"version":3,"file":"scaffold-engine.js","names":[],"sources":["../../../src/core/scaffold-engine.ts"],"sourcesContent":["import { copyFile, mkdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { collectBootBindings, resolveAddons } from \"../addons/registry.js\";\nimport { indexTemplate, taserTsTemplate } from \"../frameworks/index.js\";\nimport { installPackages, resolveUserAgent } from \"./package-manager.js\";\nimport { writeProjectConfig } from \"./project-config.js\";\nimport { resolvePackages } from \"./resolve-packages.js\";\nimport type { ScaffoldOptions, ScaffoldResult } from \"./types.js\";\nimport {\n contextTemplate,\n gitignoreTemplate,\n healthRouteTemplate,\n indexRouteTemplate,\n packageJsonTemplate,\n rootLayoutTemplate,\n starterManifestTemplate,\n tsconfigTemplate,\n tsdownConfigTemplate,\n} from \"../templates/base.js\";\n\nasync function write(filePath: string, contents: string): Promise<void> {\n await mkdir(path.dirname(filePath), { recursive: true });\n await writeFile(filePath, contents, \"utf8\");\n}\n\nexport async function scaffoldProject(options: ScaffoldOptions): Promise<ScaffoldResult> {\n const root = options.targetDir;\n const ctx = {\n projectName: options.projectName,\n targetDir: root,\n type: options.type,\n ...(options.db ? { db: options.db, driver: options.driver } : {}),\n ...(options.logger ? { logger: options.logger } : {}),\n ...(options.validator ? { validator: options.validator } : {}),\n };\n\n const addons = resolveAddons(ctx);\n const packages = resolvePackages(ctx);\n const bootBindings = collectBootBindings(ctx);\n\n await write(\n path.join(root, \"package.json\"),\n packageJsonTemplate(options.projectName, packages.scripts),\n );\n await write(path.join(root, \"tsconfig.json\"), tsconfigTemplate());\n await write(path.join(root, \"tsdown.config.ts\"), tsdownConfigTemplate());\n await write(path.join(root, \".gitignore\"), gitignoreTemplate());\n await write(path.join(root, \"src/context.ts\"), contextTemplate(bootBindings));\n await write(path.join(root, \"src/taser.ts\"), taserTsTemplate(options.type));\n await write(path.join(root, \"src/index.ts\"), indexTemplate(options.type));\n await write(path.join(root, \"src/routes/$.ts\"), rootLayoutTemplate());\n await write(path.join(root, \"src/routes/index.get.ts\"), indexRouteTemplate());\n await write(path.join(root, \"src/routes/health.get.ts\"), healthRouteTemplate(ctx));\n await write(path.join(root, \"src/routeManifest.gen.ts\"), starterManifestTemplate());\n\n if (options.type === \"cloudflare-workers\") {\n await write(\n path.join(root, \"wrangler.jsonc\"),\n JSON.stringify(\n {\n $schema: \"node_modules/wrangler/config-schema.json\",\n name: options.projectName,\n main: \"src/index.ts\",\n compatibility_date: \"2024-11-01\",\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n if (options.type === \"vercel\") {\n await write(\n path.join(root, \"vercel.json\"),\n JSON.stringify(\n {\n rewrites: [{ source: \"/(.*)\", destination: \"/src/index.ts\" }],\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n if (options.type === \"azure-functions\") {\n await write(\n path.join(root, \"host.json\"),\n JSON.stringify(\n {\n version: \"2.0\",\n logging: {\n applicationInsights: {\n samplingSettings: {\n isEnabled: true,\n excludedTypes: \"Request\",\n },\n },\n },\n extensionBundle: {\n id: \"Microsoft.Azure.Functions.ExtensionBundle\",\n version: \"[4.*, 5.0.0)\",\n },\n extensions: {\n http: {\n routePrefix: \"\",\n },\n },\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n await Promise.all(\n addons.map(async (addon) => {\n await addon.apply(ctx, (filePath, contents) => write(path.join(root, filePath), contents));\n }),\n );\n\n try {\n await copyFile(path.join(root, \".env.example\"), path.join(root, \".env\"));\n } catch {\n // .env.example was not created\n }\n\n await writeProjectConfig(root, ctx);\n\n if (options.skipInstall) {\n return ctx as ScaffoldResult;\n }\n\n const agent = options.agent ?? resolveUserAgent();\n await installPackages(agent, root, {\n dependencies: packages.dependencies,\n devDependencies: packages.devDependencies,\n });\n\n return ctx as ScaffoldResult;\n}\n"],"mappings":";;;;;;;;;AAqBA,eAAe,MAAM,UAAkB,UAAiC;CACtE,MAAM,MAAM,KAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;CACvD,MAAM,UAAU,UAAU,UAAU,MAAM;AAC5C;AAEA,eAAsB,gBAAgB,SAAmD;CACvF,MAAM,OAAO,QAAQ;CACrB,MAAM,MAAM;EACV,aAAa,QAAQ;EACrB,WAAW;EACX,MAAM,QAAQ;EACd,GAAI,QAAQ,KAAK;GAAE,IAAI,QAAQ;GAAI,QAAQ,QAAQ;EAAO,IAAI,CAAC;EAC/D,GAAI,QAAQ,SAAS,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EACnD,GAAI,QAAQ,YAAY,EAAE,WAAW,QAAQ,UAAU,IAAI,CAAC;CAC9D;CAEA,MAAM,SAAS,cAAc,GAAG;CAChC,MAAM,WAAW,gBAAgB,GAAG;CACpC,MAAM,eAAe,oBAAoB,GAAG;CAE5C,MAAM,MACJ,KAAK,KAAK,MAAM,cAAc,GAC9B,oBAAoB,QAAQ,aAAa,SAAS,OAAO,CAC3D;CACA,MAAM,MAAM,KAAK,KAAK,MAAM,eAA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Aa,GACf,EACF;CACF,GACA,MACA,CACF,IAAI,IACN;CAGF,MAAM,QAAQ,IACZ,OAAO,IAAI,OAAO,UAAU;EAC1B,MAAM,MAAM,MAAM,MAAM,UAAU,aAAa,MAAM,KAAK,KAAK,MAAM,QAAQ,GAAG,QAAQ,CAAC;CAC3F,CAAC,CACH;CAEA,IAAI;EACF,MAAM,SAAS,KAAK,KAAK,MAAM,cAAc,GAAG,KAAK,KAAK,MAAM,MAAM,CAAC;CACzE,QAAQ,CAER;CAEA,MAAM,mBAAmB,MAAM,GAAG;CAElC,IAAI,QAAQ,aACV,OAAO;CAGT,MAAM,QAAQ,QAAQ,SAAS,iBAAiB;CAChD,MAAM,gBAAgB,OAAO,MAAM;EACjC,cAAc,SAAS;EACvB,iBAAiB,SAAS;CAC5B,CAAC;CAED,OAAO;AACT"}
@@ -1,3 +1,3 @@
1
1
  import { ProjectType } from '../core/types.js';
2
2
  export declare function indexTemplate(type: ProjectType): string;
3
- export declare function taserTsTemplate(type?: ProjectType): string;
3
+ export declare function taserTsTemplate(_type?: ProjectType): string;
@@ -31,7 +31,7 @@ import { t } from '#src/taser.js'
31
31
  const router = t.create(routeManifest)
32
32
 
33
33
  const app = new Hono()
34
- app.all('/*', c => router.native(c).fetch(c.req.raw))
34
+ app.all('/*', c => router.fetch(c.req.raw))
35
35
 
36
36
  const port = Number(process.env.PORT ?? 3000)
37
37
  serve({ fetch: app.fetch, port }, () => {
@@ -93,7 +93,7 @@ import { t } from '#src/taser.js'
93
93
  const router = t.create(routeManifest)
94
94
 
95
95
  const app = new Hono()
96
- app.all('/*', c => router.native(c).fetch(c.req.raw))
96
+ app.all('/*', c => router.fetch(c.req.raw))
97
97
 
98
98
  export const handler = handle(app)
99
99
  `;
@@ -121,7 +121,7 @@ import { t } from '#src/taser.js'
121
121
  const router = t.create(routeManifest)
122
122
 
123
123
  const app = new Hono()
124
- app.all('/*', c => router.native(c).fetch(c.req.raw))
124
+ app.all('/*', c => router.fetch(c.req.raw))
125
125
 
126
126
  export default handle(app)
127
127
  `;
@@ -136,7 +136,7 @@ import { t } from '#src/taser.js'
136
136
  const router = t.create(routeManifest)
137
137
 
138
138
  const app = new Hono()
139
- app.all('/*', c => router.native(c).fetch(c.req.raw))
139
+ app.all('/*', c => router.fetch(c.req.raw))
140
140
 
141
141
  export default handle(app)
142
142
  `;
@@ -152,7 +152,7 @@ import { t } from '#src/taser.js'
152
152
  const router = t.create(routeManifest)
153
153
 
154
154
  const honoApp = new Hono()
155
- honoApp.all('/*', c => router.native(c).fetch(c.req.raw))
155
+ honoApp.all('/*', c => router.fetch(c.req.raw))
156
156
 
157
157
  app.http('httpTrigger', {
158
158
  methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'],
@@ -191,33 +191,14 @@ serve({ fetch: router.fetch, port }, () => {
191
191
  `;
192
192
  }
193
193
  }
194
- function taserTsTemplate(type = "node") {
195
- if (type === "hono" || type === "aws-lambda" || type === "netlify" || type === "vercel" || type === "azure-functions") return `import type { Context } from 'hono'
196
- import { createTaserApp, type InferAppContext } from '@taserjs/router'
194
+ function taserTsTemplate(_type = "node") {
195
+ return `import { createTaserApp } from '@taserjs/router'
197
196
 
198
197
  import { context } from '#src/context.js'
199
198
 
200
- declare module '@taserjs/router' {
201
- interface RouterRegister {
202
- NativeContext: Context
203
- }
204
- }
205
-
206
199
  export const t = createTaserApp({
207
200
  response: { validate: true },
208
201
  }).context(context)
209
-
210
- export type AppContext = InferAppContext<typeof context>
211
- `;
212
- return `import { createTaserApp, type InferAppContext } from '@taserjs/router'
213
-
214
- import { context } from '#src/context.js'
215
-
216
- export const t = createTaserApp({
217
- response: { validate: true },
218
- }).context(context)
219
-
220
- export type AppContext = InferAppContext<typeof context>
221
202
  `;
222
203
  }
223
204
  //#endregion
@@ -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.native(c).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.native(c).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.native(c).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.native(c).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.native(c).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 if (\n type === \"hono\" ||\n type === \"aws-lambda\" ||\n type === \"netlify\" ||\n type === \"vercel\" ||\n type === \"azure-functions\"\n ) {\n return `import type { Context } from 'hono'\nimport { createTaserApp, type InferAppContext } from '@taserjs/router'\n\nimport { context } from '#src/context.js'\n\ndeclare module '@taserjs/router' {\n interface RouterRegister {\n NativeContext: Context\n }\n}\n\nexport const t = createTaserApp({\n response: { validate: true },\n}).context(context)\n\nexport type AppContext = InferAppContext<typeof context>\n`;\n }\n\n return `import { createTaserApp, type InferAppContext } from '@taserjs/router'\n\nimport { context } from '#src/context.js'\n\nexport const t = createTaserApp({\n response: { validate: true },\n}).context(context)\n\nexport type AppContext = InferAppContext<typeof 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,OAAoB,QAAgB;CAClE,IACE,SAAS,UACT,SAAS,gBACT,SAAS,aACT,SAAS,YACT,SAAS,mBAET,OAAO;;;;;;;;;;;;;;;;;CAmBT,OAAO;;;;;;;;;;AAUT"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-taserjs",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Scaffold a new Taser application",
5
5
  "license": "ISC",
6
6
  "repository": {
@@ -64,16 +64,6 @@ export function resolveAddons(ctx: ScaffoldContext): AddonDefinition[] {
64
64
  selected.push(loggerAddon);
65
65
  }
66
66
 
67
- const dbCount = selected.filter((addon) => addon.category === "database").length;
68
- if (dbCount > 1) {
69
- throw new Error("Only one database addon can be selected");
70
- }
71
-
72
- const loggerCount = selected.filter((addon) => addon.category === "logger").length;
73
- if (loggerCount > 1) {
74
- throw new Error("Only one logger addon can be selected");
75
- }
76
-
77
67
  if (ctx.validator) {
78
68
  const validatorAddon = VALIDATOR_ADDONS.find((addon) => addon.id === ctx.validator);
79
69
  if (!validatorAddon) {
@@ -82,11 +72,6 @@ export function resolveAddons(ctx: ScaffoldContext): AddonDefinition[] {
82
72
  selected.push(validatorAddon);
83
73
  }
84
74
 
85
- const validatorCount = selected.filter((addon) => addon.category === "validator").length;
86
- if (validatorCount > 1) {
87
- throw new Error("Only one validator addon can be selected");
88
- }
89
-
90
75
  return selected;
91
76
  }
92
77
 
@@ -9,13 +9,13 @@ export const IMPORT_LINES: Record<ValidatorId, string> = {
9
9
 
10
10
  export const VALIDATION_BLOCK_TEMPLATE: Record<ValidatorId, string> = {
11
11
  zod: `, {
12
- query: z.object({ name: z.string() }),
12
+ query: z.object({ name: z.string().default('Taser') }),
13
13
  }`,
14
14
  arktype: `, {
15
- query: type({ name: 'string' }),
15
+ query: type({ 'name?': 'string = "Taser"' }),
16
16
  }`,
17
17
  valibot: `, {
18
- query: v.object({ name: v.string() }),
18
+ query: v.object({ name: v.optional(v.string(), 'Taser') }),
19
19
  }`,
20
20
  };
21
21
 
@@ -128,14 +128,7 @@ export async function scaffoldProject(options: ScaffoldOptions): Promise<Scaffol
128
128
  await writeProjectConfig(root, ctx);
129
129
 
130
130
  if (options.skipInstall) {
131
- return {
132
- projectName: ctx.projectName,
133
- targetDir: root,
134
- type: ctx.type,
135
- ...(ctx.db ? { db: ctx.db, driver: ctx.driver } : {}),
136
- ...(ctx.logger ? { logger: ctx.logger } : {}),
137
- ...(ctx.validator ? { validator: ctx.validator } : {}),
138
- };
131
+ return ctx as ScaffoldResult;
139
132
  }
140
133
 
141
134
  const agent = options.agent ?? resolveUserAgent();
@@ -144,12 +137,5 @@ export async function scaffoldProject(options: ScaffoldOptions): Promise<Scaffol
144
137
  devDependencies: packages.devDependencies,
145
138
  });
146
139
 
147
- return {
148
- projectName: ctx.projectName,
149
- targetDir: root,
150
- type: ctx.type,
151
- ...(ctx.db ? { db: ctx.db, driver: ctx.driver } : {}),
152
- ...(ctx.logger ? { logger: ctx.logger } : {}),
153
- ...(ctx.validator ? { validator: ctx.validator } : {}),
154
- };
140
+ return ctx as ScaffoldResult;
155
141
  }
@@ -34,7 +34,7 @@ import { t } from '#src/taser.js'
34
34
  const router = t.create(routeManifest)
35
35
 
36
36
  const app = new Hono()
37
- app.all('/*', c => router.native(c).fetch(c.req.raw))
37
+ app.all('/*', c => router.fetch(c.req.raw))
38
38
 
39
39
  const port = Number(process.env.PORT ?? 3000)
40
40
  serve({ fetch: app.fetch, port }, () => {
@@ -100,7 +100,7 @@ import { t } from '#src/taser.js'
100
100
  const router = t.create(routeManifest)
101
101
 
102
102
  const app = new Hono()
103
- app.all('/*', c => router.native(c).fetch(c.req.raw))
103
+ app.all('/*', c => router.fetch(c.req.raw))
104
104
 
105
105
  export const handler = handle(app)
106
106
  `;
@@ -130,7 +130,7 @@ import { t } from '#src/taser.js'
130
130
  const router = t.create(routeManifest)
131
131
 
132
132
  const app = new Hono()
133
- app.all('/*', c => router.native(c).fetch(c.req.raw))
133
+ app.all('/*', c => router.fetch(c.req.raw))
134
134
 
135
135
  export default handle(app)
136
136
  `;
@@ -146,7 +146,7 @@ import { t } from '#src/taser.js'
146
146
  const router = t.create(routeManifest)
147
147
 
148
148
  const app = new Hono()
149
- app.all('/*', c => router.native(c).fetch(c.req.raw))
149
+ app.all('/*', c => router.fetch(c.req.raw))
150
150
 
151
151
  export default handle(app)
152
152
  `;
@@ -163,7 +163,7 @@ import { t } from '#src/taser.js'
163
163
  const router = t.create(routeManifest)
164
164
 
165
165
  const honoApp = new Hono()
166
- honoApp.all('/*', c => router.native(c).fetch(c.req.raw))
166
+ honoApp.all('/*', c => router.fetch(c.req.raw))
167
167
 
168
168
  app.http('httpTrigger', {
169
169
  methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'],
@@ -206,41 +206,13 @@ serve({ fetch: router.fetch, port }, () => {
206
206
  }
207
207
  }
208
208
 
209
- export function taserTsTemplate(type: ProjectType = "node"): string {
210
- if (
211
- type === "hono" ||
212
- type === "aws-lambda" ||
213
- type === "netlify" ||
214
- type === "vercel" ||
215
- type === "azure-functions"
216
- ) {
217
- return `import type { Context } from 'hono'
218
- import { createTaserApp, type InferAppContext } from '@taserjs/router'
219
-
220
- import { context } from '#src/context.js'
221
-
222
- declare module '@taserjs/router' {
223
- interface RouterRegister {
224
- NativeContext: Context
225
- }
226
- }
227
-
228
- export const t = createTaserApp({
229
- response: { validate: true },
230
- }).context(context)
231
-
232
- export type AppContext = InferAppContext<typeof context>
233
- `;
234
- }
235
-
236
- return `import { createTaserApp, type InferAppContext } from '@taserjs/router'
209
+ export function taserTsTemplate(_type: ProjectType = "node"): string {
210
+ return `import { createTaserApp } from '@taserjs/router'
237
211
 
238
212
  import { context } from '#src/context.js'
239
213
 
240
214
  export const t = createTaserApp({
241
215
  response: { validate: true },
242
216
  }).context(context)
243
-
244
- export type AppContext = InferAppContext<typeof context>
245
217
  `;
246
218
  }