<commit_before>(ns coffee-table.component.web-server
  (:require [bidi.vhosts :refer [vhosts-model]]
            [schema.core :as s]
            [coffee-table.component.visits :refer [visit-routes]]
            [com.stuartsierra.component :as component]
            [yada.yada :as yada]
            [taoensso.timbre :as timbre]))

(timbre/refer-timbre)

(s/defn routes
  "Create the URI route structure for our application."
  [visits]
  [""
   [
    ["/hello" (yada/handler "Hello World")]
    ["/api" [(visit-routes visits)]]
    [true (yada/handler nil)]]])

(s/defrecord WebServer [host port visits listener]
  component/Lifecycle
  (start [component]
    (if listener
      component ; idempotence
      (let [vhosts-model (vhosts-model [{:scheme :http :host host} (routes visits)])
            listener (yada/listener vhosts-model {:port port})]<commit_msg>Add swagger to API endpoints<commit_after>(ns coffee-table.component.web-server
  (:require [bidi.vhosts :refer [vhosts-model]]
            [schema.core :as s]
            [coffee-table.component.visits :refer [visit-routes]]
            [com.stuartsierra.component :as component]
            [yada.yada :as yada]
            [yada.swagger :refer [swaggered]]
            [taoensso.timbre :as timbre]))

(timbre/refer-timbre)

(s/defn routes
  "Create the URI route structure for our application."
  [visits]
  [""
   [
    ["/api" (swaggered (visit-routes visits)
                       {:info {:title "Visits"
                               :version "1.0"
                               :description "A visits service"}
                        :basePath "/api"})]
    [true (yada/handler nil)]]])

(s/defrecord WebServer [host port visits listener]
  component/Lifecycle
  (start [component]
    (if listener
      component ; idempotence
      (let [vhosts-model (vhosts-model [{:scheme :http :host host} (routes visits)])
            listener (yada/listener vhosts-model {:port port})]
{'fraction_non_alphanumeric': 0.13165983606557377, 'fraction_numerical': 0.0010245901639344263, 'mean_word_length': 2.402439024390244, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7478219', 'n_tokens_mistral': 626, 'n_tokens_neox': 618, 'n_words': 154}