Customize SUCCESS() method
This blog post describes how to customize SUCCESS() method to fit your needs.

The SUCCESS() method is the most used method in my Total.js applications. And few developers know that the output of this method can be changed to fit your needs.
How to modify it?
- create a definition file called
overrides.js
global.SUCCESS = function(success, value) {
// Check if the "success" variable is a function
if (typeof(success) === 'function') {
return function(err, value) {
success(err, SUCCESS(err, value));
};
}
var err;
if (success instanceof Error) {
// Is "success" Error?
err = success.toString();
success = false;
} else if (success instanceof ErrorBuilder) {
// Maybe "success" is ErrorBuilder instance
if (success.hasError()) {
err = success.output();
success = false;
} else
success = true;
} else if (success == null)
success = true;
if (err)
return { error: err };
else if (success)
return { ok: true };
else
return { error: 'Repeat your operation.' };
};Usage examples:
console.log(SUCCESS(true));
// Output: { ok: true }
console.log(SUCCESS(false));
// Output: { error: 'Repeat your operation.' }
console.log(SUCCESS(false));
// Output: { error: 'Error: A bug' }
console.log(SUCCESS(new ErrorBuilder().push('', 'A bug')));
// Output: { error: [ { name: '', error: 'A bug', path: undefined, index: undefined } ] }
// the real purpose is to use it as a response in a controller
function some_controller() {
this.json(SUCCESS(true));
}Keep reading
Using AI for Traffic Analysis and Smart Parking Monitoring
Discover how AI, NVIDIA Jetson AGX, and Total.js IoT transform camera data into traffic insights and automated parking occupancy monitoring.
Total.js Platform and NVIDIA DeepStream: Automated AI Video Anonymization
Discover how we combined Total.js Platform, Total.js Flow, and NVIDIA DeepStream to build a scalable, GPU-accelerated video anonymization system for a major enterprise customer. Explore how we process large volumes of video recordings, automate workflows across multiple locations, and manage AI-powered anonymization through a centralized interface.
October report 2026
A quick overview of all changes and news from the entire Total.js Platform. Read more about our work.
Node.js Security Vulnerabilities
Recent Node.js security updates have addressed serious vulnerabilities, including an issue in Brotli decompression. The news is particularly interesting because AI-assisted security research helped uncover a flaw in technology used by applications around the world.
September report 2026
A quick overview of all changes and news from the entire Total.js Platform. Read more about our work.
August report 2026
A quick overview of all changes and news from the entire Total.js Platform. Read more about our work.
How to write better Total.js Applications using AI?
Learn how to make AI coding agents write better, more native Total.js applications!
July report 2026
A quick overview of all changes and news from the entire Total.js Platform. Read more about our work.
Total.js AIModel: a practical foundation for AI-powered workflows
How Total.js helps developers integrate AI models into real applications with routing, actions, streaming, tools, validation, and business logic in one coherent stack.
June report 2026
A quick overview of all changes and news from the entire Total.js Platform. Read more about our work.