diff --git a/Dockerfile b/Dockerfile index 19cc3e8..ab47695 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,7 @@ RUN apk add curl rlwrap WORKDIR /app COPY deps.edn ./ RUN clj -P +RUN clj -Spath COPY build.clj config.edn ./ COPY src ./src diff --git a/src/micro_blog/api.clj b/src/micro_blog/api.clj index f1db175..38262e1 100644 --- a/src/micro_blog/api.clj +++ b/src/micro_blog/api.clj @@ -1,32 +1,34 @@ (ns micro-blog.api (:require [io.pedestal.connector :as conn] [io.pedestal.http.http-kit :as hk] + [micro-blog.config :refer [config]] micro-blog.mastodon micro-blog.blue-sky [taoensso.telemere :as tel])) -(defn mastodon-proc-handler [] - (tel/log! :info "Procing Mastodon Scrape") - (micro-blog.mastodon/run) - {:status 200 - :body "Scraped Mastodon\n"}) +(defn mastodon-proc-handler [_request] + (let [msg "Proceding Mastodon Scrape"] + (tel/log! :info msg) + (micro-blog.mastodon/run) + {:status 200 + :body msg})) -(defn blue-sky-proc-handler [] - (tel/log! :info "Procing BlueSky Scrape") +(defn blue-sky-proc-handler [_request] + (let [msg "Procing BlueSky Scrape"] + (tel/log! :info msg) (micro-blog.mastodon/run) {:status 200 - :body "Scraped Mastodon\n"}) + :body msg})) (def routes #{["/bluesky" :get blue-sky-proc-handler :route-name :blue-sky] ["/mastodon" :get mastodon-proc-handler :route-name :mastodon]}) (defn create-connector [] - (-> (conn/default-connector-map 8890) + (-> (conn/default-connector-map (:api-host @config) (Integer/parseInt (str (:api-port @config)))) (conn/with-default-interceptors) (conn/with-routes routes) (hk/create-connector nil))) (defn start [] - ;; (log/info :in 'start :msg "Starting Pedestal server with Telmere logging") (conn/start! (create-connector))) diff --git a/src/micro_blog/config.clj b/src/micro_blog/config.clj index 7b15275..51528e3 100644 --- a/src/micro_blog/config.clj +++ b/src/micro_blog/config.clj @@ -6,7 +6,9 @@ :blue-sky-api-key "BLUE_SKY_API_KEY" :minstral-api-key "MISTRAL_API_KEY" :mastodon-host "MASTODON_BASE_URL" - :mastodon-account-id "MASTODON_ACCOUNT_ID"}) + :mastodon-account-id "MASTODON_ACCOUNT_ID" + :api-host "API_HOST" + :api-port "API_PORT"}) (defn- load-config [] (merge (read-string (slurp "config.edn"))