Skip to content

Tera3Bit/Xpress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Version License Build Platform Status Contributions Issues Stars Forks

πŸš€ Xpress++ v2.0.0

Modern C++ Web Framework β€” Fast, Lightweight & Developer-Friendly

Xpress++ is a high-performance C++ web framework inspired by the simplicity of Express.js and the efficiency of modern C++ networking. Built for speed, safety, and ease of use β€” without compromising advanced features.


✨ What's New in v2.0.0

πŸ†• Rewritten core with faster routing engine πŸ†• New Request & Response API πŸ†• Advanced Caching (ETag, Cache-Control, No-Cache) πŸ†• Cookie Manager (set, read, clear, options) πŸ†• Bearer Authentication Helpers πŸ†• Mobile Detection + Content Negotiation πŸ†• CSV, XML, JSONP, SSE support πŸ†• File responses (inline + download) πŸ†• Metrics + Server-Timing πŸ†• Pagination helper πŸ†• Pattern-matching routes πŸ†• Unified error / success responses πŸ†• Static security headers + CSP πŸ†• Rate-limit headers πŸ†• Full request introspection πŸ†• Better redirect & status helpers πŸ†• Trusted proxies support πŸ†• New ServerConfig System


πŸ“¦ Installation

git clone https://github.com/QuickDigi/Xpress.git
cd Xpress
mkdir build && cd build
cmake ..
make -j8

Or include it as a header-only dependency in your project.


🧩 Quick Example

#include <xpresspp/app.hpp>
#include <xpresspp/server.hpp>

using namespace xpresspp;

int main() {
    App app;

    app.get("/", [](Request& req, Response& res){
        res.json({{"message", "Hello from Xpress++!"}});
    });

    ServerConfig config;
    config.port = 5000;

    Server server(app, config);
    server.run();
}

🌐 Features Overview

πŸ”₯ Core Features

  • Super-fast routing
  • Params, query, full URL parsing
  • Pattern-based routes (/user/:id)
  • JSON / HTML / Text responses
  • app.all("*") for wildcard routes
  • Request body parser (JSON)

πŸ” Authentication

  • req.getBearerToken()
  • req.isAuthenticated()
  • Token & cookie-based checks

πŸ” Security

  • Auto security headers
  • CSP support (res.csp())
  • Proxy trust support
  • CORS (res.cors(), res.corsPreFlight())

⚑ Performance

  • ETag support
  • Cache-Control helpers
  • Freshness validation
  • Response compression-friendly

🧠 Content Negotiation

  • req.accepts("application/json")
  • Mobile detection
  • XHR detection
  • CSV, XML, JSONP support

πŸͺ Cookies

  • Set/read/clear cookies
  • Options: maxAge, secure, httpOnly, sameSite

πŸ“ File Handling

  • Inline file serving
  • File download
  • Attachments

πŸ“Š Monitoring

  • Server metrics
  • Server-Timing header
  • Request duration
  • Health endpoint

πŸ“¦ API Helpers

  • Pagination (res.paginate())
  • Error/Success formatters
  • Rate-limit headers

πŸ“‘ Advanced Endpoints in v2.0.0

βœ” Bearer Authentication

app.get("/auth/bearer", [](Request& req, Response& res){
    if (req.getBearerToken() != "secret-token-123")
        return res.error(403, "Invalid token");

    res.success({{"user","admin"}}, "Authenticated");
});

βœ” Cookie Example

res.cookie("session", "abc123", {
    .maxAge = 3600,
    .httpOnly = true,
    .secure = false,
    .sameSite = "Lax"
});

βœ” File Download

res.download("file.txt", "download.txt");

βœ” SSE (Server-Sent Events)

res.sse("Hello!", "update", "1");

πŸ“‚ Project Structure (Recommended)

/src
  /routes
  /controllers
  /middleware
  main.cpp

/include/xpresspp
  app.hpp
  server.hpp
  request.hpp
  response.hpp

/examples
/docs

πŸ›  Server Configuration

ServerConfig cfg;
cfg.host = "localhost";
cfg.port = 5000;
cfg.threadPoolSize = 8;
cfg.enableCORS = true;
cfg.enableMetrics = true;
cfg.maxRequestSize = 5 * 1024 * 1024; // 5MB

πŸ“ˆ Benchmark (v2.0.0)

Test Result
JSON response ~52k req/s
HTML response ~48k req/s
File serving ~41k req/s
Routing (params) ~62k req/s

Benchmarks run on AMD A8 R7 (same as dev-machine).


πŸ“œ License

MIT β€” completely free for personal & commercial use.


❀️ Maintained by

QuickDigi β€” Egyptian tech innovator πŸ‡ͺπŸ‡¬ Developer: Mohammed Mostafa Brawh


⭐ Support

If you like Xpress++ β†’ Star the repo ⭐ It keeps the project alive!

About

A lightweight C++ web framework inspired by Express.js

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages