%%% -*- mode: erlang; erlang-indent-level: 2; -*-

[
    {
        kernel,
        [
            {logger_level, debug},
            {
                logger,
                [
                    {
                        handler,
                        default,
                        logger_std_h,
                        #{
                            filters =>
                                [
                                    {
                                        default,
                                        {
                                            fun logger_filters:domain/2,
                                            {stop, super, [otp, sasl, tls]}
                                        }
                                    },
                                    {debug, {fun logger_filters:level/2, {log, gt, debug}}}
                                ],
                            formatter => {pretty_logger, #{}}
                        }
                    },
                    {
                        handler,
                        debug,
                        logger_std_h,
                        #{
                            filters =>
                                [
                                    {
                                        default,
                                        {
                                            fun logger_filters:domain/2,
                                            {stop, super, [otp, sasl, tls]}
                                        }
                                    },
                                    {debug, {fun logger_filters:level/2, {stop, neq, debug}}}
                                ],
                            config => #{file => "/var/log/damage/debug.log", max_no_bytes => 1048576, max_no_files => 10}
                        }
                    },
                    {
                        handler,
                        error,
                        logger_std_h,
                        #{
                            single_line => false,
                            filters =>
                                [{error, {fun logger_filters:level/2, {stop, neq, error}}}],
                            config => #{file => "/var/log/damage/error.log", max_no_bytes => 1048576, max_no_files => 10},
                            formatter => {pretty_logger, #{}}
                        }
                    },
                    {
                        handler,
                        info,
                        logger_std_h,
                        #{
                            single_line => false,
                            filters =>
                                [
                                    {
                                        default,
                                        {
                                            fun logger_filters:domain/2,
                                            {stop, super, [otp, sasl, tls]}
                                        }
                                    },
                                    {error, {fun logger_filters:level/2, {stop, neq, info}}}
                                ],
                            config => #{file => "/var/log/damage/info.log", max_no_bytes => 1048576, max_no_files => 10},
                            formatter => {pretty_logger, #{}}
                        }
                    }
                ]
            }
        ]
    },
    {throttle, [
        %{driver, throttle_ets},  %% or throttle_mnesia for cluster-wide limits
        {ip_whitelist, [{127,0,0,1}, {192,168,1,197}]},
        {rates, [
            %%                Scope                     Limit      Period
            {public_read, 200, per_minute},
            {auth_read, 120, per_minute},
            {write_light, 130, per_minute},
            {heavy_query, 10, per_minute},
            {file_upload, 6, per_minute},
            {login_per_identity, 5, per_minute},
            {login_per_ip, 20, per_hour},
            {password_reset_per_identity, 3, per_hour},
            {signup_per_ip, 3, per_day}
        ]}
    ]},
    {
        ecai, [
            {port, 9003},
            {search_context_file, "/var/lib/damage/ecai/yelp.ctx"},
            {pools, [
                {ecai_chat, [{size, 1}, {max_overflow, 0}], []}
            ]}
        ]
    },
    {
        erm, [
            {port, 9000},
            {pools, []}
        ]
    },
    {
        nosternity, [
            {port, 9001},
            {pools, []}
        ]
    },
    {
        bop, [
            {port, 9002},
            {
                pools,
                [
                    {bop, [{size, 10}, {max_overflow, 100}], []}
                ]
            },
            {nostr_npub, "npub16a2r3p8d7syd46ypygva0fqw6pfpgdxv5mm4gd8vqra4wr9scj5sx42y5t"}
        ]
    },
    {
        damage,
        [
            {feature_dirs, ["~/DamageBDD/features/"]},
            {run_user, "damage"},
            {api_url, "http://localhost:8080"},
            {allowance, 1000},
            {lnpay_host, "https://example.xyz"},
            {token_contract, "ct_2taq2WPRer6pkVV7JjiYrkTNr8vr61nLAHQFWbJ3jpX6iyCeBi"},
            {account_contract, "ct_aBXwRhTXYXyD6Gqz7Vk7Nq3U1QhMsZuxFyZ2GvoiroKavxW6B"},
            {identity_contract, "ct_aBXwRhTXYXyD6Gqz7Vk7Nq3U1QhMsZuxFyZ2GvoiroKavxW6B"},
            {
                node_admins,
                [
                    %"ak_...",
                ]
            },
            {ip, {127, 0, 0, 1}},
            %{ip, {0, 0, 0, 0}},
            {port, 8080},
            {smtp_host, "smtp.example.net"},
            {smtp_hostname, "example.com"},
            {smtp_from, {"DamageBDD Node", "node@example.com"}},
            {smtp_user, "apikey"},
            {smtp_port, 587},
            {nostr_relay, "nos.lol"},
            {nostr_npub, "npub14ekwjk8gqjlgdv29u6nnehx63fptkhj5yl2sf8lxykdkm58s937sjw99u8"},
            {data_dir, "/var/lib/damage/"},
            {bitcoin_rpc_port, 8332},
            {bitcoin_rpc_user, "damage"},
            {bitcoin_wallet, "damage"},
            {lnd_host, "localhost"},
            {lnd_port, 8011},
            {lnd_wspath, "/v1/invoices/subscribe?method=GET"},
            {lnd_certfile, "/var/lib/lnd/tls.cert"},
            {lnd_keyfile, "/var/lib/lnd/tls.key"},
            {cln_host, "localhost"},
            {cln_port, 3010},
            {cln_wspath, "/"},
            {cln_cacertfile, "~/.lightning/bitcoin/ca.pem"},
            {cln_certfile, "~/.lightning/bitcoin/client.pem"},
            {cln_keyfile, "~/.lightning/bitcoin/client-key.pem"},
            {ipfs, [{"Addresses.Gateway", "/ip4/127.0.0.1/tcp/8082"}]},
            {ae_network_id, "ae_mainnet"},
            {ae_tls, true},
            {
                ae_nodes,
                [
                    %{"localhost", 3013, "/"}
                    %{"testnet.aeternity.io", 443, "/"}
                    {"mainnet.aeternity.io", 443, "/"}
                ]
            },
            {
                ae_mdw_nodes,
                [
                    %{"localhost", 4000, "/"}
                    %{"testnet.aeternity.io", 443, "/mdw/"}
                    {"mainnet.aeternity.io", 443, "/mdw/"}
                ]
            },
            {ae_mdw_ws_nodes, [
                    %{"localhost", 4002, "/"}
                    {"mainnet.aeternity.io", 443, "/mdw/v3/websocket"}
                ]},
            {cmd_allowed, ["zx list deps"]},
            {chromedriver, "http://localhost:9515/"},
            {
                pools,
                [
                    {damage, [{size, 10}, {max_overflow, 100}], []},
                    {damage_ai, [{size, 2}, {max_overflow, 5}], []},
                    {formatter, [{size, 3}, {max_overflow, 500}], []},
                    {lnd, [{size, 1}, {max_overflow, 0}], []},
                    {cln, [{size, 1}, {max_overflow, 0}], []},
                    %{damage_ssh, [{size, 1}, {max_overflow, 0}], []},
                    {
                        damage_ipfs,
                        [{size, 2}, {max_overflow, 5}],
                        [
                            {"localhost", 5001}
                        ]
                    }
                ]
            },
            {abduco_workers, [
                #{
                    name => "lightningd",
                    cmd =>
                        ["/usr/sbin/lightningd"]
                },

                #{name => "lightpanda", cmd => ["bin/lightpanda-x86_64-linux", "--verbose"]},
                #{name => "chromedriver", cmd => ["chromedriver", "--port=9515"]},
                #{name => "bitcoind", cmd => ["/usr/local/bin/bitcoind"]},
                #{name => "ipfs", cmd => ["/usr/local/bin/ipfs", "daemon"]}
            ]},
            {market_rules, [
                {"DAMAGEUSDT", [{price_precision, 4}, {min_qty, 100.0}]},
                {"BTCUSDT", [{price_precision, 4}, {min_qty, 100.0}]}
            ]},
            {
                ssh, [
                    {user_dir, "/var/lib/damage/sshtest_user/.ssh"},
                    {system_dir, "/var/lib/damage/ssh_daemon/"},
                    {allow_push, true},
                    {port, 2223},
                    {root, "/var/lib/damage/repos/"}
                ]
            },
            {
                systemd,
                [
                    {
                        nginx,
                        {admins, ["ak_2eu6yAH46eu9T88WN7MDnyr1QzW6GLWAc667Z93U44wLewuhLN"]}
                    }
                ]
            }
        ]
    },
    {
        cowboy_swagger,
        [
            %% `static_files`: Static content directory. This is where Swagger-UI
            %% is located. Default: `priv/swagger`.
            %% Remember that Swagger-UI is embedded into `cowboy-swagger` project,
            %% within `priv/swagger` folder. BUT you have to reference that path,
            %% and depending on how youre using `cowboy-swagger` it will be different.
            %% For example, assuming that you want to run your app which has
            %% `cowboy-swagger` as dependency from the console, `static_files` will be:
            {static_files, "./_build/default/lib/cowboy_swagger/priv/swagger"},
            %% `global_spec`: Global fields for Swagger specification.
            %% If these fields are not set, `cowboy_swagger` will set default values.
            {
                global_spec,
                #{
                    swagger => "2.0",
                    info => #{title => "DamageBDD API"},
                    basePath => "/api-docs"
                }
            }
        ]
    },
    {mustache, [{templates_dir, "priv/templates"}]},
    {erlexec, [{user, "damage"}, {limit_users, ["damage"]}]},
    {bcrypt, [{mechanism, "port"}]},
    {sync, [{src_dirs, {replace, [{"./src"}]}}]}
].
