Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Vix.cpp

<p align="center">
<img
src="https://res.cloudinary.com/dwjbed2xb/image/upload/v1762524350/vixcpp_etndhz.png"
alt="Vix.cpp Banner"
<img
src="https://res.cloudinary.com/dwjbed2xb/image/upload/v1762524350/vixcpp_etndhz.png"
alt="Vix.cpp Banner"
width="100%"
style="max-width:900px;border-radius:8px;"
/>
Expand Down Expand Up @@ -45,7 +45,7 @@ but engineered **from day one** for:
> **Run applications like Node/Deno/Bun
> with C++ speed, control, and predictability.**

Vix is not just a backend framework.
Vix is not just a backend framework.
It is a **runtime layer** for real-world distributed systems.

---
Expand Down Expand Up @@ -106,7 +106,7 @@ Vix.cpp is designed to remove overhead, unpredictability, and GC pauses.
int main() {
Vix::App app;

app.get("/", [](auto&, auto& res){
app.get("/", [](Request&, Response& res){
res.send("Hello from Vix.cpp 🚀");
});

Expand Down
9 changes: 5 additions & 4 deletions docs/examples/delete_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
#include <vix/json/Simple.hpp>
#include <string>

using namespace Vix;
namespace J = Vix::json;
using namespace vix;
namespace J = vix::json;

int main()
{
App app;

// DELETE /users/{id}
app.del("/users/{id}", [](auto &, auto &res, auto &params)
app.del("/users/{id}", [](Request &req, Response &res)
{
const std::string id = params["id"];
const std::string id = req.param("id");

// In a real app you'd remove the resource from DB or memory here
res.json({
Expand All @@ -25,5 +25,6 @@ int main()
}); });

app.run(8080);
return 0;
}
```
4 changes: 2 additions & 2 deletions docs/examples/hello_routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Minimal GET routes and path params.

```cpp
#include <vix.hpp>
using namespace Vix;
using namespace vix;

int main()
{
App app;

app.get("/hello", [](auto &, auto &res)
app.get("/hello", [](Request &, Response &res)
{ res.json({"message", "Hello, Vix!"}); });

app.run(8080);
Expand Down
33 changes: 17 additions & 16 deletions docs/examples/json_builders_routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,34 @@
#include <vix.hpp>
#include <vix/json/Simple.hpp>

using namespace Vix;
namespace J = Vix::json;
using namespace vix;
namespace J = vix::json;

int main()
{
App app;

// GET /hello -> {"message": "Hello, World!"}
app.get("/hello", [](auto &, auto &res)
{ res.json({"message", "Hello, World!"}); });
app.get("/hello", [](Request &, Response &res){
res.json({"message", "Hello, World!"});
});

// GET /users/{id} -> {"user": {"id": "...", "active": true}}
app.get("/users/{id}", [](auto &, auto &res, auto &params)
{
const std::string id = params["id"];
res.json({
"user", J::obj({
"id", id,
"active", true
})
}); });
app.get("/users/{id}", [](Request &req, Response &res){
const std::string id = req.param("id");
res.json({
"user", J::obj({
"id", id,
"active", true
})
});
});

// GET /roles -> {"roles": ["admin", "editor", "viewer"]}
app.get("/roles", [](auto &, auto &res)
{ res.json({"roles", J::array({"admin", "editor", "viewer"})}); });
app.get("/roles", [](Request &, Response &res){
res.json({"roles", J::array({"admin", "editor", "viewer"})});
});

app.run(8080);
return 0;
}
```
57 changes: 0 additions & 57 deletions docs/examples/logger_context_and_uuid.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/examples/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ int main()

// Basic JSON response (auto send)
app.get("/", [](Request req, Response res) {
return vix::json::o("message", "Hello from Vix");
res.send("message", "Hello from Vix");
});
// Path params + return {status, payload}
app.get("/users/{id}", [](Request req, Response res) {
Expand Down
13 changes: 6 additions & 7 deletions docs/examples/post_create_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@
#include <vix/json/Simple.hpp>
#include <string>

using namespace Vix;
namespace J = Vix::json;
using namespace vix;
namespace J = vix::json;

int main()
{
App app;

// POST /users
app.post("/users", [](auto &req, auto &res)
app.post("/users", [](Request &req, Response &res)
{
try {
// Parse body as nlohmann::json for simplicity (still supported)
auto body = nlohmann::json::parse(req.body());
auto body = json::Json::parse(req.body());

const std::string name = body.value("name", "");
const std::string email = body.value("email", "");
const int age = body.value("age", 0);

res.status(http::status::created).json({
res.status(200).json({
"action", "create",
"status", "created",
"user", J::obj({
Expand All @@ -34,7 +33,7 @@ int main()
});
}
catch (...) {
res.status(http::status::bad_request).json({
res.status(400).json({
"error", "Invalid JSON"
});
} });
Expand Down
13 changes: 6 additions & 7 deletions docs/examples/put_update_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
#include <vix/json/Simple.hpp>
#include <string>

using namespace Vix;
namespace J = Vix::json;
using namespace vix;
namespace J = vix::json;

int main()
{
App app;

// PUT /users/{id}
app.put("/users/{id}", [](auto &req, auto &res, auto &params)
app.put("/users/{id}", [](Request &req, Response &res)
{
const std::string id = params["id"];
const std::string id = req.param("id");

try {
// Parsing with nlohmann::json for input is fine (Vix supports it internally)
auto body = nlohmann::json::parse(req.body());
auto body = json::Json::parse(req.body());

const std::string name = body.value("name", "");
const std::string email = body.value("email", "");
Expand All @@ -37,7 +36,7 @@ int main()
});
}
catch (...) {
res.status(http::status::bad_request).json({
res.status(400).json({
"error", "Invalid JSON"
});
} });
Expand Down
23 changes: 10 additions & 13 deletions docs/examples/user_crud_with_validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#include <sstream>
#include <vector>

using namespace Vix;
namespace J = Vix::json;
using namespace vix;
namespace J = vix::json;
using njson = nlohmann::json;
using namespace Vix::utils;
using namespace vix::utils;

// --------------------------- Data Model -------------------------------------
struct User
Expand Down Expand Up @@ -110,7 +110,7 @@ int main()
App app;

// CREATE (POST /users)
app.post("/users", [](auto &req, auto &res)
app.post("/users", [](Request &req, Response &res)
{
njson body;
try {
Expand Down Expand Up @@ -172,9 +172,9 @@ int main()
}); });

// READ (GET /users/{id})
app.get("/users/{id}", [](auto & /*req*/, auto &res, auto &params)
app.get("/users/{id}", [](Request &req, Response &res)
{
const std::string id = params["id"];
const std::string id = req.param("id");
std::lock_guard<std::mutex> lock(g_mtx);
auto it = g_users.find(id);
if (it == g_users.end()) {
Expand All @@ -188,9 +188,9 @@ int main()
}); });

// UPDATE (PUT /users/{id})
app.put("/users/{id}", [](auto &req, auto &res, auto &params)
app.put("/users/{id}", [](Request &req, Response &res)
{
const std::string id = params["id"];
const std::string id = req.param("id");

njson body;
try {
Expand Down Expand Up @@ -226,9 +226,9 @@ int main()
}); });

// DELETE (DELETE /users/{id})
app.del("/users/{id}", [](auto & /*req*/, auto &res, auto &params)
app.del("/users/{id}", [](Request &req, Response &res)
{
const std::string id = params["id"];
const std::string id = req.param("id");
std::lock_guard<std::mutex> lock(g_mtx);
const auto n = g_users.erase(id);
if (!n) {
Expand All @@ -244,8 +244,5 @@ int main()

// Lancement
app.run(8080);
return 0;
}


```
20 changes: 10 additions & 10 deletions docs/introduction.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Introduction to Vix.cpp

Vix.cpp is a next‑generation **C++20** web backend framework focused on **speed**, **modularity**, and **developer ergonomics**.
Vix.cpp is a next‑generation **C++20** web backend framework focused on **speed**, **modularity**, and **developer ergonomics**.
Inspired by ideas from **FastAPI**, **Vue.js**, and **React**, it brings a clean, expressive style to native C++ while retaining zero‑overhead abstractions and low‑level control.

---
Expand All @@ -19,19 +19,19 @@ Inspired by ideas from **FastAPI**, **Vue.js**, and **React**, it brings a clean

## Core Ideas

1. **Small, sharp core**
1. **Small, sharp core**
The core (`App`, router, request/response, HTTP server) stays tiny and predictable. Everything else is opt‑in.

2. **Simple routing**
2. **Simple routing**
Declarative routes with path parameters: `app.get("/users/{id}", handler);`

3. **JSON‑first**
3. **JSON‑first**
Seamless helpers around _nlohmann/json_ via `Vix::json` (builders, small utilities, safe conversions).

4. **Composability**
4. **Composability**
Middleware, utilities (Logger, UUID, Time, Env), and an optional ORM layer (MySQL / SQLite) integrate without tight coupling.

5. **Pragmatism**
5. **Pragmatism**
Clean, incremental APIs; clear error messages; predictable defaults; portable builds (CMake).

---
Expand All @@ -44,8 +44,8 @@ using namespace Vix;

int main() {
App app;
app.get("/", [](auto&, auto& res) {
res.json({ "message", "Hello world" });
app.get("/", [](Request&, Response& res) {
res.send("message", "Hello world");
});
app.run(8080);
}
Expand Down Expand Up @@ -107,7 +107,7 @@ cmake --build build-rel -j
./build-rel/hello_routes
```

For platform‑specific setup (Linux/macOS/Windows), see **[Installation](./installation.md)**.
For platform‑specific setup (Linux/macOS/Windows), see **[Installation](./installation.md)**.
For packaging, sanitizers, and compile_commands.json, see **[Build & Packaging](./build.md)**.

---
Expand Down Expand Up @@ -149,5 +149,5 @@ For details and status, see **[Architecture](./architecture.md)** and module pag

## Contributing & License

Contributions are welcome! Please read **CONTRIBUTING.md**.
Contributions are welcome! Please read **CONTRIBUTING.md**.
Licensed under **MIT** — see **LICENSE**.
Loading
Loading