<commit_before>(ns made-merits.handler
  (:require [compojure.core :refer [routes wrap-routes]]
            [made-merits.layout :refer [error-page]]
            [made-merits.routes.leaderboard :refer [leaderboard-routes]]
            [made-merits.routes.merits :refer [merits-routes]]
            [compojure.route :as route]
            [ring.middleware.basic-authentication :refer [wrap-basic-authentication]]
            [made-merits.env :refer [defaults]]
            [mount.core :as mount]
            [made-merits.middleware :as middleware]))

(mount/defstate init-app
                :start ((or (:init defaults) identity))
                :stop  ((or (:stop defaults) identity)))

 (defn authenticated? [name pass]
  (and (= name (System/getenv "HTTP_USERNAME"))
       (= pass (System/getenv "HTTP_PASSWORD"))))

(def app-routes
  (routes
    (-> #'merits-routes
        (wrap-routes middleware/wrap-csrf)
        (wrap-basic-authentication authenticated?)
        (wrap-routes middleware/wrap-formats))
    (-> #'leaderboard-routes
        (wrap-basic-authentication authenticated?)
        (wrap-routes middleware/wrap-formats))
    (route/not-found
      (:body
        (error-page {:status 404
                     :title "page not found"})))))


(defn app [] (middleware/wrap-base #'app-routes))<commit_msg>Only password protect the merits, leaderboard is fine.<commit_after>(ns made-merits.handler
  (:require [compojure.core :refer [routes wrap-routes]]
            [made-merits.layout :refer [error-page]]
            [made-merits.routes.leaderboard :refer [leaderboard-routes]]
            [made-merits.routes.merits :refer [merits-routes]]
            [compojure.route :as route]
            [ring.middleware.basic-authentication :refer [wrap-basic-authentication]]
            [made-merits.env :refer [defaults]]
            [mount.core :as mount]
            [made-merits.middleware :as middleware]))

(mount/defstate init-app
                :start ((or (:init defaults) identity))
                :stop  ((or (:stop defaults) identity)))

 (defn authenticated? [name pass]
  (and (= name (System/getenv "HTTP_USERNAME"))
       (= pass (System/getenv "HTTP_PASSWORD"))))

(def app-routes
  (routes
    (-> #'merits-routes
        (wrap-routes middleware/wrap-csrf)
        (wrap-routes middleware/wrap-formats))
    (-> #'leaderboard-routes
        (wrap-basic-authentication authenticated?)
        (wrap-routes middleware/wrap-formats))
    (route/not-found
      (:body
        (error-page {:status 404
                     :title "page not found"})))))


(defn app [] (middleware/wrap-base #'app-routes))
{'fraction_non_alphanumeric': 0.14106463878326997, 'fraction_numerical': 0.0022813688212927757, 'mean_word_length': 2.5220883534136544, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7368276', 'n_tokens_mistral': 824, 'n_tokens_neox': 819, 'n_words': 168}