 
 (defc "/systems" [:env] (keyword v))
  
-(defn systems-by-query 
-   "Get systems in range by query" 
-   [from to query]
-  {:pre [(> from -1)]}
-
-  )
+(defn working-username  []
+   (let [{:keys [username]} (current-user) ] 
+     username))
 
 (defn systems-range
   "Get systems in range" 
   [from to]
   {:pre [(> from -1)]}
-  (let [{:keys [username]} (friend/current-authentication)
-         systems (into [] (s/systems-for username)) to* (min to (count systems))]
+  (let [systems (into [] (s/systems-for (working-username))) to* (min to (count systems))]
     (when-not (empty? systems)
       (if (and (contains? systems from) (contains? systems (- to* 1)))
         {:meta {:total (count systems)} 


  (DELETE- "/systems/:id" [^:int id] {:nickname "deleteSystem" :summary "Delete System" 
                                          :errorResponses (errors {:bad-req "System does not exist"})}
           (try+ 
             (let [spec (s/get-system! id) int-id (Integer/valueOf id)]               
               (s/delete-system! id) 
               (success {:message "System deleted"})) 


(defroutes- environments {:path "/environments" :description "Operations on environments"}
  (GET- "/environments" [] {:nickname "getEnvironments" :summary "Get all environments"}
     (let [{:keys [envs] :as user} (p/get-user (working-username))]
        (success {:environments (sanitized-envs (into #{} envs))}))))
