aboutsummaryrefslogtreecommitdiff
path: root/server/src/jchat_config.erl
blob: 35a3436b04b2fe3730eb60331ebd6625e19e54bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-module(jchat_config).

-export([get/1, get/2, 
         http_port/0, api_domain/0, web_domain/0, 
         static_files_dir/0, cors_origins/0,
         jwt_secret/0, auth_config/0,
         database_config/0]).

%% Get configuration value with optional default
get(Key) ->
    application:get_env(jchat, Key).

get(Key, Default) ->
    application:get_env(jchat, Key, Default).

%% Specific configuration getters
http_port() ->
    get(http_port, 8080).

api_domain() ->
    get(api_domain, "api.jchat.localhost").

web_domain() ->
    get(web_domain, "web.jchat.localhost").

static_files_dir() ->
    get(static_files_dir, "../client").

cors_origins() ->
    get(cors_origins, ["*"]).

jwt_secret() ->
    Secret = get(jwt_secret, "default-secret-change-me"),
    case Secret of
        "default-secret-change-me" ->
            logger:warning("Using default JWT secret - change this in production!"),
            Secret;
        _ ->
            Secret
    end.

auth_config() ->
    get(auth, []).

database_config() ->
    get(database, []).