HappyX Framework Documentation

repository·master·Indexed 20 days ago

https://github.com/hapticx/happyx

A macro-oriented, asynchronous, full-stack web framework written in Nim for building Single Page Applications (SPA), Static Site Generation (SSG), Server-Side Rendering (SSR) applications, and REST APIs. It includes a unified toolset via the hpx CLI and provides language bindings for NodeJS (Linux only), Python (>= 3.7.x), and Java.

Tokens
11.5K
Snippets
49
Records
62
Agent score
70%

What's inside HappyX

  1. Core HappyX features and macros

    master

    HappyX is a macro-oriented framework that provides several tools for full-stack development:

    • Asset Building: Use buildHtml, buildStyle, and buildJs macros to generate web assets.
    • Request Modeling: Use the model macro to support JSON, XML, Form-Data, and x-www-form-urlencoded request bodies.
    • Routing: Supports powerful path parameters via the pathParams macro.
    • Sub-applications: Use the mount macro to mount sub-applications.
    • Logging: Enable logging using the -d:debug flag.
    • Translation: Enable automatic translation using -d:hpxTranslate or -d:translate flags.
  2. Requirements for running the sandbox_api example

    master

    To run the sandbox_api example, which is used in the HappyX website, ensure your environment meets the following requirements:

    • Nim: version v2.0.0 or higher.
    • HappyX: The #head version (latest development version).
    • Libraries: The regex library must be installed.
  3. Create a Single Page Application (SPA) project

    master

    To start a new SPA project, use the hpx CLI tool with the --kind SPA flag. You can also include the --path-params flag to enable path parameter support.

    hpx create --name spa_project --kind SPA --path-params
    cd spa_project
    hpx create --name spa_project --kind SPA --path-params
  4. Build a HappyX project

    master
    To build your HappyX project for deployment, use the hpx build command. This generates a production-ready build, typically located in the /build directory. Once the build is complete, you can serve or open the resulting /build/index.html file to view your application.
    hpx build
  5. Create a Server-Side Rendering (SSR) project

    master

    To start a new SSR project, use the hpx CLI tool with the --kind SSR flag. The main entry point will be located at src/main.nim within your project directory.

    hpx create --name ssr_project --kind SSR
    cd ssr_project/src
    hpx create --name ssr_project --kind SSR
  6. Explore HappyX usage examples

    master

    The examples directory contains several reference implementations demonstrating different application types possible with the HappyX framework:

    • Hello, world!: A basic entry-level application.
    • TODO App: A functional task management application.
    • Nim Website: A complex site implementation (a copy of nim-lang.org).
    • Chat App: A full-stack implementation featuring both server-side and client-side logic using HappyX.
    • Official HappyX website: A Single Page Application (SPA) built entirely with HappyX.