@batijs/cli 0.0.202 → 0.0.204

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 (39) hide show
  1. package/dist/boilerplates/@batijs/compiled/files/$vite.config.ts.js +2 -1
  2. package/dist/boilerplates/@batijs/edgedb/files/$package.json.js +1 -1
  3. package/dist/boilerplates/@batijs/eslint/files/$package.json.js +2 -2
  4. package/dist/boilerplates/@batijs/express/files/$package.json.js +2 -2
  5. package/dist/boilerplates/@batijs/express/files/express-entry.ts +6 -1
  6. package/dist/boilerplates/@batijs/fastify/files/$package.json.js +2 -2
  7. package/dist/boilerplates/@batijs/fastify/files/fastify-entry.ts +6 -1
  8. package/dist/boilerplates/@batijs/firebase-auth/files/$package.json.js +1 -1
  9. package/dist/boilerplates/@batijs/h3/files/$package.json.js +3 -3
  10. package/dist/boilerplates/@batijs/h3/files/h3-entry.ts +6 -1
  11. package/dist/boilerplates/@batijs/hattip/files/$package.json.js +6 -6
  12. package/dist/boilerplates/@batijs/hattip/files/hattip-entry.ts +6 -1
  13. package/dist/boilerplates/@batijs/hono/files/$package.json.js +3 -3
  14. package/dist/boilerplates/@batijs/hono/files/hono-entry.ts +6 -1
  15. package/dist/boilerplates/@batijs/prisma/files/$package.json.js +2 -2
  16. package/dist/boilerplates/@batijs/react/files/$package.json.js +8 -6
  17. package/dist/boilerplates/@batijs/react/files/layouts/LayoutDefault.tsx +30 -4
  18. package/dist/boilerplates/@batijs/react/files/pages/index/+Page.tsx +2 -0
  19. package/dist/boilerplates/@batijs/react/files/pages/index/Counter.tsx +12 -0
  20. package/dist/boilerplates/@batijs/react/files/pages/todo/TodoList.tsx +3 -0
  21. package/dist/boilerplates/@batijs/shared/files/package.json +1 -1
  22. package/dist/boilerplates/@batijs/solid/files/$package.json.js +3 -2
  23. package/dist/boilerplates/@batijs/solid/files/pages/todo/TodoList.tsx +3 -0
  24. package/dist/boilerplates/@batijs/tailwindcss/files/$package.json.js +1 -1
  25. package/dist/boilerplates/@batijs/telefunc/files/$package.json.js +1 -1
  26. package/dist/boilerplates/@batijs/ts-rest/files/$package.json.js +100 -0
  27. package/dist/boilerplates/@batijs/ts-rest/files/server/ts-rest-handler.ts +46 -0
  28. package/dist/boilerplates/@batijs/ts-rest/files/ts-rest/client.ts +13 -0
  29. package/dist/boilerplates/@batijs/ts-rest/files/ts-rest/contract.ts +34 -0
  30. package/dist/boilerplates/@batijs/ts-rest/types/server/ts-rest-handler.d.ts +1 -0
  31. package/dist/boilerplates/@batijs/ts-rest/types/ts-rest/client.d.ts +43 -0
  32. package/dist/boilerplates/@batijs/ts-rest/types/ts-rest/contract.d.ts +31 -0
  33. package/dist/boilerplates/@batijs/vercel/files/$package.json.js +1 -1
  34. package/dist/boilerplates/@batijs/vue/files/$package.json.js +3 -2
  35. package/dist/boilerplates/@batijs/vue/files/pages/todo/TodoList.vue +4 -1
  36. package/dist/boilerplates/@batijs/vue/types/pages/+config.d.ts +1 -1
  37. package/dist/boilerplates/boilerplates.json +11 -0
  38. package/dist/index.js +1 -1
  39. package/package.json +5 -5
@@ -5,7 +5,8 @@ async function getViteConfig(props) {
5
5
  addVitePlugin(mod, {
6
6
  from: "vite-plugin-compiled-react",
7
7
  constructor: "compiled",
8
- imported: "compiled"
8
+ imported: "compiled",
9
+ options: { extract: true }
9
10
  });
10
11
  return mod.generate().code;
11
12
  }
