@batijs/cli 0.0.202 → 0.0.203
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.
- package/dist/boilerplates/@batijs/edgedb/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/eslint/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/express/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/express/files/express-entry.ts +6 -1
- package/dist/boilerplates/@batijs/fastify/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/fastify/files/fastify-entry.ts +6 -1
- package/dist/boilerplates/@batijs/firebase-auth/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/h3/files/$package.json.js +3 -3
- package/dist/boilerplates/@batijs/h3/files/h3-entry.ts +6 -1
- package/dist/boilerplates/@batijs/hattip/files/$package.json.js +6 -6
- package/dist/boilerplates/@batijs/hattip/files/hattip-entry.ts +6 -1
- package/dist/boilerplates/@batijs/hono/files/$package.json.js +3 -3
- package/dist/boilerplates/@batijs/hono/files/hono-entry.ts +6 -1
- package/dist/boilerplates/@batijs/prisma/files/$package.json.js +2 -2
- package/dist/boilerplates/@batijs/react/files/$package.json.js +3 -2
- package/dist/boilerplates/@batijs/react/files/pages/todo/TodoList.tsx +3 -0
- package/dist/boilerplates/@batijs/shared/files/package.json +1 -1
- package/dist/boilerplates/@batijs/solid/files/$package.json.js +3 -2
- package/dist/boilerplates/@batijs/solid/files/pages/todo/TodoList.tsx +3 -0
- package/dist/boilerplates/@batijs/tailwindcss/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/telefunc/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/ts-rest/files/$package.json.js +100 -0
- package/dist/boilerplates/@batijs/ts-rest/files/server/ts-rest-handler.ts +46 -0
- package/dist/boilerplates/@batijs/ts-rest/files/ts-rest/client.ts +13 -0
- package/dist/boilerplates/@batijs/ts-rest/files/ts-rest/contract.ts +34 -0
- package/dist/boilerplates/@batijs/ts-rest/types/server/ts-rest-handler.d.ts +1 -0
- package/dist/boilerplates/@batijs/ts-rest/types/ts-rest/client.d.ts +43 -0
- package/dist/boilerplates/@batijs/ts-rest/types/ts-rest/contract.d.ts +31 -0
- package/dist/boilerplates/@batijs/vercel/files/$package.json.js +1 -1
- package/dist/boilerplates/@batijs/vue/files/$package.json.js +3 -2
- package/dist/boilerplates/@batijs/vue/files/pages/todo/TodoList.vue +4 -1
- package/dist/boilerplates/@batijs/vue/types/pages/+config.d.ts +1 -1
- package/dist/boilerplates/boilerplates.json +11 -0
- package/dist/index.js +1 -1
- package/package.json +5 -5
|
@@ -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.
|
|
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.
|
|
46
|
-
"@typescript-eslint/parser": "^7.13.
|
|
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.
|
|
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 (
|
|
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.
|
|
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 (
|
|
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
|
|
|
@@ -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
|
-
"@
|
|
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.
|
|
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 (
|
|
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
|
-
"@
|
|
54
|
-
"@hattip/
|
|
55
|
-
"@hattip/
|
|
56
|
-
"@hattip/
|
|
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.
|
|
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.
|
|
58
|
+
hono: "^4.4.7",
|
|
59
59
|
telefunc: "^0.1.74",
|
|
60
60
|
tsx: "^4.15.6",
|
|
61
|
-
vike: "^0.4.
|
|
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 (
|
|
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.
|
|
45
|
+
"@prisma/client": "^5.15.1",
|
|
46
46
|
"@types/node": "^18.19.14",
|
|
47
47
|
colorette: "^2.0.20",
|
|
48
|
-
prisma: "^5.15.
|
|
48
|
+
prisma: "^5.15.1"
|
|
49
49
|
},
|
|
50
50
|
dependencies: {
|
|
51
51
|
"@batijs/core": "workspace:*"
|
|
@@ -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
|
"@babel/core": "^7.24.7",
|
|
50
51
|
"@babel/plugin-syntax-flow": "^7.24.7",
|
|
51
52
|
"@babel/plugin-transform-react-jsx": "^7.24.7",
|
|
@@ -54,12 +55,12 @@ var require_package = __commonJS({
|
|
|
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.
|
|
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.
|
|
63
|
+
vike: "^0.4.177",
|
|
63
64
|
"vike-react": "^0.4.14",
|
|
64
65
|
vite: "^5.3.1"
|
|
65
66
|
},
|
|
@@ -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",
|
|
@@ -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.
|
|
56
|
-
"vike-solid": "^0.
|
|
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",
|
|
@@ -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
|
+
};
|
|
@@ -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.
|
|
59
|
-
"vike-vue": "^0.7.
|
|
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",
|
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.
|
|
1562
|
+
version: "0.0.203",
|
|
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.
|
|
3
|
+
"version": "0.0.203",
|
|
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.
|
|
25
|
-
"@batijs/compile": "0.0.
|
|
24
|
+
"@batijs/build": "0.0.203",
|
|
25
|
+
"@batijs/compile": "0.0.203"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@batijs/core": "0.0.
|
|
29
|
-
"@batijs/features": "0.0.
|
|
28
|
+
"@batijs/core": "0.0.203",
|
|
29
|
+
"@batijs/features": "0.0.203"
|
|
30
30
|
},
|
|
31
31
|
"bin": "./dist/index.js",
|
|
32
32
|
"exports": {
|