Skip to content

Latest commit

History

History
119 lines (81 loc) · 2.07 KB

File metadata and controls

119 lines (81 loc) · 2.07 KB

project-setup

Project setup

This guide shows the simplest possible Vix project layout.

Everything is minimal. Everything is explicit. No hidden structure.


1. Minimal structure

my-vix-app/
CMakeLists.txt
main.cpp

That is enough.


2. main.cpp example

All routes directly inside main.

#include<vix.hpp>usingnamespacevix;intmain()
{
App app;
app.get("/", [](Request&, Response& res) {
res.json({"message", "Welcome to Vix"});
});
app.get("/users/{id}", [](Request& req, Response& res) {
const std::string id = req.param("id", "0");
if (id == "0")
{
res.status(404).json({"error", "User not found"});
return;
}
res.json({
"id", id,
"name", "User#" + id
});
});
app.get("/search", [](Request& req, Response& res) {
const std::string q = req.query_value("q", "");
const std::string page = req.query_value("page", "1");
res.json({
"query", q,
"page", page
});
});
app.run(8080);
}

3. Minimal CMakeLists.txt

cmake_minimum_required(VERSION3.20)
project(my_vix_app LANGUAGESCXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIREDON)
add_executable(my_vix_appmain.cpp)
# Link Vix according to your setup# target_link_libraries(my_vix_app PRIVATE vix::vix)

4. Build manually

mkdir build
cd build
cmake ..
cmake --build .

Run:

./my_vix_app

5. Scaling later

When your project grows, you can:

  • Split routes into multiple files
  • Add helpers for parsing
  • Add middleware
  • Add database layers

But the core idea stays the same:

Routes are explicit. Handlers are simple lambdas. main starts the runtime.

Nothing more.