@@ -43,7 +43,7 @@ var require_package = __commonJS({
43
43
  devDependencies: {
44
44
  "@batijs/compile": "workspace:*",
45
45
  "@edgedb/generate": "^0.5.3",
46
- "@prisma/client": "^5.15.0",
46
+ "@prisma/client": "^5.15.1",
47
47
  "@types/node": "^18.19.14",
48
48
  colorette: "^2.0.20",
49
49
  edgedb: "^1.5.7"
@@ -42,8 +42,8 @@ var require_package = __commonJS({
42
42
  },
43
43
  devDependencies: {
44
44
  "@batijs/compile": "workspace:^",
45
- "@typescript-eslint/eslint-plugin": "^7.13.0",
46
- "@typescript-eslint/parser": "^7.13.0",
45
+ "@typescript-eslint/eslint-plugin": "^7.13.1",
46
+ "@typescript-eslint/parser": "^7.13.1",
47
47
  eslint: "^8.57.0"
48
48
  },
49
49
  dependencies: {
@@ -44,12 +44,12 @@ var require_package = __commonJS({
44
44
  "@auth/core": "^0.32.0",
45
45
  "@batijs/authjs": "workspace:*",
46
46
  "@batijs/compile": "workspace:*",
47
- "@batijs/drizzle": "workspace:*",
48
47
  "@batijs/firebase-auth": "workspace:*",
49
48
  "@batijs/shared-server": "workspace:^",
50
49
  "@batijs/shared-todo": "workspace:^",
51
50
  "@batijs/telefunc": "workspace:*",
52
51
  "@batijs/trpc": "workspace:*",
52
+ "@batijs/ts-rest": "workspace:*",
53
53
  "@trpc/server": "^10.45.2",
54
54
  "@types/cookie-parser": "^1.4.7",
55
55
  "@types/express": "^4.17.21",
@@ -61,7 +61,7 @@ var require_package = __commonJS({
61
61
  "express-openid-connect": "^2.17.1",
62
62
  telefunc: "^0.1.74",
63
63
  tsx: "^4.15.6",
64
- vike: "^0.4.176",
64
+ vike: "^0.4.177",
65
65
  vite: "^5.3.1"
66
66
  },
67
67
  dependencies: {
@@ -12,6 +12,7 @@ import { vikeHandler } from "@batijs/shared-server/server/vike-handler";
12
12
  import { createTodoHandler } from "@batijs/shared-todo/server/create-todo-handler";
13
13
  import { telefuncHandler } from "@batijs/telefunc/server/telefunc-handler";
14
14
  import { appRouter } from "@batijs/trpc/trpc/server";
15
+ import { tsRestHandler } from "@batijs/ts-rest/server/ts-rest-handler";
15
16
  import * as trpcExpress from "@trpc/server/adapters/express";
16
17
  import { createMiddleware } from "@universal-middleware/express";
17
18
  import express from "express";
@@ -117,7 +118,11 @@ async function startServer() {
117
118
  app.post("/_telefunc", handlerAdapter(telefuncHandler));
118
119
  }
119
120
 
120
- if (!BATI.has("telefunc") && !BATI.has("trpc")) {
121
+ if (BATI.has("ts-rest")) {
122
+ app.all("/api/*", handlerAdapter(tsRestHandler));
123
+ }
124
+
125
+ if (!BATI.has("telefunc") && !BATI.has("trpc") && !BATI.has("ts-rest")) {
121
126
  app.post("/api/todo/create", handlerAdapter(createTodoHandler));
122
127
  }
123
128
 
@@ -44,12 +44,12 @@ var require_package = __commonJS({
44
44
  "@auth/core": "^0.32.0",
45
45
  "@batijs/authjs": "workspace:*",
46
46
  "@batijs/compile": "workspace:*",
47
- "@batijs/drizzle": "workspace:*",
48
47
  "@batijs/firebase-auth": "workspace:*",
49
48
  "@batijs/shared-server": "workspace:^",
50
49
  "@batijs/shared-todo": "workspace:^",
51
50
  "@batijs/telefunc": "workspace:^",
52
51
  "@batijs/trpc": "workspace:^",
52
+ "@batijs/ts-rest": "workspace:*",
53
53
  "@fastify/middie": "^8.3.1",
54
54
  "@fastify/static": "^7.0.4",
55
55
  "@trpc/server": "^10.45.2",
@@ -60,7 +60,7 @@ var require_package = __commonJS({
60
60
  fastify: "^4.28.0",
61
61
  telefunc: "^0.1.74",
62
62
  tsx: "^4.15.6",
63
- vike: "^0.4.176",
63
+ vike: "^0.4.177",
64
64
  vite: "^5.3.1"
65
65
  },
66
66
  dependencies: {
@@ -12,6 +12,7 @@ import { vikeHandler } from "@batijs/shared-server/server/vike-handler";
12
12
  import { createTodoHandler } from "@batijs/shared-todo/server/create-todo-handler";
13
13
  import { telefuncHandler } from "@batijs/telefunc/server/telefunc-handler";
14
14
  import { appRouter, type AppRouter } from "@batijs/trpc/trpc/server";
15
+ import { tsRestHandler } from "@batijs/ts-rest/server/ts-rest-handler";
15
16
  import {
16
17
  fastifyTRPCPlugin,
17
18
  type CreateFastifyContextOptions,
@@ -143,7 +144,11 @@ async function startServer() {
143
144
  app.post<{ Body: string }>("/_telefunc", handlerAdapter(telefuncHandler));
144
145
  }
145
146
 
146
- if (!BATI.has("telefunc") && !BATI.has("trpc")) {
147
+ if (BATI.has("ts-rest")) {
148
+ app.all("/api/*", handlerAdapter(tsRestHandler));
149
+ }
150
+
151
+ if (!BATI.has("telefunc") && !BATI.has("trpc") && !BATI.has("ts-rest")) {
147
152
  app.post("/api/todo/create", handlerAdapter(createTodoHandler));
148
153
  }
149
154
 
@@ -49,7 +49,7 @@ var require_package = __commonJS({
49
49
  firebase: "^10.12.2",
50
50
  "firebase-admin": "^12.1.1",
51
51
  firebaseui: "^6.1.0",
52
- vike: "^0.4.176",
52
+ vike: "^0.4.177",
53
53
  vite: "^5.3.1"
54
54
  },
55
55
  dependencies: {
@@ -44,13 +44,13 @@ var require_package = __commonJS({
44
44
  "@auth/core": "^0.32.0",
45
45
  "@batijs/authjs": "workspace:*",
46
46
  "@batijs/compile": "workspace:*",
47
- "@batijs/drizzle": "workspace:*",
48
47
  "@batijs/firebase-auth": "workspace:*",
49
48
  "@batijs/shared-server": "workspace:^",
50
49
  "@batijs/shared-todo": "workspace:^",
51
50
  "@batijs/telefunc": "workspace:^",
52
51
  "@batijs/trpc": "workspace:^",
53
- "@hattip/polyfills": "^0.0.45",
52
+ "@batijs/ts-rest": "workspace:*",
53
+ "@hattip/polyfills": "^0.0.46",
54
54
  "@trpc/server": "^10.45.2",
55
55
  "@types/express": "^4.17.21",
56
56
  "@types/node": "^18.19.14",
@@ -60,7 +60,7 @@ var require_package = __commonJS({
60
60
  "serve-static": "^1.15.0",
61
61
  telefunc: "^0.1.74",
62
62
  tsx: "^4.15.6",
63
- vike: "^0.4.176",
63
+ vike: "^0.4.177",
64
64
  vite: "^5.3.1"
65
65
  },
66
66
  dependencies: {
@@ -13,6 +13,7 @@ import { vikeHandler } from "@batijs/shared-server/server/vike-handler";
13
13
  import { createTodoHandler } from "@batijs/shared-todo/server/create-todo-handler";
14
14
  import { telefuncHandler } from "@batijs/telefunc/server/telefunc-handler";
15
15
  import { appRouter } from "@batijs/trpc/trpc/server";
16
+ import { tsRestHandler } from "@batijs/ts-rest/server/ts-rest-handler";
16
17
  import installCrypto from "@hattip/polyfills/crypto";
17
18
  import installGetSetCookie from "@hattip/polyfills/get-set-cookie";
18
19
  import installWhatwgNodeFetch from "@hattip/polyfills/whatwg-node";
@@ -126,7 +127,11 @@ async function startServer() {
126
127
  router.post("/_telefunc", fromWebHandler(telefuncHandler));
127
128
  }
128
129
 
129
- if (!BATI.has("telefunc") && !BATI.has("trpc")) {
130
+ if (BATI.has("ts-rest")) {
131
+ router.use("/api/**", fromWebHandler(tsRestHandler));
132
+ }
133
+
134
+ if (!BATI.has("telefunc") && !BATI.has("trpc") && !BATI.has("ts-rest")) {
130
135
  router.post("/api/todo/create", fromWebHandler(createTodoHandler));
131
136
  }
132
137
 
@@ -44,22 +44,22 @@ var require_package = __commonJS({
44
44
  "@auth/core": "^0.32.0",
45
45
  "@batijs/authjs": "workspace:*",
46
46
  "@batijs/compile": "workspace:*",
47
- "@batijs/drizzle": "workspace:*",
48
47
  "@batijs/firebase-auth": "workspace:*",
49
48
  "@batijs/shared-server": "workspace:^",
50
49
  "@batijs/shared-todo": "workspace:^",
51
50
  "@batijs/telefunc": "workspace:^",
52
51
  "@batijs/trpc": "workspace:^",
53
- "@hattip/adapter-node": "^0.0.45",
54
- "@hattip/core": "^0.0.45",
55
- "@hattip/router": "^0.0.45",
56
- "@hattip/vite": "^0.0.45",
52
+ "@batijs/ts-rest": "workspace:*",
53
+ "@hattip/adapter-node": "^0.0.46",
54
+ "@hattip/core": "^0.0.46",
55
+ "@hattip/router": "^0.0.46",
56
+ "@hattip/vite": "^0.0.46",
57
57
  "@trpc/server": "^10.45.2",
58
58
  "@types/node": "^18.19.14",
59
59
  dotenv: "^16.4.5",
60
60
  hattip: "^0.0.33",
61
61
  telefunc: "^0.1.74",
62
- vike: "^0.4.176",
62
+ vike: "^0.4.177",
63
63
  vite: "^5.3.1"
64
64
  },
65
65
  dependencies: {
@@ -10,6 +10,7 @@ import { vikeHandler } from "@batijs/shared-server/server/vike-handler";
10
10
  import { createTodoHandler } from "@batijs/shared-todo/server/create-todo-handler";
11
11
  import { telefuncHandler } from "@batijs/telefunc/server/telefunc-handler";
12
12
  import { appRouter } from "@batijs/trpc/trpc/server";
13
+ import { tsRestHandler } from "@batijs/ts-rest/server/ts-rest-handler";
13
14
  import type { HattipHandler } from "@hattip/core";
14
15
  import { createRouter, type RouteHandler } from "@hattip/router";
15
16
  import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
@@ -57,6 +58,10 @@ if (BATI.has("trpc")) {
57
58
  });
58
59
  }
59
60
 
61
+ if (BATI.has("ts-rest")) {
62
+ router.use("/api/*", handlerAdapter(tsRestHandler));
63
+ }
64
+
60
65
  if (BATI.has("authjs") || BATI.has("auth0")) {
61
66
  /**
62
67
  * Append Auth.js session to context
@@ -76,7 +81,7 @@ if (BATI.has("firebase-auth")) {
76
81
  router.post("/api/sessionLogout", handlerAdapter(firebaseAuthLogoutHandler));
77
82
  }
78
83
 
79
- if (!BATI.has("telefunc") && !BATI.has("trpc")) {
84
+ if (!BATI.has("telefunc") && !BATI.has("trpc") && !BATI.has("ts-rest")) {
80
85
  router.post("/api/todo/create", handlerAdapter(createTodoHandler));
81
86
  }
82
87
 
@@ -44,21 +44,21 @@ var require_package = __commonJS({
44
44
  "@auth/core": "^0.32.0",
45
45
  "@batijs/authjs": "workspace:*",
46
46
  "@batijs/compile": "workspace:*",
47
- "@batijs/drizzle": "workspace:*",
48
47
  "@batijs/firebase-auth": "workspace:*",
49
48
  "@batijs/shared-server": "workspace:^",
50
49
  "@batijs/shared-todo": "workspace:^",
51
50
  "@batijs/telefunc": "workspace:^",
52
51
  "@batijs/trpc": "workspace:^",
52
+ "@batijs/ts-rest": "workspace:*",
53
53
  "@hono/node-server": "^1.11.3",
54
54
  "@hono/vite-dev-server": "^0.12.2",
55
55
  "@trpc/server": "^10.45.2",
56
56
  "@types/node": "^18.19.14",
57
57
  dotenv: "^16.4.5",
58
- hono: "^4.4.6",
58
+ hono: "^4.4.7",
59
59
  telefunc: "^0.1.74",
60
60
  tsx: "^4.15.6",
61
- vike: "^0.4.176",
61
+ vike: "^0.4.177",
62
62
  vite: "^5.3.1"
63
63
  },
64
64
  dependencies: {
@@ -10,6 +10,7 @@ import { vikeHandler } from "@batijs/shared-server/server/vike-handler";
10
10
  import { createTodoHandler } from "@batijs/shared-todo/server/create-todo-handler";
11
11
  import { telefuncHandler } from "@batijs/telefunc/server/telefunc-handler";
12
12
  import { appRouter } from "@batijs/trpc/trpc/server";
13
+ import { tsRestHandler } from "@batijs/ts-rest/server/ts-rest-handler";
13
14
  import { serve } from "@hono/node-server";
14
15
  import { serveStatic } from "@hono/node-server/serve-static";
15
16
  import { fetchRequestHandler, type FetchCreateContextFnOptions } from "@trpc/server/adapters/fetch";
@@ -104,7 +105,11 @@ if (BATI.has("telefunc")) {
104
105
  app.post("/_telefunc", handlerAdapter(telefuncHandler));
105
106
  }
106
107
 
107
- if (!BATI.has("telefunc") && !BATI.has("trpc")) {
108
+ if (BATI.has("ts-rest")) {
109
+ app.all("/api/*", handlerAdapter(tsRestHandler));
110
+ }
111
+
112
+ if (!BATI.has("telefunc") && !BATI.has("trpc") && !BATI.has("ts-rest")) {
108
113
  app.post("/api/todo/create", handlerAdapter(createTodoHandler));
109
114
  }
110
115
 
@@ -42,10 +42,10 @@ var require_package = __commonJS({
42
42
  license: "MIT",
43
43
  devDependencies: {
44
44
  "@batijs/compile": "workspace:*",
45
- "@prisma/client": "^5.15.0",
45
+ "@prisma/client": "^5.15.1",
46
46
  "@types/node": "^18.19.14",
47
47
  colorette: "^2.0.20",
48
- prisma: "^5.15.0"
48
+ prisma: "^5.15.1"
49
49
  },
50
50
  dependencies: {
51
51
  "@batijs/core": "workspace:*"
@@ -41,27 +41,29 @@ var require_package = __commonJS({
41
41
  author: "",
42
42
  license: "MIT",
43
43
  devDependencies: {
44
+ "@babel/core": "^7.24.7",
45
+ "@babel/plugin-syntax-flow": "^7.24.7",
46
+ "@babel/plugin-transform-react-jsx": "^7.24.7",
44
47
  "@batijs/compile": "workspace:^",
45
48
  "@batijs/drizzle": "workspace:^",
46
49
  "@batijs/shared-todo": "workspace:^",
47
50
  "@batijs/telefunc": "workspace:^",
48
51
  "@batijs/trpc": "workspace:^",
49
- "@babel/core": "^7.24.7",
50
- "@babel/plugin-syntax-flow": "^7.24.7",
51
- "@babel/plugin-transform-react-jsx": "^7.24.7",
52
+ "@batijs/ts-rest": "workspace:*",
52
53
  "@types/node": "^18.19.14",
53
54
  "@types/react": "^18.3.3",
54
55
  "@types/react-dom": "^18.3.0",
55
56
  "@vitejs/plugin-react": "^4.3.1",
56
57
  "cross-fetch": "^4.0.0",
57
- "eslint-plugin-react": "^7.34.2",
58
+ "eslint-plugin-react": "^7.34.3",
58
59
  react: "^18.3.1",
59
60
  "react-dom": "^18.3.1",
60
61
  tailwindcss: "^3.4.4",
61
62
  typescript: "^5.4.5",
62
- vike: "^0.4.176",
63
+ vike: "^0.4.177",
63
64
  "vike-react": "^0.4.14",
64
- vite: "^5.3.1"
65
+ vite: "^5.3.1",
66
+ "vite-plugin-compiled-react": "^1.1.3"
65
67
  },
66
68
  dependencies: {
67
69
  "@batijs/core": "workspace:*"
@@ -10,7 +10,13 @@ export default function LayoutDefault({ children }: { children: React.ReactNode
10
10
  <div
11
11
  //# BATI.has("tailwindcss")
12
12
  className="flex max-w-5xl m-auto"
13
- //# !BATI.has("tailwindcss")
13
+ //# BATI.has("compiled-css")
14
+ css={{
15
+ display: "flex",
16
+ maxWidth: 1024,
17
+ margin: "auto",
18
+ }}
19
+ //# !BATI.has("tailwindcss") && !BATI.has("compiled-css")
14
20
  style={{
15
21
  display: "flex",
16
22
  maxWidth: 900,
@@ -34,7 +40,16 @@ function Sidebar({ children }: { children: React.ReactNode }) {
34
40
  id="sidebar"
35
41
  //# BATI.has("tailwindcss")
36
42
  className="p-5 flex flex-col shrink-0 border-r-2 border-r-gray-200"
37
- //# !BATI.has("tailwindcss")
43
+ //# BATI.has("compiled-css")
44
+ css={{
45
+ padding: 20,
46
+ display: "flex",
47
+ flexShrink: 0,
48
+ flexDirection: "column",
49
+ lineHeight: "1.8em",
50
+ borderRight: "2px solid #eee",
51
+ }}
52
+ //# !BATI.has("tailwindcss") && !BATI.has("compiled-css")
38
53
  style={{
39
54
  padding: 20,
40
55
  flexShrink: 0,
@@ -56,7 +71,13 @@ function Content({ children }: { children: React.ReactNode }) {
56
71
  id="page-content"
57
72
  //# BATI.has("tailwindcss")
58
73
  className="p-5 pb-12 min-h-screen"
59
- //# !BATI.has("tailwindcss")
74
+ //# BATI.has("compiled-css")
75
+ css={{
76
+ padding: 20,
77
+ paddingBottom: 48,
78
+ minHeight: "100vh",
79
+ }}
80
+ //# !BATI.has("tailwindcss") && !BATI.has("compiled-css")
60
81
  style={{
61
82
  padding: 20,
62
83
  paddingBottom: 50,
@@ -74,7 +95,12 @@ function Logo() {
74
95
  <div
75
96
  //# BATI.has("tailwindcss")
76
97
  className="p-5 mb-2"
77
- //# !BATI.has("tailwindcss")
98
+ //# BATI.has("compiled-css")
99
+ css={{
100
+ padding: 20,
101
+ marginBottom: 8,
102
+ }}
103
+ //# !BATI.has("tailwindcss") && !BATI.has("compiled-css")
78
104
  style={{
79
105
  marginTop: 20,
80
106
  marginBottom: 10,
@@ -7,6 +7,8 @@ export default function Page() {
7
7
  <h1
8
8
  //# BATI.has("tailwindcss")
9
9
  className="font-bold text-3xl pb-4"
10
+ //# BATI.has("compiled-css")
11
+ css={{ fontWeight: "700", fontSize: "1.875rem", paddingBottom: "1rem" }}
10
12
  >
11
13
  My Vike app
12
14
  </h1>
@@ -8,6 +8,18 @@ export function Counter() {
8
8
  type="button"
9
9
  //# BATI.has("tailwindcss")
10
10
  className="inline-block border border-black rounded bg-gray-200 px-2 py-1 text-xs font-medium uppercase leading-normal"
11
+ //# BATI.has("compiled-css")
12
+ css={{
13
+ display: "inline-block",
14
+ border: "1px solid black",
15
+ borderRadius: "0.25rem",
16
+ backgroundColor: "#e5e7eb",
17
+ padding: "4px 8px 4px 8px",
18
+ fontSize: "0.75rem",
19
+ fontWeight: "500",
20
+ textTransform: "uppercase",
21
+ lineHeight: "1.5",
22
+ }}
11
23
  onClick={() => setCount((count) => count + 1)}
12
24
  >
13
25
  Counter {count}
@@ -1,5 +1,6 @@
1
1
  import { onNewTodo } from "@batijs/telefunc/pages/todo/TodoList.telefunc";
2
2
  import { trpc } from "@batijs/trpc/trpc/client";
3
+ import { client } from "@batijs/ts-rest/ts-rest/client";
3
4
  import React, { useState } from "react";
4
5
 
5
6
  export function TodoList({ initialTodoItems }: { initialTodoItems: { text: string }[] }) {
@@ -24,6 +25,8 @@ export function TodoList({ initialTodoItems }: { initialTodoItems: { text: strin
24
25
  await onNewTodo({ text: newTodo });
25
26
  } else if (BATI.has("trpc")) {
26
27
  await trpc.onNewTodo.mutate(newTodo);
28
+ } else if (BATI.has("ts-rest")) {
29
+ await client.createTodo({ body: { text: newTodo } });
27
30
  } else {
28
31
  const response = await fetch("/api/todo/create", {
29
32
  method: "POST",
@@ -13,7 +13,7 @@
13
13
  "devDependencies": {
14
14
  "@auth/core": "^0.32.0",
15
15
  "typescript": "^5.4.5",
16
- "vike": "^0.4.176",
16
+ "vike": "^0.4.177",
17
17
  "vite": "^5.3.1"
18
18
  },
19
19
  "dependencies": {}
@@ -46,14 +46,15 @@ var require_package = __commonJS({
46
46
  "@batijs/shared-todo": "workspace:*",
47
47
  "@batijs/telefunc": "workspace:*",
48
48
  "@batijs/trpc": "workspace:^",
49
+ "@batijs/ts-rest": "workspace:*",
49
50
  "@types/node": "^18.19.14",
50
51
  "cross-fetch": "^4.0.0",
51
52
  "eslint-plugin-solid": "^0.14.0",
52
53
  "solid-js": "^1.8.17",
53
54
  tailwindcss: "^3.4.4",
54
55
  typescript: "^5.4.5",
55
- vike: "^0.4.176",
56
- "vike-solid": "^0.4.5",
56
+ vike: "^0.4.177",
57
+ "vike-solid": "^0.6.0",
57
58
  vite: "^5.3.1",
58
59
  "vite-plugin-solid": "^2.10.2"
59
60
  },
@@ -1,5 +1,6 @@
1
1
  import { onNewTodo } from "@batijs/telefunc/pages/todo/TodoList.telefunc";
2
2
  import { trpc } from "@batijs/trpc/trpc/client";
3
+ import { client } from "@batijs/ts-rest/ts-rest/client";
3
4
  import { createSignal, For, untrack } from "solid-js";
4
5
 
5
6
  export function TodoList(props: { initialTodoItems: { text: string }[] }) {
@@ -22,6 +23,8 @@ export function TodoList(props: { initialTodoItems: { text: string }[] }) {
22
23
  await onNewTodo({ text: untrack(newTodo) });
23
24
  } else if (BATI.has("trpc")) {
24
25
  await trpc.onNewTodo.mutate(untrack(newTodo));
26
+ } else if (BATI.has("ts-rest")) {
27
+ await client.createTodo({ body: { text: untrack(newTodo) } });
25
28
  } else {
26
29
  const response = await fetch("/api/todo/create", {
27
30
  method: "POST",
@@ -47,7 +47,7 @@ var require_package = __commonJS({
47
47
  daisyui: "^4.12.2",
48
48
  postcss: "^8.4.38",
49
49
  tailwindcss: "^3.4.4",
50
- vike: "^0.4.176",
50
+ vike: "^0.4.177",
51
51
  vite: "^5.3.1"
52
52
  },
53
53
  dependencies: {
@@ -47,7 +47,7 @@ var require_package = __commonJS({
47
47
  "@batijs/shared-todo": "workspace:*",
48
48
  "@types/node": "^18.19.14",
49
49
  telefunc: "^0.1.74",
50
- vike: "^0.4.176",
50
+ vike: "^0.4.177",
51
51
  vite: "^5.3.1"
52
52
  },
53
53
  dependencies: {
@@ -0,0 +1,100 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // package.json
28
+ var require_package = __commonJS({
29
+ "package.json"(exports, module) {
30
+ module.exports = {
31
+ name: "@batijs/ts-rest",
32
+ private: true,
33
+ version: "0.0.1",
34
+ description: "",
35
+ type: "module",
36
+ scripts: {
37
+ "check-types": "tsc --noEmit",
38
+ build: "bati-compile-boilerplate"
39
+ },
40
+ keywords: [],
41
+ author: "",
42
+ license: "MIT",
43
+ devDependencies: {
44
+ "@batijs/compile": "workspace:*",
45
+ "@batijs/drizzle": "workspace:*",
46
+ "@batijs/shared-no-db": "workspace:*",
47
+ "@ts-rest/core": "^3.45.2",
48
+ "@ts-rest/serverless": "^3.45.2",
49
+ "@types/node": "^18.19.14"
50
+ },
51
+ dependencies: {
52
+ "@batijs/core": "workspace:*"
53
+ },
54
+ files: [
55
+ "dist/"
56
+ ],
57
+ bati: {
58
+ if: {
59
+ flag: "ts-rest"
60
+ }
61
+ },
62
+ exports: {
63
+ "./ts-rest/contract": {
64
+ types: "./dist/types/ts-rest/contract.d.ts"
65
+ },
66
+ "./server/ts-rest-handler": {
67
+ types: "./dist/types/server/ts-rest-handler.d.ts"
68
+ },
69
+ "./ts-rest/client": {
70
+ types: "./dist/types/ts-rest/client.d.ts"
71
+ }
72
+ },
73
+ typesVersions: {
74
+ "*": {
75
+ "ts-rest/contract": [
76
+ "./dist/types/ts-rest/contract.d.ts"
77
+ ],
78
+ "server/ts-rest-handler": [
79
+ "./dist/types/server/ts-rest-handler.d.ts"
80
+ ],
81
+ "ts-rest/client": [
82
+ "./dist/types/ts-rest/client.d.ts"
83
+ ]
84
+ }
85
+ }
86
+ };
87
+ }
88
+ });
89
+
90
+ // files/$package.json.ts
91
+ import { addDependency, loadAsJson } from "@batijs/core";
92
+ async function getPackageJson(props) {
93
+ const packageJson = await loadAsJson(props);
94
+ return addDependency(packageJson, await Promise.resolve().then(() => __toESM(require_package(), 1)).then((x) => x.default), {
95
+ dependencies: ["@ts-rest/core", "@ts-rest/serverless"]
96
+ });
97
+ }
98
+ export {
99
+ getPackageJson as default
100
+ };
@@ -0,0 +1,46 @@
1
+ import { db } from "@batijs/drizzle/database/db";
2
+ import { todoTable } from "@batijs/drizzle/database/schema";
3
+ import { lowDb } from "@batijs/shared-no-db/database/todoItems";
4
+ import { fetchRequestHandler, tsr } from "@ts-rest/serverless/fetch";
5
+ import { contract } from "../ts-rest/contract";
6
+
7
+ /**
8
+ * ts-rest route
9
+ *
10
+ * @link {@see https://ts-rest.com/docs/serverless/fetch-runtimes/}
11
+ **/
12
+ const router = tsr.router(contract, {
13
+ demo: async () => {
14
+ return {
15
+ status: 200,
16
+ body: {
17
+ demo: true,
18
+ },
19
+ };
20
+ },
21
+ createTodo: async ({ body }) => {
22
+ if (BATI.has("drizzle")) {
23
+ await db.insert(todoTable).values({ text: body.text });
24
+ } else {
25
+ lowDb.update(({ todo }) => todo.push({ text: body.text }));
26
+ }
27
+ return {
28
+ status: 200,
29
+ body: {
30
+ status: "Ok",
31
+ },
32
+ };
33
+ },
34
+ });
35
+
36
+ export async function tsRestHandler<Context extends Record<string | number | symbol, unknown>>(
37
+ request: Request,
38
+ _context?: Context,
39
+ ): Promise<Response> {
40
+ return fetchRequestHandler({
41
+ request: new Request(request.url, request),
42
+ contract,
43
+ router,
44
+ options: {},
45
+ });
46
+ }
@@ -0,0 +1,13 @@
1
+ import { initClient } from "@ts-rest/core";
2
+ import { contract } from "./contract";
3
+
4
+ /**
5
+ * ts-rest client
6
+ *
7
+ * This is the basic client, using fetch under the hood which is exported from @ts-rest/core
8
+ * @link {@see https://ts-rest.com/docs/core/fetch/}
9
+ **/
10
+ export const client = initClient(contract, {
11
+ baseUrl: "",
12
+ baseHeaders: {},
13
+ });
@@ -0,0 +1,34 @@
1
+ import { initContract } from "@ts-rest/core";
2
+
3
+ const c = initContract();
4
+
5
+ /**
6
+ * ts-rest contract
7
+ *
8
+ * Create a contract, this should ideally be shared between your consumers and producers
9
+ * Think of this as your HTTP Schema that both your client and backend can use.
10
+ * @link {@see https://ts-rest.com/docs/core/}
11
+ **/
12
+ export const contract = c.router(
13
+ {
14
+ demo: {
15
+ method: "GET",
16
+ path: "/demo",
17
+ responses: {
18
+ 200: c.type<{ demo: boolean }>(),
19
+ },
20
+ },
21
+ createTodo: {
22
+ method: "POST",
23
+ path: "/todo/create",
24
+ body: c.type<{ text: string }>(),
25
+ responses: {
26
+ 200: c.type<{ status: string }>(),
27
+ },
28
+ summary: "Create a Todo",
29
+ },
30
+ },
31
+ {
32
+ pathPrefix: "/api",
33
+ },
34
+ );
@@ -0,0 +1 @@
1
+ export declare function tsRestHandler<Context extends Record<string | number | symbol, unknown>>(request: Request, _context?: Context): Promise<Response>;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * ts-rest client
3
+ *
4
+ * This is the basic client, using fetch under the hood which is exported from @ts-rest/core
5
+ * @link {@see https://ts-rest.com/docs/core/fetch/}
6
+ **/
7
+ export declare const client: {
8
+ demo: (args?: {
9
+ cache?: RequestCache;
10
+ fetchOptions?: import("@ts-rest/core").FetchOptions;
11
+ extraHeaders?: Record<string, string>;
12
+ overrideClientOptions?: Partial<import("@ts-rest/core").OverrideableClientArgs>;
13
+ }) => Promise<{
14
+ status: 200;
15
+ body: {
16
+ demo: boolean;
17
+ };
18
+ headers: Headers;
19
+ } | {
20
+ status: 100 | 101 | 102 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
21
+ body: unknown;
22
+ headers: Headers;
23
+ }>;
24
+ createTodo: (args?: {
25
+ cache?: RequestCache;
26
+ body?: {
27
+ text: string;
28
+ };
29
+ fetchOptions?: import("@ts-rest/core").FetchOptions;
30
+ extraHeaders?: Record<string, string>;
31
+ overrideClientOptions?: Partial<import("@ts-rest/core").OverrideableClientArgs>;
32
+ }) => Promise<{
33
+ status: 200;
34
+ body: {
35
+ status: string;
36
+ };
37
+ headers: Headers;
38
+ } | {
39
+ status: 100 | 101 | 102 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
40
+ body: unknown;
41
+ headers: Headers;
42
+ }>;
43
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * ts-rest contract
3
+ *
4
+ * Create a contract, this should ideally be shared between your consumers and producers
5
+ * Think of this as your HTTP Schema that both your client and backend can use.
6
+ * @link {@see https://ts-rest.com/docs/core/}
7
+ **/
8
+ export declare const contract: {
9
+ demo: {
10
+ method: "GET";
11
+ path: "/api/demo";
12
+ responses: {
13
+ 200: import("@ts-rest/core").ContractPlainType<{
14
+ demo: boolean;
15
+ }>;
16
+ };
17
+ };
18
+ createTodo: {
19
+ summary: "Create a Todo";
20
+ method: "POST";
21
+ body: import("@ts-rest/core").ContractPlainType<{
22
+ text: string;
23
+ }>;
24
+ path: "/api/todo/create";
25
+ responses: {
26
+ 200: import("@ts-rest/core").ContractPlainType<{
27
+ status: string;
28
+ }>;
29
+ };
30
+ };
31
+ };
@@ -44,7 +44,7 @@ var require_package = __commonJS({
44
44
  "@batijs/compile": "workspace:*",
45
45
  "@types/node": "^18.19.14",
46
46
  "@vite-plugin-vercel/vike": "^7.0.0",
47
- vike: "^0.4.176",
47
+ vike: "^0.4.177",
48
48
  vite: "^5.3.1",
49
49
  "vite-plugin-vercel": "^7.0.0"
50
50
  },
@@ -46,6 +46,7 @@ var require_package = __commonJS({
46
46
  "@batijs/shared-todo": "workspace:*",
47
47
  "@batijs/telefunc": "workspace:*",
48
48
  "@batijs/trpc": "workspace:^",
49
+ "@batijs/ts-rest": "workspace:*",
49
50
  "@types/node": "^18.19.14",
50
51
  "@vitejs/plugin-vue": "^5.0.5",
51
52
  "@vue/compiler-sfc": "^3.4.29",
@@ -55,8 +56,8 @@ var require_package = __commonJS({
55
56
  tailwindcss: "^3.4.4",
56
57
  typescript: "^5.4.5",
57
58
  "unplugin-vue-markdown": "^0.26.2",
58
- vike: "^0.4.176",
59
- "vike-vue": "^0.7.3",
59
+ vike: "^0.4.177",
60
+ "vike-vue": "^0.7.5",
60
61
  vite: "^5.3.1",
61
62
  vue: "^3.4.29",
62
63
  "vue-gtag": "^2.0.1"
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <ul>
3
- <li v-for="item in todoItems" :key="item.text">
3
+ <li v-for="(item) in todoItems" :key="item.text">
4
4
  {{ item.text }}
5
5
  </li>
6
6
  <li>
@@ -15,6 +15,7 @@
15
15
  <script lang="ts" setup>
16
16
  import { onNewTodo } from "@batijs/telefunc/pages/todo/TodoList.telefunc";
17
17
  import { trpc } from "@batijs/trpc/trpc/client";
18
+ import { client } from "@batijs/ts-rest/ts-rest/client";
18
19
  import { ref } from "vue";
19
20
 
20
21
  const props = defineProps<{ initialTodoItems: { text: string }[] }>();
@@ -29,6 +30,8 @@ const submitNewTodo = async () => {
29
30
  await onNewTodo({ text: newTodo.value });
30
31
  } else if (BATI.has("trpc")) {
31
32
  await trpc.onNewTodo.mutate(newTodo.value);
33
+ } else if (BATI.has("ts-rest")) {
34
+ await client.createTodo({ body: { text: newTodo.value } });
32
35
  } else {
33
36
  const response = await fetch("/api/todo/create", {
34
37
  method: "POST",
@@ -92,7 +92,7 @@ declare const _default: {
92
92
  config: true;
93
93
  };
94
94
  };
95
- bodyHtmlStart: {
95
+ bodyHtmlBegin: {
96
96
  env: {
97
97
  server: true;
98
98
  client: true;
@@ -343,6 +343,17 @@
343
343
  "files"
344
344
  ]
345
345
  },
346
+ {
347
+ "config": {
348
+ "if": {
349
+ "flag": "ts-rest"
350
+ }
351
+ },
352
+ "folder": "@batijs/ts-rest",
353
+ "subfolders": [
354
+ "files"
355
+ ]
356
+ },
346
357
  {
347
358
  "config": {
348
359
  "if": {
package/dist/index.js CHANGED
@@ -1559,7 +1559,7 @@ var import_which_pm_runs = __toESM(require_which_pm_runs(), 1);
1559
1559
  // package.json
1560
1560
  var package_default = {
1561
1561
  name: "@batijs/cli",
1562
- version: "0.0.202",
1562
+ version: "0.0.204",
1563
1563
  type: "module",
1564
1564
  scripts: {
1565
1565
  "check-types": "tsc --noEmit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@batijs/cli",
3
- "version": "0.0.202",
3
+ "version": "0.0.204",
4
4
  "type": "module",
5
5
  "keywords": [],
6
6
  "description": "Next-gen scaffolder. Get started with fully-functional apps, and choose any tool you want",
@@ -21,12 +21,12 @@
21
21
  "typescript": "^5.4.5",
22
22
  "vite": "^5.3.1",
23
23
  "which-pm-runs": "^1.1.0",
24
- "@batijs/build": "0.0.202",
25
- "@batijs/compile": "0.0.202"
24
+ "@batijs/compile": "0.0.204",
25
+ "@batijs/build": "0.0.204"
26
26
  },
27
27
  "dependencies": {
28
- "@batijs/core": "0.0.202",
29
- "@batijs/features": "0.0.202"
28
+ "@batijs/features": "0.0.204",
29
+ "@batijs/core": "0.0.204"
30
30
  },
31
31
  "bin": "./dist/index.js",
32
32
  "exports": {