 (defn api-routes
   [db]
   (routes
+    (ANY "/groups" [] (groups-resource db nil))
     (ANY "/groups/:id" [id] (groups-resource db id))
-    (ANY "/groups/:id/expenses" [id] (expenses-resourse id))
-    (ANY "/groups/:id/dept" [id] (dept-resource id))))
+    (ANY "/groups/:id/expenses" [id] (expenses-resourse db id))
+    (ANY "/groups/:id/dept" [id] (dept-resource db id))))
 
 (def api-handler
   (-> (api-routes database)

           (let [body (slurp (-> ctx :request :body))
                 data (json/read-str body :key-fn keyword)
                 group-id (get-in ctx [:request :params :id])
                 id (groups/add-shared-expense group-id (:payed-by data)
                                               (:amount data) (:shared-with data))]
             {::expense-id id})))

(defresource dept-resource [group-id]
  :allowed-methods [:get]
  :available-media-types ["application/json" "application/clojure"]
  :handle-ok (fn [ctx]
               (let [media-type (get-in ctx [:representation :media-type])]
                 (condp = media-type
                   "application/json" (into [] (groups/get-group-dept database group-id))
                   (into [] (groups/get-group-dept database group-id))))))

(defn- hello-world [request]
  (-> (res/response "Hello, api!")

(defresource groups-resource [db id]
  :available-media-types ["application/json"]
  :handle-ok (fn [ctx]
               (if (nil? id)
                 (json/write-str (groups/list-groups db))
                 (json/write-str (groups/get-group db id)))))

(defresource expenses-resourse [db group-id]
  :allowed-methods [:post :get]
  :available-media-types ["application/json" "application/clojure"]
  :handle-ok (fn [ctx]
