Total.js Framework

3.4.13 · maintenance · verified Sun Apr 19

Total.js is a full-stack, open-source Node.js framework designed for creating web applications, REST services, real-time applications, and IoT solutions. Written in pure JavaScript without external dependencies (beyond optional database connectors or specific modules), it aims for high performance and clean architecture, similar to MVC frameworks like Laravel or Django. The framework emphasizes backward compatibility, with version 3 (3.4.13 being a recent patch) receiving frequent updates and bug fixes. It includes a built-in web server, static file handling, powerful routing, an embedded NoSQL database (TextDB), image processing via GraphicsMagick or ImageMagick, WebSockets, a custom view engine, and a schema system for data validation and workflows. Total.js differentiates itself by providing a comprehensive, independent platform often used with its ecosystem of tools like Total.js Code Editor and CMS. While Total.js v3 is actively maintained, the project has transitioned to newer major versions (v4, `total4` on npm, and v5, `total5` on npm), which introduce significant architectural changes and target newer Node.js versions, although v3 continues to be supported for existing projects.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Total.js framework, start a basic HTTP server, and define two simple GET routes that respond with plain text and JSON respectively, using the global `ROUTE` function and `framework.http()` method.

const framework = require('total.js');

// Start the framework in debug mode
// In a typical Total.js setup, this would be in your main application file (e.g., app.js or index.js)
// and the framework automatically scans for controllers, views, etc.
// For a simple standalone script, you can explicitly call .http() or .https().

// To run a full Total.js application, you'd usually have a directory structure
// with 'controllers', 'views', 'schemas', etc., and then start it with:
// require('total.js').http('debug');

// For this quickstart, we'll demonstrate a simple route definition directly:

// Define a simple GET route
ROUTE('GET /', function() {
    // 'this' inside a route handler refers to the Controller instance
    this.plain('Hello from Total.js!');
});

ROUTE('GET /api/data', function() {
    this.json({
        message: 'This is some data from Total.js API',
        timestamp: new Date()
    });
});

// Listen on HTTP port 8000 (default for debug mode)
framework.http('debug', { port: 8000 });

console.log('Total.js application running in debug mode on http://127.0.0.1:8000');

view raw JSON →