             [uxbox.util.uuid :as uuid]
             [uxbox.util.exceptions :as ex]))
 
+
+;; --- Common Specs
+
+(s/def ::id ::us/uuid)
+(s/def ::name string?)
+(s/def ::version (s/and int? pos?))
+
+;; --- List Projects
+
 (defn list-projects
   {:description "List projects"}
   [{:keys [user] :as req}]

                  (let [loc (str "/api/projects/" (:id result))]
                    (rsp/created loc result)))))))

(defn update-project
  "Update project"
  {:parameters {:path {:id [st/required st/uuid-str]}
                :body {:name [st/required st/string]
                       :version [st/required st/integer]}}}
  [{:keys [user parameters] :as req}]
  (let [id (get-in parameters [:path :id])
        data (get parameters :body)

    (->> (sv/query message)
         (p/map rsp/ok))))

;; --- Create Projects

(s/def ::create-project|body
  (s/keys :req-un [::name]
          :opt-un [::id]))

(defn create-project
  "Create project"
  {:parameters {:body ::create-project|body}
   :validation :spec}
  [{:keys [user parameters] :as req}]
  (let [data (get parameters :body)
        message (assoc data :type :create-project :user user)]
