FAQ

Core & Common

How can I start services with Moleculer Runner in debug mode?

Use the following command:

$ node --inspect=0.0.0.0:9229 node_modules/moleculer/bin/moleculer-runner services

API Gateway (moleculer-web)

Why am I getting 413 - request entity too large error message when sending a big POST body?

You should configure the bodyParsers to overwrite the default 100kb POST body limit. More info.

module.exports = {
name: "api",
settings: {
routes: [{
path: "/api",

// Use bodyparser modules
bodyParsers: {
json: { limit: "2MB" },
urlencoded: { extended: true, limit: "2MB" }
}
}]
}
}
Recommendation

Use streaming feature when you want to send big data to a service or receive from a service.

How do I reformat error responses?

You should define an onError hook in API Gateway settings. More info.

// api.service.js
module.exports = {
mixins: [ApiService],
settings: {
// Global error handler
onError(req, res, err) {
res.setHeader("Content-Type", "application/json");
res.writeHead(err.code || 500);
res.end(JSON.stringify({
success: false,
message: err.message
}));
}
}
};