@batijs/cli 0.0.476 → 0.0.478

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 (129) hide show
  1. package/dist/boilerplates/@batijs/auth0/files/$.env.js +6 -5
  2. package/dist/boilerplates/@batijs/auth0/files/$README.md.js +3 -3
  3. package/dist/boilerplates/@batijs/auth0/files/$wrangler.toml.js +32 -0
  4. package/dist/boilerplates/@batijs/authjs/files/$package.json.js +7 -6
  5. package/dist/boilerplates/@batijs/authjs/files/server/authjs-handler.ts +42 -35
  6. package/dist/boilerplates/@batijs/authjs/types/server/authjs-handler.d.ts +8 -3
  7. package/dist/boilerplates/@batijs/aws/files/$README.md.js +3 -3
  8. package/dist/boilerplates/@batijs/aws/files/$package.json.js +10 -10
  9. package/dist/boilerplates/@batijs/aws/files/$tsconfig.json.js +3 -3
  10. package/dist/boilerplates/@batijs/biome/files/$package.json.js +4 -4
  11. package/dist/boilerplates/@batijs/cloudflare/files/$package.json.js +17 -26
  12. package/dist/boilerplates/@batijs/cloudflare/files/wrangler.toml +2 -3
  13. package/dist/boilerplates/@batijs/compiled/files/$package.json.js +5 -5
  14. package/dist/boilerplates/@batijs/compiled/files/$vite.config.ts.js +5 -5
  15. package/dist/boilerplates/@batijs/d1/files/$README.md.js +4 -4
  16. package/dist/boilerplates/@batijs/d1/files/$package.json.js +8 -8
  17. package/dist/boilerplates/@batijs/d1/files/$tsconfig.json.js +3 -3
  18. package/dist/boilerplates/@batijs/d1/files/database/d1/helpers.ts +3 -11
  19. package/dist/boilerplates/@batijs/d1-sqlite/files/$package.json.js +7 -7
  20. package/dist/boilerplates/@batijs/drizzle/files/$.env.js +3 -3
  21. package/dist/boilerplates/@batijs/drizzle/files/$README.md.js +3 -3
  22. package/dist/boilerplates/@batijs/drizzle/files/$package.json.js +8 -8
  23. package/dist/boilerplates/@batijs/eslint/files/$package.json.js +8 -8
  24. package/dist/boilerplates/@batijs/eslint/types/eslint.config.d.ts +1 -1
  25. package/dist/boilerplates/@batijs/express/files/$package.json.js +16 -29
  26. package/dist/boilerplates/@batijs/express/files/server/entry.ts +45 -0
  27. package/dist/boilerplates/@batijs/express/types/server/entry.d.ts +3 -0
  28. package/dist/boilerplates/@batijs/fastify/files/$package.json.js +18 -32
  29. package/dist/boilerplates/@batijs/fastify/files/server/entry.ts +52 -0
  30. package/dist/boilerplates/@batijs/fastify/types/server/entry.d.ts +4 -0
  31. package/dist/boilerplates/@batijs/google-analytics/files/$.env.js +3 -3
  32. package/dist/boilerplates/@batijs/h3/files/$package.json.js +21 -32
  33. package/dist/boilerplates/@batijs/h3/files/server/entry.ts +45 -0
  34. package/dist/boilerplates/@batijs/{express/types/express-entry.d.ts → h3/types/server/entry.d.ts} +1 -1
  35. package/dist/boilerplates/@batijs/hono/files/$package.json.js +23 -40
  36. package/dist/boilerplates/@batijs/hono/files/entry_aws_lambda.ts +2 -9
  37. package/dist/boilerplates/@batijs/hono/files/server/entry.ts +53 -0
  38. package/dist/boilerplates/@batijs/hono/types/server/entry.d.ts +4 -0
  39. package/dist/boilerplates/@batijs/mantine/files/$README.md.js +3 -3
  40. package/dist/boilerplates/@batijs/mantine/files/$package.json.js +12 -12
  41. package/dist/boilerplates/@batijs/photon/files/$README.md.js +29 -0
  42. package/dist/boilerplates/@batijs/photon/files/$package.json.js +109 -0
  43. package/dist/boilerplates/@batijs/photon/files/+photon.ts +7 -0
  44. package/dist/boilerplates/@batijs/photon/types/+photon.d.ts +4 -0
  45. package/dist/boilerplates/@batijs/pnpm/files/$pnpm-workspace.yaml.js +3 -3
  46. package/dist/boilerplates/@batijs/prettier/files/$package.json.js +4 -4
  47. package/dist/boilerplates/@batijs/prisma/files/$.env.js +3 -3
  48. package/dist/boilerplates/@batijs/prisma/files/$README.md.js +3 -3
  49. package/dist/boilerplates/@batijs/prisma/files/$package.json.js +6 -6
  50. package/dist/boilerplates/@batijs/react/files/$README.md.js +3 -3
  51. package/dist/boilerplates/@batijs/react/files/$package.json.js +16 -15
  52. package/dist/boilerplates/@batijs/react/files/$tsconfig.json.js +3 -3
  53. package/dist/boilerplates/@batijs/react/files/$vite.config.ts.js +5 -5
  54. package/dist/boilerplates/@batijs/react/files/pages/+config.ts +6 -1
  55. package/dist/boilerplates/@batijs/react/types/pages/+config.d.ts +63 -2
  56. package/dist/boilerplates/@batijs/react-sentry/files/$package.json.js +10 -10
  57. package/dist/boilerplates/@batijs/sentry/files/$.env.js +4 -4
  58. package/dist/boilerplates/@batijs/sentry/files/$README.md.js +3 -3
  59. package/dist/boilerplates/@batijs/sentry/files/$package.json.js +6 -6
  60. package/dist/boilerplates/@batijs/sentry/files/$vite.config.ts.js +7 -7
  61. package/dist/boilerplates/@batijs/sentry/files/pages/$+client.ts.js +9 -9
  62. package/dist/boilerplates/@batijs/shadcn-ui/files/$README.md.js +3 -3
  63. package/dist/boilerplates/@batijs/shadcn-ui/files/$package.json.js +7 -7
  64. package/dist/boilerplates/@batijs/shadcn-ui/files/$tsconfig.json.js +3 -3
  65. package/dist/boilerplates/@batijs/shadcn-ui/files/$vite.config.ts.js +5 -5
  66. package/dist/boilerplates/@batijs/shared/files/$README.md.js +9 -9
  67. package/dist/boilerplates/@batijs/shared/files/package.json +3 -3
  68. package/dist/boilerplates/@batijs/shared/files/vite.config.ts +1 -20
  69. package/dist/boilerplates/@batijs/shared-db/files/server/db-middleware.ts +21 -15
  70. package/dist/boilerplates/@batijs/shared-db/types/server/db-middleware.d.ts +2 -2
  71. package/dist/boilerplates/@batijs/shared-server/files/$package.json.js +8 -14
  72. package/dist/boilerplates/@batijs/shared-server/files/server/create-todo-handler.ts +33 -34
  73. package/dist/boilerplates/@batijs/shared-server/types/server/create-todo-handler.d.ts +3 -4
  74. package/dist/boilerplates/@batijs/solid/files/$README.md.js +3 -3
  75. package/dist/boilerplates/@batijs/solid/files/$package.json.js +11 -10
  76. package/dist/boilerplates/@batijs/solid/files/$tsconfig.json.js +3 -3
  77. package/dist/boilerplates/@batijs/solid/files/$vite.config.ts.js +5 -5
  78. package/dist/boilerplates/@batijs/solid/files/pages/+config.ts +6 -1
  79. package/dist/boilerplates/@batijs/solid/types/pages/+config.d.ts +70 -2
  80. package/dist/boilerplates/@batijs/solid-sentry/files/$package.json.js +7 -7
  81. package/dist/boilerplates/@batijs/sqlite/files/$.env.js +3 -3
  82. package/dist/boilerplates/@batijs/sqlite/files/$README.md.js +4 -3
  83. package/dist/boilerplates/@batijs/sqlite/files/$package.json.js +7 -7
  84. package/dist/boilerplates/@batijs/tailwindcss/files/$package.json.js +9 -9
  85. package/dist/boilerplates/@batijs/tailwindcss/files/$vite.config.ts.js +5 -5
  86. package/dist/boilerplates/@batijs/telefunc/files/$package.json.js +9 -9
  87. package/dist/boilerplates/@batijs/telefunc/files/$vite.config.ts.js +5 -5
  88. package/dist/boilerplates/@batijs/telefunc/files/server/telefunc-handler.ts +34 -27
  89. package/dist/boilerplates/@batijs/telefunc/types/server/telefunc-handler.d.ts +2 -2
  90. package/dist/boilerplates/@batijs/trpc/files/$package.json.js +9 -9
  91. package/dist/boilerplates/@batijs/trpc/files/server/trpc-handler.ts +26 -18
  92. package/dist/boilerplates/@batijs/trpc/types/server/trpc-handler.d.ts +6 -1
  93. package/dist/boilerplates/@batijs/trpc/types/trpc/client.d.ts +1 -1
  94. package/dist/boilerplates/@batijs/ts-rest/files/$package.json.js +6 -6
  95. package/dist/boilerplates/@batijs/ts-rest/files/server/ts-rest-handler.ts +21 -14
  96. package/dist/boilerplates/@batijs/ts-rest/types/server/ts-rest-handler.d.ts +2 -2
  97. package/dist/boilerplates/@batijs/vercel/files/$package.json.js +8 -9
  98. package/dist/boilerplates/@batijs/vercel/files/pages/$+config.ts.js +3 -3
  99. package/dist/boilerplates/@batijs/vue/files/$README.md.js +3 -3
  100. package/dist/boilerplates/@batijs/vue/files/$package.json.js +15 -14
  101. package/dist/boilerplates/@batijs/vue/files/$tsconfig.json.js +3 -3
  102. package/dist/boilerplates/@batijs/vue/files/$vite.config.ts.js +6 -6
  103. package/dist/boilerplates/@batijs/vue/files/pages/+config.ts +6 -1
  104. package/dist/boilerplates/@batijs/vue/types/pages/+config.d.ts +1 -2
  105. package/dist/boilerplates/@batijs/vue-sentry/files/$package.json.js +8 -8
  106. package/dist/boilerplates/boilerplates.json +20 -0
  107. package/dist/{chunk-2SZ4N3E5.js → chunk-LRTYGOU6.js} +83539 -83181
  108. package/dist/index.js +720 -659
  109. package/dist/jiti-ZW3ADF2F-7XIEJQMO.js +2982 -0
  110. package/dist/src-5HGZFBZ3-KQZBBJSW.js +468 -0
  111. package/package.json +10 -10
  112. package/dist/boilerplates/@batijs/cloudflare/files/$tsconfig.json.js +0 -19
  113. package/dist/boilerplates/@batijs/cloudflare/files/$vite.config.ts.js +0 -34
  114. package/dist/boilerplates/@batijs/express/files/express-entry.ts +0 -102
  115. package/dist/boilerplates/@batijs/fastify/files/fastify-entry.ts +0 -140
  116. package/dist/boilerplates/@batijs/fastify/types/fastify-entry.d.ts +0 -3
  117. package/dist/boilerplates/@batijs/h3/files/h3-entry.ts +0 -144
  118. package/dist/boilerplates/@batijs/h3/types/h3-entry.d.ts +0 -4
  119. package/dist/boilerplates/@batijs/hono/files/$vite.config.ts.js +0 -36
  120. package/dist/boilerplates/@batijs/hono/files/hono-entry.node.ts +0 -31
  121. package/dist/boilerplates/@batijs/hono/files/hono-entry.ts +0 -74
  122. package/dist/boilerplates/@batijs/hono/types/hono-entry.d.ts +0 -6
  123. package/dist/boilerplates/@batijs/hono/types/hono-entry.node.d.ts +0 -1
  124. package/dist/boilerplates/@batijs/shared-server/files/server/vike-handler.ts +0 -20
  125. package/dist/boilerplates/@batijs/shared-server/types/server/vike-handler.d.ts +0 -2
  126. package/dist/boilerplates/@batijs/vercel/files/$tsconfig.json.js +0 -19
  127. package/dist/boilerplates/@batijs/vercel/files/$vite.config.ts.js +0 -27
  128. package/dist/jiti-W5Y5D52V-VBLACVBV.js +0 -30587
  129. package/dist/src-UAKFXUB2-DFO2P37K.js +0 -417
