Skip to content

Commit 62ea5f7

Browse files
committed
update
1 parent 1251527 commit 62ea5f7

File tree

5 files changed

+139
-90
lines changed

5 files changed

+139
-90
lines changed

vix-site/src/data/examples.js

Lines changed: 90 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,24 @@ export const EXAMPLES = {
88
id: "http-ping",
99
title: "HTTP: /api/ping",
1010
desc: "A minimal JSON ping route.",
11-
code: `#include <vix/app/App.hpp>
12-
using vix::App;
11+
code: `#include <vix.hpp>
1312
14-
int main() {
13+
using namespace vix;
14+
15+
int main()
16+
{
1517
App app;
1618
17-
app.get("/api/ping", [](auto& req, auto& res) {
19+
app.get("/api/ping", [](Request &, Response &res)
20+
{
1821
res.json({
1922
"ok", true,
2023
"message", "pong"
2124
});
2225
});
2326
24-
return app.listen(8080);
27+
app.run(8080);
28+
return 0;
2529
}`,
2630
run: `vix run server.cpp`,
2731
out: `http :8080/api/ping
@@ -36,25 +40,29 @@ HTTP/1.1 200 OK
3640
id: "query-params",
3741
title: "HTTP: query params",
3842
desc: "Read query values with defaults.",
39-
code: `#include <vix/app/App.hpp>
43+
code: `#include <vix.hpp>
4044
#include <string>
41-
using vix::App;
4245
43-
int main() {
46+
using namespace vix;
47+
48+
int main()
49+
{
4450
App app;
4551
46-
app.get("/search", [](auto& req, auto& res) {
52+
app.get("/search", [](Request &req, Response &res)
53+
{
4754
const std::string q = req.query_value("q", "");
48-
const std::string pageStr = req.query_value("page", "1");
55+
const std::string page = req.query_value("page", "1");
4956
5057
res.json({
5158
"ok", true,
5259
"q", q,
53-
"page", pageStr
60+
"page", page
5461
});
5562
});
5663
57-
return app.listen(8080);
64+
app.run(8080);
65+
return 0;
5866
}`,
5967
run: `vix run server.cpp`,
6068
out: `http ":8080/search?q=vix&page=2"
@@ -70,33 +78,52 @@ HTTP/1.1 200 OK
7078
id: "middleware-required-header",
7179
title: "Middleware: require header (401 demo)",
7280
desc: "Reject requests unless a required header is present.",
73-
code: `#include <vix/app/App.hpp>
74-
using vix::App;
81+
code: `#include <vix.hpp>
82+
#include <vix/middleware/app/adapter.hpp>
83+
84+
using namespace vix;
7585
76-
int main() {
86+
int main()
87+
{
7788
App app;
7889
79-
// Pseudo middleware (concept)
80-
// In your real code, plug your middleware function in the proper pipeline.
81-
app.use([](auto& req, auto& res, auto next) {
82-
const auto v = req.header("x-demo");
83-
if (!v || v->empty()) {
90+
// ------------------------------------------------------------
91+
// Middleware inline: require header x-demo: 1
92+
// ------------------------------------------------------------
93+
auto require_demo_header =
94+
middleware::HttpMiddleware([](Request &req,
95+
Response &res,
96+
middleware::Next next)
97+
{
98+
const std::string value = req.header("x-demo");
99+
100+
if (value.empty() || value != "1")
101+
{
84102
res.status(401).json({
85-
"ok", false,
86103
"error", "unauthorized",
87104
"hint", "Missing or invalid header",
105+
"ok", false,
88106
"required_header", "x-demo"
89107
});
90-
return;
108+
return; // block request
91109
}
92-
next();
93-
});
94110
95-
app.get("/api/ping", [](auto& req, auto& res) {
96-
res.json({ "ok", true, "message", "pong" });
97-
});
111+
next(); });
98112
99-
return app.listen(8080);
113+
// Attach middleware ONLY to /api/ping
114+
middleware::app::install_exact(
115+
app,
116+
"/api/ping",
117+
middleware::app::adapt(require_demo_header));
118+
119+
// ------------------------------------------------------------
120+
// Route
121+
// ------------------------------------------------------------
122+
app.get("/api/ping", [](Request &, Response &res)
123+
{ res.json({"ok", true, "message", "pong"}); });
124+
125+
app.run(8080);
126+
return 0;
100127
}`,
101128
run: `vix run server.cpp`,
102129
out: `http :8080/api/ping
@@ -114,7 +141,7 @@ HTTP/1.1 200 OK
114141
"ok": true,
115142
"message": "pong"
116143
}`,
117-
note: "This matches your 401 output. Keep the error shape stable: ok/error/hint/required_header.",
144+
note: "Keep the error shape stable: ok/error/hint/required_header. This matches your 401 output.",
118145
},
119146

120147
{
@@ -123,38 +150,49 @@ HTTP/1.1 200 OK
123150
desc: "Structured logs, useful for debugging and CI.",
124151
code: `// Nothing special in code.
125152
// Use the CLI flags to control log format.`,
126-
run: `vix run server.cpp --log-format=json --log-level=debug
127-
128-
or
129-
vix run server.cpp --log-format=json-pretty --log-level=debug --log-color=always`,
153+
run: `vix run server.cpp --log-format=json --log-level=debug`,
130154
out: `{"level":"debug","msg":"server listening","port":8080,"ts":"..."}`,
155+
note: `Alternative (pretty + colored):
156+
vix run server.cpp --log-format=json-pretty --log-level=debug --log-color=always`,
131157
},
132158

133159
{
134160
id: "http-ws-together",
135161
title: "HTTP + WebSocket in one process",
136-
desc: "Serve HTTP routes and WebSocket events from a single Vix app.",
137-
code: `#include <vix/app/App.hpp>
138-
// pseudo: websocket headers depend on your module layout
139-
// #include <vix/ws/WebSocket.hpp>
162+
desc: "Serve HTTP routes and typed WebSocket events from a single runtime.",
163+
code: `#include <vix.hpp>
164+
#include <vix/websocket/AttachedRuntime.hpp>
140165
141-
using vix::App;
166+
using namespace vix;
142167
143-
int main() {
144-
App app;
168+
int main()
169+
{
170+
// Default config path "config/config.json" and port 8080
171+
vix::serve_http_and_ws([](auto &app, auto &ws)
172+
{
173+
// Minimal HTTP route
174+
app.get("/api/ping", [](auto&, auto& res) {
175+
res.json({
176+
"ok", true,
177+
"message", "pong"
178+
});
179+
});
145180
146-
app.get("/api/ping", [](auto& req, auto& res) {
147-
res.json({ "ok", true, "message", "pong" });
181+
// Minimal WebSocket handler: echo/broadcast chat.message
182+
ws.on_typed_message(
183+
[&ws](auto& session,
184+
const std::string& type,
185+
const vix::json::kvs& payload)
186+
{
187+
(void)session;
188+
189+
if (type == "chat.message") {
190+
ws.broadcast_json("chat.message", payload);
191+
}
192+
});
148193
});
149194
150-
// app.ws("/ws", [](auto& ws) {
151-
// ws.on_open([](auto& ctx){});
152-
// ws.on_message([](auto& ctx, std::string_view msg){
153-
// ctx.send(msg); // echo
154-
// });
155-
// });
156-
157-
return app.listen(8080);
195+
return 0;
158196
}`,
159197
run: `vix run server.cpp`,
160198
out: `http :8080/api/ping
@@ -163,7 +201,7 @@ HTTP/1.1 200 OK
163201
"ok": true,
164202
"message": "pong"
165203
}`,
166-
note: "Keep the example simple and aligned with your actual ws API names once stabilized.",
204+
note: "Keep this aligned with the stable ws API names (typed messages + broadcast_json).",
167205
},
168206

169207
{
@@ -178,7 +216,7 @@ vix publish 0.7.0 --notes "Add tree helper"`,
178216
run: `vix add <author>/<pkg>@<version>`,
179217
out: `✔ added: gaspardkirira/tree@0.7.0
180218
✔ configured: include paths + CMake integration`,
181-
note: "The web UI will move to registry.vixcpp.com on the VPS.",
219+
note: "Keep outputs short and stable; avoid promising features not shipped yet.",
182220
},
183221
],
184222
};

vix-site/src/data/home.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,24 @@ vix dev`,
3838

3939
demo: {
4040
title: "A tiny HTTP route",
41-
code: `#include <vix/app/App.hpp>
42-
using vix::App;
41+
code: `#include <vix.hpp>
4342
44-
int main() {
43+
using namespace vix;
44+
45+
int main()
46+
{
4547
App app;
4648
47-
app.get("/api/ping", [](auto& req, auto& res) {
49+
app.get("/api/ping", [](Request &, Response &res)
50+
{
4851
res.json({
4952
"ok", true,
5053
"message", "pong"
5154
});
5255
});
5356
54-
return app.listen(8080);
57+
app.run(8080);
58+
return 0;
5559
}`,
5660
run: `vix run server.cpp`,
5761
out: `http :8080/api/ping
@@ -60,6 +64,7 @@ HTTP/1.1 200 OK
6064
"ok": true,
6165
"message": "pong"
6266
}`,
67+
note: "This is the exact Vix.cpp style: vix.hpp + Request/Response handlers + app.run(port).",
6368
},
6469

6570
next: {

vix-site/src/data/install.js

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,75 @@
11
export const INSTALL = {
2-
title: "Install",
2+
title: "Install Vix.cpp",
33
subtitle:
4-
"Get Vix.cpp installed in minutes. Keep it simple: install, verify, update.",
4+
"Install the Vix.cpp CLI in minutes. Simple, explicit, and reproducible.",
55

66
sections: [
77
{
88
id: "linux",
99
title: "Linux (recommended)",
10-
desc: "Install with a single command. This will download and place the vix binary in a standard location.",
10+
desc: "Install using the official installer. This downloads a prebuilt binary and places it in a standard location.",
1111
code: `curl -fsSL https://vixcpp.com/install.sh | bash`,
12-
note: "Tip: if you're behind a proxy or restricted network, download the binary manually from GitHub Releases.",
12+
note: "The installer is idempotent and safe to re-run. It verifies the binary and does not modify your system outside the install path.",
1313
},
14+
1415
{
1516
id: "mac",
1617
title: "macOS",
17-
desc: "macOS installer is coming soon. Until then, use GitHub Releases.",
18-
code: `# coming soon
19-
# use GitHub Releases for now`,
20-
note: "Once the VPS is live, installs and checksums will be served from vixcpp.com.",
18+
desc: "macOS binaries are distributed via GitHub Releases. A native installer is planned once the packaging format is finalized.",
19+
code: `# download the latest release
20+
# https://github.com/vixcpp/vix/releases
21+
22+
chmod +x vix
23+
mv vix /usr/local/bin/vix`,
24+
note: "We intentionally avoid Homebrew until the CLI interface and upgrade guarantees are fully stabilized.",
2125
},
26+
2227
{
2328
id: "windows",
2429
title: "Windows",
25-
desc: "Windows support is coming soon. For now, build from source.",
26-
code: `# coming soon
27-
# build from source`,
28-
note: "We’ll publish a clean Windows install path once the packaging story is stable.",
30+
desc: "Windows support is experimental. Build from source if you need to evaluate Vix.cpp on Windows today.",
31+
code: `# build from source
32+
git clone https://github.com/vixcpp/vix
33+
cd vix
34+
cmake -B build
35+
cmake --build build`,
36+
note: "A packaged Windows distribution will be published once the runtime and CLI behavior are locked.",
2937
},
38+
3039
{
3140
id: "verify",
32-
title: "Verify",
33-
desc: "Confirm your installation and check the version.",
41+
title: "Verify installation",
42+
desc: "Confirm that Vix.cpp is installed correctly and accessible from your shell.",
3443
code: `vix -h
3544
vix --version`,
36-
note: "If you see the help output and a version, you're good.",
45+
note: "If both commands work and a version is displayed, the installation is complete.",
3746
},
47+
3848
{
3949
id: "update",
4050
title: "Update",
41-
desc: "Re-run the installer to update to the latest release.",
51+
desc: "Update Vix.cpp to the latest release using the same installer.",
4252
code: `curl -fsSL https://vixcpp.com/install.sh | bash`,
43-
note: "Updates are idempotent: you can run this safely multiple times.",
53+
note: "Updates are safe and repeatable. Existing configurations and projects are preserved.",
4454
},
55+
4556
{
4657
id: "uninstall",
4758
title: "Uninstall",
48-
desc: "Remove the vix binary from your system.",
49-
code: `# example (if installed to ~/.local/bin)
59+
desc: "Remove Vix.cpp from your system.",
60+
code: `# example (default install location)
5061
rm -f ~/.local/bin/vix
5162
52-
# optional: remove cache
63+
# optional: remove local cache and registry data
5364
rm -rf ~/.vix`,
54-
note: "Paths may differ depending on your install location.",
65+
note: "Paths may differ depending on where you installed the binary.",
5566
},
5667
],
5768

5869
external: {
5970
releasesLabel: "GitHub Releases",
6071
releasesHref: "https://github.com/vixcpp/vix/releases",
61-
sourceLabel: "Build from source",
72+
sourceLabel: "Source code",
6273
sourceHref: "https://github.com/vixcpp/vix",
6374
},
6475
};

vix-site/src/data/nav.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@ export const NAV = [
66
{ label: "Blog", to: "/blog", optional: true },
77
];
88

9-
// External (switch to subdomains later)
109
export const EXTERNAL = {
1110
docs: {
1211
label: "Docs",
13-
href: "https://github.com/vixcpp/vix", // later: https://docs.vixcpp.com
14-
badge: "coming soon",
12+
href: "https://github.com/vixcpp/vix",
13+
note: "Source-first documentation",
1514
},
1615
registry: {
1716
label: "Registry",
18-
href: "https://github.com/vixcpp/registry", // later: https://registry.vixcpp.com
19-
badge: "coming soon",
17+
href: "https://github.com/vixcpp/registry",
18+
note: "Git-based package index",
2019
},
2120
rix: {
2221
label: "Rix",
23-
href: "https://github.com/vixcpp/rix", // later: https://rix.vixcpp.com
24-
badge: "coming soon",
22+
href: "https://github.com/vixcpp/rix",
23+
note: "Core utilities and foundational modules",
2524
},
2625
};

0 commit comments

Comments
 (0)