Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
Aluisio Amaral edited this page Nov 28, 2017 · 5 revisions

Summary

Change errors language

Currently, when the node-routeros throws errors, it throws in english. We can change the language using the node-routeros's property locale when creating a new object:

const RouterOSClient = require('routeros-client').RouterOSClient;

const routeros = new RouterOSClient({
    host: "someplace.com",
    user: "admin",
    password: "somepassword",
    locale: "br"
});

You can find the currently available languages here. You can contribute sending a translation to your language if you don't find it there =].

Use snake_case on retrieved properties

In case you are using the snake_case pattern for your development workflow, you can change the way routeros-client parses the routerOS dashed properties by invoking the useSnakeCase() method of the client object:

useSnakeCase(): void

routeros.connect().then((client) => {
    
    // Changing to snake_case pattern
    client.useSnakeCase();

}).catch((err) => {
    // Error when trying to connect
    console.log(err);
});

Note: you can use snake_case anywhere you wan't, like:

client.menu("/ip proxy access").select([
    "id",
    "dst_host",
    "dst_port",
    "comment"
]).where({
    local_port: 8080
}).get();

Considerations

Clone this wiki locally