-module(store_app).
-behaviour(application).

-export([start/2]).
-export([stop/1]).

start(_Type, _Args) ->
  table:new(table(), [named_table, public, set]),
  Dispatch = cowboy_router:compile([
    {'_', [{"/api/items/[:item_id]", store_handler, #{table => table()}}]}
  ]),
  {ok, _} = cowboy:start_clear(
    http_listener,
    [{port, 8080}],
    #{env => #{dispatch => Dispatch}}
  ),
  store_sup:start_link().

stop(_State) ->
  ok.

%%
%% Internal.
%%
table() -> workloads_store.