Skip to content

Commit

Permalink
Merge pull request #3 from parenthesin/fix/license-add-badge
Browse files Browse the repository at this point in the history
fix: license & badge & schema/malli dependencies
  • Loading branch information
rafaeldelboni authored Apr 22, 2023
2 parents 64f1861 + a00a787 commit ead44e0
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 35 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# parenthesin/components
[![Clojars Project](https://img.shields.io/clojars/v/com.github.parenthesin/components.svg)](https://clojars.org/com.github.parenthesin/components)

Common components used on the Parenthesin's service templates.

# Components
Expand All @@ -14,6 +16,11 @@ Depends on config component to read [connection info data](test/resources/config
### Libraries
- [next-jdbc](https://github.com/seancorfield/next-jdbc)
- [hikaricp](https://github.com/brettwooldridge/HikariCP)
### In addition, you will need to add dependencies for the JDBC drivers you wish to use for whatever databases you are using. For example:
MySQL: mysql/mysql-connector-java {:mvn/version "8.0.19"} (search for latest version)
PostgreSQL: org.postgresql/postgresql {:mvn/version "42.2.10"} (search for latest version)
Microsoft SQL Server: com.microsoft.sqlserver/mssql-jdbc {:mvn/version "8.2.1.jre8"} (search for latest version)
Sqlite: org.xerial/sqlite-jdbc {:mvn/version "3.39.2.1"} (search for latest version)

## [http/clj-http](src/parenthesin/components/http/clj_http.clj)
Has some [mock implementations](test/unit/parenthesin/components/http/clj_http_test.clj) for tests
Expand Down Expand Up @@ -60,6 +67,11 @@ Function to start / stop instrumentation as `clojure.test/use-fixtures`
Wrapper over migratus to create an CLI based API.
Depends on aero and jdbc to read and connect to the database.

### Projects using this library
These projects are using the library, they can be used as templates or source of documentation of how use the components.
- [parenthesin/microservice-boilerplate](https://github.com/parenthesin/microservice-boilerplate)
- [parenthesin/microservice-boilerplate-malli](https://github.com/parenthesin/microservice-boilerplate-malli)

# Contributing

## Tests
Expand Down
8 changes: 3 additions & 5 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
aero/aero {:mvn/version "1.1.6"}
cheshire/cheshire {:mvn/version "5.11.0"}
clj-http/clj-http {:mvn/version "3.12.3"}
com.github.seancorfield/honeysql {:mvn/version "2.4.1011"}
com.github.seancorfield/next.jdbc {:mvn/version "1.3.865"}
com.stuartsierra/component {:mvn/version "1.1.0"}
com.taoensso/timbre {:mvn/version "6.1.0"}
Expand All @@ -18,14 +17,13 @@
metosin/reitit-swagger {:mvn/version "0.6.0"}
metosin/reitit-swagger-ui {:mvn/version "0.6.0"}
migratus/migratus {:mvn/version "1.4.9"}
org.postgresql/postgresql {:mvn/version "42.6.0"}
org.slf4j/slf4j-simple {:mvn/version "2.0.7"}
prismatic/schema {:mvn/version "1.4.1"}
prismatic/schema-generators {:mvn/version "0.1.5"}}
prismatic/schema {:mvn/version "1.4.1"}}

:aliases
{:test {:extra-paths ["test" "test/resources"]
:extra-deps {org.clojars.bigsy/pg-embedded-clj {:mvn/version "1.0.0"}
:extra-deps {org.postgresql/postgresql {:mvn/version "42.6.0"}
org.clojars.bigsy/pg-embedded-clj {:mvn/version "1.0.0"}
lambdaisland/kaocha {:mvn/version "1.82.1306"}
lambdaisland/kaocha-cloverage {:mvn/version "1.1.89"}
nubank/matcher-combinators {:mvn/version "3.8.5"}
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<url>https://github.com/parenthesin/components</url>
<licenses>
<license>
<name>Eclipse Public License</name>
<url>http://www.eclipse.org/legal/epl-v10.html</url>
<name>Unlicense</name>
<url>https://unlicense.org</url>
</license>
</licenses>
<developers>
Expand Down
19 changes: 10 additions & 9 deletions src/parenthesin/components/http/clj_http.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
(:require [clj-http.client :as http]
[clj-http.util :as http-util]
[com.stuartsierra.component :as component]
[parenthesin.helpers.logs :as logs]
[schema.core :as s]))
[parenthesin.helpers.logs :as logs]))

(s/defschema HttpRequestInput
{:url s/Str
:method (apply s/enum #{:get :head :post :put :delete :options :copy :move :patch})
s/Any s/Any})
(defn request-fn
"Accepts :req which should be a map containing the following keys:
:url - string, containing the http address requested
:method - keyword, contatining one of the following options:
#{:get :head :post :put :delete :options :copy :move :patch}
(s/defn request-fn
[{:keys [url] :as req} :- HttpRequestInput
& [respond raise]]
The following keys make an async HTTP request, like ring's CPS handler.
* :respond
* :raise"
[{:keys [url] :as req} & [respond raise]]
(http/check-url! url)
(if (http-util/opt req :async)
(if (some nil? [respond raise])
Expand Down
6 changes: 1 addition & 5 deletions test/integration/parenthesin/db/jdbc_hikari_test.clj
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
(ns integration.parenthesin.db.jdbc-hikari-test
(:require [clojure.test :as clojure.test]
[com.stuartsierra.component :as component]
(:require [com.stuartsierra.component :as component]
[integration.parenthesin.util :as util]
[parenthesin.components.config.aero :as components.config]
[parenthesin.components.db.jdbc-hikari :as components.db]
[parenthesin.helpers.state-flow.db :as state-flow.db]
[schema.test :as schema.test]
[state-flow.api :refer [defflow]]
[state-flow.assertions.matcher-combinators :refer [match?]]
[state-flow.core :as state-flow :refer [flow]]))

(clojure.test/use-fixtures :once schema.test/validate-schemas)

(defflow
flow-integration-database-test
{:init (util/start-system!
Expand Down
5 changes: 1 addition & 4 deletions test/integration/parenthesin/util.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns integration.parenthesin.util
(:require [com.stuartsierra.component :as component]
[malli.dev :as dev]
[parenthesin.helpers.logs :as logs]
[pg-embedded-clj.core :as pg-emb]))

Expand All @@ -13,13 +12,11 @@
(defn start-system!
[components]
(fn []
(dev/start!)
(logs/setup :debug :auto)
(pg-emb/init-pg)
(create-and-start-components! components)))

(defn stop-system!
[system]
(component/stop-system system)
(pg-emb/halt-pg!)
(dev/stop!))
(pg-emb/halt-pg!))
7 changes: 2 additions & 5 deletions test/unit/parenthesin/components/config/aero_test.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
(ns unit.parenthesin.components.config.aero-test
(:require [clojure.test :refer [deftest is testing use-fixtures]]
(:require [clojure.test :refer [deftest is testing]]
[com.stuartsierra.component :as component]
[matcher-combinators.test :refer [match?]]
[parenthesin.components.config.aero :as config.aero]
[schema.test :as schema.test]))

(use-fixtures :once schema.test/validate-schemas)
[parenthesin.components.config.aero :as config.aero]))

(defn- create-and-start-system!
[{:keys [config]}]
Expand Down
7 changes: 2 additions & 5 deletions test/unit/parenthesin/components/http/clj_http_test.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
(ns unit.parenthesin.components.http.clj-http-test
(:require [clojure.test :refer [deftest is testing use-fixtures]]
(:require [clojure.test :refer [deftest is testing]]
[com.stuartsierra.component :as component]
[matcher-combinators.test :refer [match?]]
[parenthesin.components.http.clj-http :as http.clj-http]
[schema.test :as schema.test]))

(use-fixtures :once schema.test/validate-schemas)
[parenthesin.components.http.clj-http :as http.clj-http]))

(defn- create-and-start-system!
[{:keys [http]}]
Expand Down

0 comments on commit ead44e0

Please sign in to comment.