@evjs/cli 0.0.1-rc.17 → 0.0.1-rc.27
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/README.md +3 -6
- package/dist/create-webpack-config.js +14 -0
- package/dist/index.js +5 -85
- package/package.json +2 -5
- package/templates/basic-csr/index.html +0 -11
- package/templates/basic-csr/package.json +0 -21
- package/templates/basic-csr/src/main.tsx +0 -22
- package/templates/basic-csr/src/pages/__root.tsx +0 -28
- package/templates/basic-csr/src/pages/about.tsx +0 -19
- package/templates/basic-csr/src/pages/home.tsx +0 -19
- package/templates/basic-csr/src/pages/posts/index.tsx +0 -63
- package/templates/basic-csr/tsconfig.json +0 -17
- package/templates/basic-server-fns/index.html +0 -11
- package/templates/basic-server-fns/package.json +0 -21
- package/templates/basic-server-fns/src/api/users.server.ts +0 -31
- package/templates/basic-server-fns/src/main.tsx +0 -12
- package/templates/basic-server-fns/src/routes.tsx +0 -108
- package/templates/basic-server-fns/tsconfig.json +0 -16
- package/templates/complex-routing/index.html +0 -11
- package/templates/complex-routing/package.json +0 -21
- package/templates/complex-routing/src/api/data.server.ts +0 -86
- package/templates/complex-routing/src/main.tsx +0 -29
- package/templates/complex-routing/src/pages/__root.tsx +0 -60
- package/templates/complex-routing/src/pages/catch.tsx +0 -26
- package/templates/complex-routing/src/pages/dashboard.tsx +0 -81
- package/templates/complex-routing/src/pages/home.tsx +0 -35
- package/templates/complex-routing/src/pages/posts/index.tsx +0 -104
- package/templates/complex-routing/src/pages/search.tsx +0 -71
- package/templates/complex-routing/src/pages/user.tsx +0 -32
- package/templates/complex-routing/tsconfig.json +0 -13
- package/templates/configured-server-fns/ev.config.ts +0 -56
- package/templates/configured-server-fns/index.html +0 -11
- package/templates/configured-server-fns/package.json +0 -21
- package/templates/configured-server-fns/src/api/users.server.ts +0 -22
- package/templates/configured-server-fns/src/main.tsx +0 -12
- package/templates/configured-server-fns/src/routes.tsx +0 -111
- package/templates/configured-server-fns/tsconfig.json +0 -16
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createAppRootRoute,
|
|
3
|
-
createMutationProxy,
|
|
4
|
-
createQueryProxy,
|
|
5
|
-
createRoute,
|
|
6
|
-
Link,
|
|
7
|
-
Outlet,
|
|
8
|
-
useQueryClient,
|
|
9
|
-
} from "@evjs/runtime/client";
|
|
10
|
-
import { useState } from "react";
|
|
11
|
-
import * as usersApi from "./api/users.server";
|
|
12
|
-
|
|
13
|
-
// ── API Proxy ──
|
|
14
|
-
|
|
15
|
-
const api = {
|
|
16
|
-
users: {
|
|
17
|
-
query: createQueryProxy(usersApi),
|
|
18
|
-
mutation: createMutationProxy(usersApi),
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// ── Root Route ──
|
|
23
|
-
|
|
24
|
-
function Root() {
|
|
25
|
-
return (
|
|
26
|
-
<div style={{ fontFamily: "system-ui, sans-serif", padding: "1rem" }}>
|
|
27
|
-
<h1>Configured Server Functions</h1>
|
|
28
|
-
<p style={{ color: "#666" }}>
|
|
29
|
-
This example uses <code>ev.config.ts</code> for custom ports and
|
|
30
|
-
settings.
|
|
31
|
-
</p>
|
|
32
|
-
<nav style={{ display: "flex", gap: "1rem", marginBottom: "1rem" }}>
|
|
33
|
-
<Link to="/">Users</Link>
|
|
34
|
-
</nav>
|
|
35
|
-
<Outlet />
|
|
36
|
-
</div>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const rootRoute = createAppRootRoute({ component: Root });
|
|
41
|
-
|
|
42
|
-
// ── Users Route ──
|
|
43
|
-
|
|
44
|
-
function UsersPage() {
|
|
45
|
-
const [name, setName] = useState("");
|
|
46
|
-
const [email, setEmail] = useState("");
|
|
47
|
-
|
|
48
|
-
const { data: users = [], isLoading } = api.users.query.getUsers.useQuery();
|
|
49
|
-
|
|
50
|
-
const queryClient = useQueryClient();
|
|
51
|
-
const { mutateAsync: doCreateUser } =
|
|
52
|
-
api.users.mutation.createUser.useMutation({
|
|
53
|
-
onSuccess: () => {
|
|
54
|
-
queryClient.invalidateQueries({
|
|
55
|
-
queryKey: api.users.query.getUsers.queryKey(),
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
async function handleCreate(e: { preventDefault: () => void }) {
|
|
61
|
-
e.preventDefault();
|
|
62
|
-
if (!name || !email) return;
|
|
63
|
-
await doCreateUser([{ name, email }]);
|
|
64
|
-
setName("");
|
|
65
|
-
setEmail("");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (isLoading) return <p>Loading users from server…</p>;
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<div>
|
|
72
|
-
<h2>Users (via Query Proxy)</h2>
|
|
73
|
-
<ul>
|
|
74
|
-
{users.map((u: { id: string; name: string; email: string }) => (
|
|
75
|
-
<li key={u.id}>
|
|
76
|
-
{u.name} — {u.email}
|
|
77
|
-
</li>
|
|
78
|
-
))}
|
|
79
|
-
</ul>
|
|
80
|
-
|
|
81
|
-
<h3>Add User</h3>
|
|
82
|
-
<form onSubmit={handleCreate} style={{ display: "flex", gap: "0.5rem" }}>
|
|
83
|
-
<input
|
|
84
|
-
placeholder="Name"
|
|
85
|
-
value={name}
|
|
86
|
-
onChange={(e) => setName(e.target.value)}
|
|
87
|
-
/>
|
|
88
|
-
<input
|
|
89
|
-
placeholder="Email"
|
|
90
|
-
value={email}
|
|
91
|
-
onChange={(e) => setEmail(e.target.value)}
|
|
92
|
-
/>
|
|
93
|
-
<button type="submit">Create</button>
|
|
94
|
-
</form>
|
|
95
|
-
</div>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const usersRoute = createRoute({
|
|
100
|
-
getParentRoute: () => rootRoute,
|
|
101
|
-
path: "/",
|
|
102
|
-
component: UsersPage,
|
|
103
|
-
loader: ({ context }) =>
|
|
104
|
-
context.queryClient.ensureQueryData(
|
|
105
|
-
api.users.query.getUsers.queryOptions(),
|
|
106
|
-
),
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
// ── Route Tree ──
|
|
110
|
-
|
|
111
|
-
export const routeTree = rootRoute.addChildren([usersRoute]);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"include": ["src"],
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "ESNext",
|
|
5
|
-
"jsx": "react-jsx",
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
8
|
-
"moduleResolution": "Bundler",
|
|
9
|
-
"outDir": "./dist",
|
|
10
|
-
"rootDir": "./src",
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"strict": true,
|
|
13
|
-
"noEmit": true,
|
|
14
|
-
"verbatimModuleSyntax": true
|
|
15
|
-
}
|
|
16
|
-
}
|