%% vim: ts=4 sw=4 et ft=erlang
%%%
%%% CHICAGO BOSS PROJECT SKELETON
%%%
%%% This file can be modified by you to avoid you needing to reenter
%%% defaults when creating new projects.  For full configuration
%%% details, please visit
%%% https://github.com/ChicagoBoss/ChicagoBoss/wiki/Configuration

%%% When running tests, you may want to create a separate configuration file
%%% "boss.test.config" which, if present, will be read instead of boss.config.

[{boss, [
    {path, "./deps/boss"},
    {applications, [chicagoboss]},
    {assume_locale, "en"},

%%%%%%%%%%%%
%% System %%
%%%%%%%%%%%%

%% vm_cookie - Erlang cookie, must be the same for all nodes in the
%%   cluster.

%% vm_name - Node name to use in production. Must be unique for all
%%   nodes in the cluster. Defaults to <application_name>@<host_name>.
%% vm_sname - Node name to use if you wish to use a "short name" instead of a
%%   full name.
%% vm_max_processes - The limit of processes that the VM is allowed to
%%   spawn. Defaults to 32768 (the usual system default).

%    {vm_cookie, "secret"},
%    {vm_name, "leader@localhost"}
%    {vm_sname, "shortname"},
%    {vm_max_processes, 32768},


%%%%%%%%%%%%%%%%%%%%%%%%
%% Controller Filters %%
%%%%%%%%%%%%%%%%%%%%%%%%

%% controller_filter_config - Specify defaults for controller filters
%%   Sub-key 'lang' can be set to the atom 'auto' to autodetermine language
%%     universally, or can be set to a specific language by setting a string (e.g.
%%     "en" or "de")

%    {controller_filter_config, [
%        {lang, auto}
%    ]},

%%%%%%%%%%%%%%
%% Compiler %%
%%%%%%%%%%%%%%

%% See compile(3) for a full list of options

%    {compiler_options, [return_errors]},

%%%%%%%%%%%
%% Cache %%
%%%%%%%%%%%

%% cache_adapter - Which cache adapter to use. Currently the only
%%   valid value is memcached_bin.
%% cache_enable - Whether to enable the cache. Defaults to false.
%% cache_servers - A list of cache servers ({Host, Port,
%%   PoolSize}). Defaults to [{"localhost", 11211, 1}].
%% cache_exp_time- The maximum time to keep a cache entry, in
%%   seconds. Defaults to 60.

%    {cache_adapter, memcached_bin},
%    {cache_enable, false},
%    {cache_servers, [{"localhost", 11211, 1}]},
%    {cache_exp_time, 60}, 

%%%%%%%%%%%%%%
%% Database %%
%%%%%%%%%%%%%%

%% db_host - The hostname of the database. Defaults to "localhost".
%% db_port - The port of the database. Defaults to 1978.
%% db_adapter - The database adapter to use. Valid values are: 
%%     mock - In-memory (non-persistent) database, useful for testing
%%     mnesia - Mnesia
%%     mongodb- MongoDB
%%     mysql - MySQL
%%     pgsql - PostgreSQL
%%     riak - Riak
%%     tyrant - Tokyo Tyrant
%% db_username - The username used for connecting to the database (if
%%   needed).
%% db_password - The password used for connecting to the database (if
%%   needed).
%% db_database - The name of the database to connect to (if needed).
%% db_cache_enable - Whether to enable the cache in boss_db. Defaults 
%%   to false. Requires cache_enable to be set to true.

    {db_host, "tfb-database"},
    {db_port, 1978},
    {db_adapter, mock},
%    {db_username, "boss"},
%    {db_password, "boss"},
%    {db_database, "boss"},

%%  MongoDB only
%%
%% Read https://github.com/TonyGen/mongodb-erlang#readme for details
%% db_write_mode - defaults to safe
%% db_read_mode - defaults to master
%    {db_write_mode, safe},
%    {db_read_mode, master},

%% Database sharding
%% A list of proplists with per-shard database configuration. 
%% The proplists override the above options, and should contain two
%% additional options: 
%%  {db_shards, [ 
%%      [ 
%%          {db_host, "localhost"}, 
%%          {db_adapter, mysql}, 
%%          {db_port, 3306}, 
%%          {db_username, "dbuser"}, 
%%          {db_password, "dbpass"}, 
%%          {db_database, "database"},
%%          {db_shard_id, shard_id_atom}, 
%%          {db_shard_models, [model_atom_1, model_atom_2,
%%                             model_atom_3, etc]}  
%%      ] 
%%  ]},

%%%%%%%%%%
%% Mail %%
%%%%%%%%%%

%% mail_driver - The email delivery driver to use. Valid values are:
%%   boss_mail_driver_smtp - SMTP delivery. If mail_relay is present, 
%%     it is used as a relay, otherwise direct delivery is attempted.
%%   boss_mail_driver_mock - A black hole, useful for testing.
%% mail_relay_host - The relay server for SMTP mail deliveries.
%% mail_relay_username -The username used for connecting to the SMTP
%%   relay (if needed).
%% mail_relay_password -The password used for connecting to the SMTP
%%   relay (if needed).

%    {mail_driver, boss_mail_driver_mock},
%    {mail_relay_host, "smtp.example.com"},
%    {mail_relay_username, "webmaster@example.com"},
%    {mail_relay_password, "mailpassword"},


%%%%%%%%%%%%%%%%%%
%% Master Node  %%
%%%%%%%%%%%%%%%%%%


%% master_node - 
%%   For distributed configurations, the name of the master node. 
%%   The master node runs global services (incoming mail, message
%%   queue, events, sessions).
%%   Should be an atom, e.g. somenode@somehost. 
%%   The node name is specified in the -sname or -name argument in the
%%   startup script.

%    {master_node, 'master@example.com'},

%%%%%%%%%%%%%%%
%% Webserver %%
%%%%%%%%%%%%%%%

%% port - The port to run the server on. Defaults to 8001.
%% server - The HTTP server to use. Valid values are: 
%%   mochiweb - The Mochiweb Web Server
%%   cowboy - The Cowboy Web Server (Comet, WebSockets, highly scalable, ...)
    {port, 8080},
    {server, cowboy},

%%%%%%%%%%%%%%
%% Websocket %%
%%%%%%%%%%%%%%
    %% you can specify a global timeout for your websocket connection
    %% when a websocket is idle more than the timeout, it is closed by the webserver
    %% and you receive in your handle_close function  {normal, timeout} as the
    %% reason.

    %{websocket_timeout, 5000},

%%%%%%%%%%%%%%
%% Sessions %%
%%%%%%%%%%%%%%

%% session_adapter - Selects the session driver to use. Valid values:
%%   cache - Store sessions in the configured cache
%%     servers. Requires cache_enable to be set to true.
%%   ets (default)
%%   mnesia

%% session_enable - Whether to enable sessions. Defaults to true.
%% session_key - Cookie key for sessions. Defaults to "_boss_session".
%% session_exp_time - Expiration time in seconds for the session
%%   cookie. Defaults to 525600, i.e. 6 days, 2 hours.
%% session_mnesia_nodes, for {session_adapter, mnesia} only - List of
%%   Mnesia nodes, defaults to node(). 
%% session_domain - (optional, sets the Domain=x cookie option), 
%%   this can be used by ex: to enable subdomain apps 
%%     (*.domain.com) with the param ".domain.com" => {session_domain,
%%     ".domain.com"}

    {session_adapter, mock},
    {session_key, "_boss_session"},
    {session_exp_time, 525600},
    {session_cookie_http_only, false},
    {session_cookie_secure, false},
%    {session_enable, true},
%    {session_mnesia_nodes, [node()]}, % <- replace "node()" with a node name
%    {session_domain, ".domain.com"},

%%%%%%%%%%%%%%%
%% Templates %%
%%%%%%%%%%%%%%%

%% template_tag_modules - List of external modules to search for
%%   custom ErlyDTL tags.
%% template_filter_modules - List of external modules to search for
%%   custom ErlyDTL filters.
%% template_auto_escape - Controls automatic HTML escaping of template
%%   values. Enabled by default.
    {template_tag_modules, []},
    {template_filter_modules, []},
    {template_auto_escape, true},

%%%%%%%%%%%%%%%%%%%%%
%% Incoming Emails %%
%%%%%%%%%%%%%%%%%%%%%

%% smtp_server_enable - Enable the SMTP server for incoming mail
%% smtp_server_address - The address that the SMTP server should bind
%%   to. Defaults to {0, 0, 0, 0} (all interfaces).
%% smtp_server_domain - The host name of the SMTP server
%% smtp_server_port - The port that the SMTP server should listen
%%   on. Defaults to 25.

%    {smtp_server_enable, false},
%    {smtp_server_address, {0, 0, 0, 0}},
%    {smtp_server_domain, "smtp.example.com"},
%    {smtp_server_port, 25},

%% smtp_server_protocol - The protocol that the SMTP server should
%%   use. Valid values are:
%%     tcp (default)
%%     ssl
%    {smtp_server_protocol, tcp},

%%%%%%%%%
%% SSL %%
%%%%%%%%%

%% ssl_enable - Enable HTTP over SSL
%% ssl_options - SSL options; see ssl(3erl)

%    {ssl_enable, true},
%    {ssl_options, []},

%%%%%%%%%%%%%%%%%%%%
%% LOG FORMATTING %%
%%%%%%%%%%%%%%%%%%%%

%% Set log_stack_multiline to true to make stack traces more readable at the
%% cost of spanning multiple lines

%    {log_stack_multiline, true},

     {dummy, true} % a final dummy option so we don't have to keep track of commas
]},

%% MESSAGE QUEUE

{ tinymq, [
%% max_age- Maximum age of messages in the [message queue], in
%%   seconds. Defaults to 60.
    % {max_age, 60}
]},

%%%%%%%%%%%%%
%% Logging %%
%%%%%%%%%%%%%

%% Lager default config. 
%% More info: https://github.com/basho/lager 

{lager, [
    {handlers, [
      {lager_console_backend, info},
      {lager_file_backend, [
        {"log/error.log", error, 10485760, "$D0", 5},
        {"log/console.log", info, 10485760, "$D0", 5}
      ]}
    ]},

    %% Colored output, if you want to modify the colors, see
    %% https://github.com/basho/lager/blob/master/src/lager.app.src
    % {colored, true},

    {dummy, true}
  ]},

%%%%%%%%%%%%%%%
%% Webserver %%
%%%%%%%%%%%%%%%

{simple_bridge, [

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %% STANDARD SETTINGS
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    {server_name, boss_webserver},
    %% You can call this whatever you want. Name it after your application
    %% is probably best

    {handler, boss_simple_bridge_handler},
    %% the name of the simple_bridge handler module, which is expected to
    %% export run/1, ws_init/1, ws_message/1, ws_info/1, and terminate/1

    {backend, cowboy},
    %% cowboy | inets | mochiweb | webmachine | yaws
    %% It's not necessary to specify this in the confiugration unless you
    %% want to start simple_bridge with application:start(simple_bridge) or
    %% simple_bridge:start/0

    {address, "0.0.0.0"},
    %% IP address to bind, either in tuple format or string
    %% use "0.0.0.0" to start on all interfaces available

    {port, 8080},
    %% Port to bind

    {document_root, "./priv/static"},
    %% The path on the local machine to handle static files

    {static_paths, ["js/"]},
    %% The list of paths to be automatically translated to static paths by
    %% simple_bridge

    %% {anchor, AnchorModule},
    %% If not provided or set to undefined, will use
    %% BACKEND_simple_bridge_anchor. This is the backend-specific module
    %% for handling the requests from your chosen backend.

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %% FILE UPLOAD SETTINGS
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    {max_post_size, 100},
    %% No multipart request greater than above will be accepted. Units are
    %% MB

    {max_file_size, 100},
    %% No single uploaded file will be accepted greater than  the above.
    %% Units are MB.

    {max_file_in_memory_size,  0},
    %% If a file is less than the above, then instead of writing the file
    %% to disk, it'll be retained in memory and can be retrieved by
    %% sb_uploaded_file:data/1. See the README for more info.

    {scratch_dir, "./scratch"},
    %% This is the location of the temp directory where uploaded files will
    %% be placed.

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %% BACKEND-SPECIFIC DISPATCH TABLES:
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    %% {webmachine_dispatch, DispatchTable},
    %% Webmachine dispatch table override (ignores static_paths above)

    %% {webmachine_dispatch_fun, {Module, Function}},
    %% A Module:Function() that when evaluated will return a dispatch table
    %% for Webmachine, again ignores the static_paths above

    %% {cowboy_dispatch, DispatchTable},
    %% Cowboy dispatch table override (ignores static_paths)

    {cowboy_dispatch_fun, {boss_cowboy_dispacher, build_and_compile}},
    %% A Module:Function() that when evaluated will return a dispatch table
    %% for Cowboy, again ignoring the static_paths above. You'll likely
    %% want to add a dispatch rule pointing at the standard simple_bridge
    %% anchor (unless you're using your own custom anchor):
    %%
    %%      {'_', cowboy_simple_bridge_anchor,[]}

    {dummy, true}
]},

%% APPLICATION CONFIGURATIONS

%% domains - A list of domains to serve the application on
%% static_prefix - The URL prefix of static assets
%% doc_prefix - The URL prefix for developer documentation
{ chicagoboss, [
    {path, "../chicagoboss"},
    {base_url, "/"},
%    {domains, all},
%    {static_prefix, "/static"},
%    {doc_prefix, "/doc"},

    {dummy, true}
]}
].