@@ -1,140 +0,0 @@
1
- // BATI.has("auth0") || BATI.hasDatabase
2
- import "dotenv/config";
3
- import { dirname } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import { authjsHandler, authjsSessionMiddleware } from "@batijs/authjs/server/authjs-handler";
6
- import { dbMiddleware } from "@batijs/shared-db/server/db-middleware";
7
- import { createTodoHandler } from "@batijs/shared-server/server/create-todo-handler";
8
- import { vikeHandler } from "@batijs/shared-server/server/vike-handler";
9
- import { telefuncHandler } from "@batijs/telefunc/server/telefunc-handler";
10
- import { trpcHandler } from "@batijs/trpc/server/trpc-handler";
11
- import { tsRestHandler } from "@batijs/ts-rest/server/ts-rest-handler";
12
- import { createHandler, createMiddleware } from "@universal-middleware/fastify";
13
- import Fastify from "fastify";
14
- import { createDevMiddleware } from "vike";
15
-
16
- const __filename = fileURLToPath(import.meta.url);
17
- const __dirname = dirname(__filename);
18
- const root = __dirname;
19
- const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;
20
- const hmrPort = process.env.HMR_PORT ? parseInt(process.env.HMR_PORT, 10) : 24678;
21
-
22
- async function startServer() {
23
- const app = Fastify();
24
-
25
- // Avoid pre-parsing body, otherwise it will cause issue with universal handlers
26
- // This will probably change in the future though, you can follow https://github.com/magne4000/universal-middleware for updates
27
- app.removeAllContentTypeParsers();
28
- app.addContentTypeParser("*", (_request, _payload, done) => {
29
- done(null, "");
30
- });
31
-
32
- await app.register(await import("@fastify/middie"));
33
-
34
- if (process.env.NODE_ENV === "production") {
35
- await app.register(await import("@fastify/static"), {
36
- root: `${root}/dist/client`,
37
- wildcard: false,
38
- });
39
- } else {
40
- // Instantiate Vite's development server and integrate its middleware to our server.
41
- // ⚠️ We should instantiate it *only* in development. (It isn't needed in production
42
- // and would unnecessarily bloat our server in production.)
43
- const viteDevMiddleware = (
44
- await createDevMiddleware({
45
- root,
46
- viteConfig: {
47
- server: { hmr: { port: hmrPort } },
48
- },
49
- })
50
- ).devMiddleware;
51
- app.use(viteDevMiddleware);
52
- }
53
-
54
- if (BATI.hasDatabase) {
55
- /**
56
- * Make database available in Context as `context.db`
57
- */
58
- await app.register(createMiddleware(dbMiddleware)());
59
- }
60
-
61
- if (BATI.has("authjs") || BATI.has("auth0")) {
62
- /**
63
- * Append Auth.js session to context
64
- **/
65
- await app.register(createMiddleware(authjsSessionMiddleware)());
66
-
67
- /**
68
- * Auth.js route
69
- * @link {@see https://authjs.dev/getting-started/installation}
70
- **/
71
- app.all("/api/auth/*", createHandler(authjsHandler)());
72
- }
73
-
74
- if (BATI.has("trpc")) {
75
- /**
76
- * tRPC route
77
- *
78
- * @link {@see https://trpc.io/docs/server/adapters/fetch}
79
- **/
80
- app.all("/api/trpc/*", createHandler(trpcHandler)("/api/trpc"));
81
- }
82
-
83
- if (BATI.has("telefunc")) {
84
- /**
85
- * Telefunc route
86
- *
87
- * @link {@see https://telefunc.com}
88
- **/
89
- app.post<{ Body: string }>("/_telefunc", createHandler(telefuncHandler)());
90
- }
91
-
92
- if (BATI.has("ts-rest")) {
93
- app.all("/api/*", createHandler(tsRestHandler)());
94
- }
95
-
96
- if (!BATI.has("telefunc") && !BATI.has("trpc") && !BATI.has("ts-rest")) {
97
- app.post("/api/todo/create", createHandler(createTodoHandler)());
98
- }
99
-
100
- /**
101
- * Vike route
102
- *
103
- * @link {@see https://vike.dev}
104
- **/
105
- app.all("/*", createHandler(vikeHandler)());
106
-
107
- return app;
108
- }
109
-
110
- const app = await startServer();
111
-
112
- //# BATI.has('vercel')
113
- // Vercel handler
114
- export default async (req: Request, res: Response) => {
115
- await app.ready();
116
- app.server.emit("request", req, res);
117
- };
118
-
119
- if (BATI.has("vercel")) {
120
- // Development listener
121
- if (process.env.NODE_ENV !== "production") {
122
- app.listen(
123
- {
124
- port: port,
125
- },
126
- () => {
127
- console.log(`Server listening on http://localhost:${port}`);
128
- },
129
- );
130
- }
131
- } else {
132
- app.listen(
133
- {
134
- port: port,
135
- },
136
- () => {
137
- console.log(`Server listening on http://localhost:${port}`);
138
- },
139
- );
140
- }
@@ -1,3 +0,0 @@
1
- import "dotenv/config";
2
- declare const _default: (req: Request, res: Response) => Promise<void>;
3
- export default _default;
@@ -1,144 +0,0 @@
1
- // BATI.has("auth0") || BATI.hasDatabase
2
- import "dotenv/config";
3
- import { createServer, type IncomingMessage, type ServerResponse } from "node:http";
4
- import { dirname } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import { authjsHandler, authjsSessionMiddleware } from "@batijs/authjs/server/authjs-handler";
7
- import { dbMiddleware } from "@batijs/shared-db/server/db-middleware";
8
- import { createTodoHandler } from "@batijs/shared-server/server/create-todo-handler";
9
- import { vikeHandler } from "@batijs/shared-server/server/vike-handler";
10
- import { telefuncHandler } from "@batijs/telefunc/server/telefunc-handler";
11
- import { appRouter } from "@batijs/trpc/trpc/server";
12
- import { tsRestHandler } from "@batijs/ts-rest/server/ts-rest-handler";
13
- import installCrypto from "@hattip/polyfills/crypto";
14
- import installGetSetCookie from "@hattip/polyfills/get-set-cookie";
15
- import installWhatwgNodeFetch from "@hattip/polyfills/whatwg-node";
16
- import { type NodeHTTPCreateContextFnOptions, nodeHTTPRequestHandler } from "@trpc/server/adapters/node-http";
17
- import { createHandler, createMiddleware, getContext } from "@universal-middleware/h3";
18
- import { createApp, createRouter, eventHandler, fromNodeMiddleware, toNodeListener } from "h3";
19
- import serveStatic from "serve-static";
20
- import { createDevMiddleware } from "vike";
21
-
22
- installWhatwgNodeFetch();
23
- installGetSetCookie();
24
- installCrypto();
25
-
26
- const __filename = fileURLToPath(import.meta.url);
27
- const __dirname = dirname(__filename);
28
- const root = __dirname;
29
- const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;
30
- const hmrPort = process.env.HMR_PORT ? parseInt(process.env.HMR_PORT, 10) : 24678;
31
-
32
- export default await startServer();
33
-
34
- async function startServer() {
35
- const app = createApp();
36
-
37
- if (process.env.NODE_ENV === "production") {
38
- app.use("/", fromNodeMiddleware(serveStatic(`${root}/dist/client`)));
39
- } else {
40
- // Instantiate Vite's development server and integrate its middleware to our server.
41
- // ⚠️ We should instantiate it *only* in development. (It isn't needed in production
42
- // and would unnecessarily bloat our server in production.)
43
- const viteDevMiddleware = (
44
- await createDevMiddleware({
45
- root,
46
- viteConfig: {
47
- server: { hmr: { port: hmrPort } },
48
- },
49
- })
50
- ).devMiddleware;
51
- app.use(fromNodeMiddleware(viteDevMiddleware));
52
- }
53
-
54
- const router = createRouter();
55
-
56
- if (BATI.hasDatabase) {
57
- /**
58
- * Make database available in Context as `context.db`
59
- */
60
- app.use(createMiddleware(dbMiddleware)());
61
- }
62
-
63
- if (BATI.has("authjs") || BATI.has("auth0")) {
64
- /**
65
- * Append Auth.js session to context
66
- **/
67
- app.use(createMiddleware(authjsSessionMiddleware)());
68
-
69
- /**
70
- * Auth.js route
71
- * @link {@see https://authjs.dev/getting-started/installation}
72
- **/
73
- router.use("/api/auth/**", createHandler(authjsHandler)());
74
- }
75
-
76
- if (BATI.has("trpc")) {
77
- /**
78
- * tRPC route
79
- *
80
- * @link {@see https://trpc.io/docs/server/adapters}
81
- **/
82
- router.use(
83
- "/api/trpc/**:path",
84
- eventHandler((event) =>
85
- nodeHTTPRequestHandler({
86
- req: event.node.req,
87
- res: event.node.res,
88
- // biome-ignore lint/style/noNonNullAssertion: param exists
89
- path: event.context.params!.path,
90
- router: appRouter,
91
- createContext({ req, res }: NodeHTTPCreateContextFnOptions<IncomingMessage, ServerResponse>) {
92
- return { ...getContext(event), req, res } as BATI.Any;
93
- },
94
- }),
95
- ),
96
- );
97
- }
98
-
99
- if (BATI.has("telefunc")) {
100
- /**
101
- * Telefunc route
102
- *
103
- * @link {@see https://telefunc.com}
104
- **/
105
- router.post("/_telefunc", createHandler(telefuncHandler)());
106
- }
107
-
108
- if (BATI.has("ts-rest")) {
109
- router.use("/api/**", createHandler(tsRestHandler)());
110
- }
111
-
112
- if (!BATI.has("telefunc") && !BATI.has("trpc") && !BATI.has("ts-rest")) {
113
- router.post("/api/todo/create", createHandler(createTodoHandler)());
114
- }
115
-
116
- /**
117
- * Vike route
118
- *
119
- * @link {@see https://vike.dev}
120
- **/
121
- router.use("/**", createHandler(vikeHandler)());
122
-
123
- app.use(router);
124
-
125
- const server = createServer(toNodeListener(app));
126
-
127
- if (BATI.has("vercel")) {
128
- if (process.env.NODE_ENV !== "production") {
129
- server.listen(port);
130
-
131
- server.on("listening", () => {
132
- console.log(`Server listening on http://localhost:${port}`);
133
- });
134
- }
135
- } else {
136
- server.listen(port);
137
-
138
- server.on("listening", () => {
139
- console.log(`Server listening on http://localhost:${port}`);
140
- });
141
- }
142
-
143
- return server;
144
- }
@@ -1,4 +0,0 @@
1
- import "dotenv/config";
2
- import { type IncomingMessage, type ServerResponse } from "node:http";
3
- declare const _default: import("http").Server<typeof IncomingMessage, typeof ServerResponse>;
4
- export default _default;
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as createRequire_BATI_CLI } from 'module';
3
- const require = createRequire_BATI_CLI(import.meta.url);
4
-
5
- import {
6
- Zri,
7
- rxs
8
- } from "../../../../chunk-2SZ4N3E5.js";
9
- import "../../../../chunk-IAWYWZSL.js";
10
- import "../../../../chunk-DHZ7AZKP.js";
11
-
12
- // ../../boilerplates/hono/dist/files/$vite.config.ts.js
13
- async function getViteConfig(props) {
14
- const mod = await rxs(props);
15
- Zri(mod, {
16
- from: "@hono/vite-dev-server",
17
- constructor: "devServer",
18
- options: {
19
- entry: "hono-entry.ts",
20
- exclude: [
21
- /^\/@.+$/,
22
- /.*\.(ts|tsx|vue)($|\?)/,
23
- /.*\.(s?css|less)($|\?)/,
24
- /^\/favicon\.ico$/,
25
- /.*\.(svg|png)($|\?)/,
26
- /^\/(public|assets|static)\/.+/,
27
- /^\/node_modules\/.*/
28
- ],
29
- injectClientScript: false
30
- }
31
- });
32
- return mod.generate().code;
33
- }
34
- export {
35
- getViteConfig as default
36
- };
@@ -1,31 +0,0 @@
1
- import { serve } from "@hono/node-server";
2
- import { serveStatic } from "@hono/node-server/serve-static";
3
- import { type Context, Hono } from "hono";
4
- import { env } from "hono/adapter";
5
- import { compress } from "hono/compress";
6
- import app from "./hono-entry.js";
7
-
8
- const envs = env<{ NODE_ENV?: string; PORT?: string }>({ env: {} } as unknown as Context<{
9
- Bindings: { NODE_ENV?: string; PORT?: string };
10
- }>);
11
-
12
- const nodeApp = new Hono();
13
-
14
- nodeApp.use(compress());
15
-
16
- nodeApp.use(
17
- "/*",
18
- serveStatic({
19
- root: `./dist/client/`,
20
- }),
21
- );
22
-
23
- nodeApp.route("/", app as Hono);
24
-
25
- const port = envs.PORT ? parseInt(envs.PORT, 10) : 3000;
26
-
27
- console.log(`Server listening on http://localhost:${port}`);
28
- serve({
29
- fetch: nodeApp.fetch,
30
- port: port,
31
- });
@@ -1,74 +0,0 @@
1
- // BATI.has("auth0") || BATI.hasDatabase
2
- import "dotenv/config";
3
- import { authjsHandler, authjsSessionMiddleware } from "@batijs/authjs/server/authjs-handler";
4
- import { dbMiddleware } from "@batijs/shared-db/server/db-middleware";
5
- import { createTodoHandler } from "@batijs/shared-server/server/create-todo-handler";
6
- import { vikeHandler } from "@batijs/shared-server/server/vike-handler";
7
- import { telefuncHandler } from "@batijs/telefunc/server/telefunc-handler";
8
- import { trpcHandler } from "@batijs/trpc/server/trpc-handler";
9
- import { tsRestHandler } from "@batijs/ts-rest/server/ts-rest-handler";
10
- import { createHandler, createMiddleware } from "@universal-middleware/hono";
11
- import { Hono } from "hono";
12
- import { handle } from "hono/vercel";
13
-
14
- const app = new Hono();
15
-
16
- if (BATI.hasDatabase) {
17
- /**
18
- * Make database available in Context as `context.db`
19
- */
20
- app.use(createMiddleware(dbMiddleware)());
21
- }
22
-
23
- if (BATI.has("authjs") || BATI.has("auth0")) {
24
- /**
25
- * Append Auth.js session to context
26
- **/
27
- app.use(createMiddleware(authjsSessionMiddleware)());
28
-
29
- /**
30
- * Auth.js route
31
- * @link {@see https://authjs.dev/getting-started/installation}
32
- **/
33
- app.use("/api/auth/**", createHandler(authjsHandler)());
34
- }
35
-
36
- if (BATI.has("trpc")) {
37
- /**
38
- * tRPC route
39
- *
40
- * @link {@see https://trpc.io/docs/server/adapters}
41
- **/
42
- app.use("/api/trpc/*", createHandler(trpcHandler)("/api/trpc"));
43
- }
44
-
45
- if (BATI.has("telefunc")) {
46
- /**
47
- * Telefunc route
48
- *
49
- * @link {@see https://telefunc.com}
50
- **/
51
- app.post("/_telefunc", createHandler(telefuncHandler)());
52
- }
53
-
54
- if (BATI.has("ts-rest")) {
55
- app.all("/api/*", createHandler(tsRestHandler)());
56
- }
57
-
58
- if (!BATI.has("telefunc") && !BATI.has("trpc") && !BATI.has("ts-rest")) {
59
- app.post("/api/todo/create", createHandler(createTodoHandler)());
60
- }
61
-
62
- /**
63
- * Vike route
64
- *
65
- * @link {@see https://vike.dev}
66
- **/
67
- app.all("*", createHandler(vikeHandler)());
68
-
69
- //# BATI.has("vercel")
70
- export const GET = handle(app);
71
- //# BATI.has("vercel")
72
- export const POST = handle(app);
73
-
74
- export default BATI.has("vercel") ? (process.env.NODE_ENV === "production" ? undefined : app) : app;
@@ -1,6 +0,0 @@
1
- import "dotenv/config";
2
- import { Hono } from "hono";
3
- export declare const GET: (req: Request) => Response | Promise<Response>;
4
- export declare const POST: (req: Request) => Response | Promise<Response>;
5
- declare const _default: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/"> | undefined;
6
- export default _default;
@@ -1,20 +0,0 @@
1
- /*# BATI include-if-imported #*/
2
- /// <reference lib="webworker" />
3
-
4
- // TODO: stop using universal-middleware and directly integrate server middlewares instead and/or use vike-server https://vike.dev/vike-server. (Bati generates boilerplates that use universal-middleware https://github.com/magne4000/universal-middleware to make Bati's internal logic easier. This is temporary and will be removed soon.)
5
- import type { Get, UniversalHandler } from "@universal-middleware/core";
6
- import { renderPage } from "vike/server";
7
-
8
- export const vikeHandler: Get<[], UniversalHandler> = () => async (request, context, runtime) => {
9
- const pageContextInit = { ...context, ...runtime, urlOriginal: request.url, headersOriginal: request.headers };
10
- const pageContext = await renderPage(pageContextInit);
11
- const response = pageContext.httpResponse;
12
-
13
- const { readable, writable } = new TransformStream();
14
- response.pipe(writable);
15
-
16
- return new Response(readable, {
17
- status: response.statusCode,
18
- headers: response.headers,
19
- });
20
- };
@@ -1,2 +0,0 @@
1
- import type { Get, UniversalHandler } from "@universal-middleware/core";
2
- export declare const vikeHandler: Get<[], UniversalHandler>;
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as createRequire_BATI_CLI } from 'module';
3
- const require = createRequire_BATI_CLI(import.meta.url);
4
-
5
- import {
6
- exs
7
- } from "../../../../chunk-2SZ4N3E5.js";
8
- import "../../../../chunk-IAWYWZSL.js";
9
- import "../../../../chunk-DHZ7AZKP.js";
10
-
11
- // ../../boilerplates/vercel/dist/files/$tsconfig.json.js
12
- async function getTsConfig(props) {
13
- const tsConfig = await exs(props);
14
- tsConfig.compilerOptions.types = [...tsConfig.compilerOptions.types ?? [], "vite-plugin-vercel/types"];
15
- return tsConfig;
16
- }
17
- export {
18
- getTsConfig as default
19
- };
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as createRequire_BATI_CLI } from 'module';
3
- const require = createRequire_BATI_CLI(import.meta.url);
4
-
5
- import {
6
- Zri,
7
- rxs
8
- } from "../../../../chunk-2SZ4N3E5.js";
9
- import "../../../../chunk-IAWYWZSL.js";
10
- import "../../../../chunk-DHZ7AZKP.js";
11
-
12
- // ../../boilerplates/vercel/dist/files/$vite.config.ts.js
13
- async function getViteConfig(props) {
14
- const mod = await rxs(props);
15
- const options = props.meta.BATI.has("express") || props.meta.BATI.has("fastify") ? {
16
- source: "/.*"
17
- } : void 0;
18
- Zri(mod, {
19
- from: "vite-plugin-vercel",
20
- constructor: "vercel",
21
- options
22
- });
23
- return mod.generate().code;
24
- }
25
- export {
26
- getViteConfig as default
27
- };