lein new duct オプションによる違い

2022-02-10

「 無し」と「+api」との違い

project.clj

@@ -4,7 +4,8 @@
   :min-lein-version "2.0.0"
   :dependencies [[org.clojure/clojure "1.10.3"]
                  [duct/core "0.8.0"]
-                 [duct/module.logging "0.5.0"]]
+                 [duct/module.logging "0.5.0"]
+                 [duct/module.web "0.7.3"]]
   :plugins [[duct/lein-duct "0.12.3"]]
   :main ^:skip-aot duct-test.main
   :resource-paths ["resources" "target/resources"]
@@ -20,4 +21,5 @@
                   :resource-paths ["dev/resources"]
                   :dependencies   [[integrant/repl "0.3.2"]
                                    [hawk "0.2.11"]
-                                   [eftest "0.5.9"]]}})
+                                   [eftest "0.5.9"]
+                                   [kerodon "0.9.1"]]}})

duct module.web

Duct module that adds a web server and useful middleware to a configuration. This is the basis of all web applications built with Duct.

(google翻訳)
Webサーバーと便利なミドルウェアを構成に追加するダクトモジュール。これは、Ductで構築されたすべてのWebアプリケーションの基礎です。

kerodon

kerodon is an interaction and testing library for ring html based apps.It is intended to look like the interaction a user would have. 

(google 翻訳)
kerodonは、ring HTMLベースのアプリ用のインタラクションおよびテストライブラリです。これは、ユーザーが行うインタラクションのように見えることを目的としています。

config.edn

@@ -1,8 +1,12 @@
 {:duct.profile/base
- {:duct.core/project-ns duct-test}
+ {:duct.core/project-ns duct-test
+
+  :duct.router/cascading []}

  :duct.profile/dev   #duct/include "dev"
  :duct.profile/local #duct/include "local"
  :duct.profile/prod  {}

- :duct.module/logging {}}
+ :duct.module/logging {}
+ :duct.module.web/api
+ {}}

フォルダ

handler フォルダが自動生成。

「+api」と「+site」との違い

config.edn

@@ -8,5 +8,5 @@
  :duct.profile/prod  {}

  :duct.module/logging {}
- :duct.module.web/api
+ :duct.module.web/site
  {}}

「+api」と「+api +ataraxy」との違い

「+ataraxy」を指定しない時のルーティングライブラリはCompojure。

project.clj

@@ -4,6 +4,7 @@
   :min-lein-version "2.0.0"
   :dependencies [[org.clojure/clojure "1.10.3"]
                  [duct/core "0.8.0"]
+                 [duct/module.ataraxy "0.3.0"]
                  [duct/module.logging "0.5.0"]
                  [duct/module.web "0.7.3"]]
   :plugins [[duct/lein-duct "0.12.3"]]

duct module.ataraxy

A Duct module that sets Ataraxy as the router for your application.

(google翻訳)Ataraxyをアプリケーションのルーターとして設定するダクトモジュール。

config.edn

@@ -1,7 +1,8 @@
 {:duct.profile/base
  {:duct.core/project-ns duct-test

-  :duct.router/cascading []}
+  :duct.router/ataraxy
+  {:routes {}}}

  :duct.profile/dev   #duct/include "dev"
  :duct.profile/local #duct/include "local"

「+sqlite」と「+postgres」の違い

project.clj

:dependencies [[org.clojure/clojure "1.10.3"]
               ……
               ;sqlite の場合
               [org.xerial/sqlite-jdbc "3.34.0"]
               ;postgres の場合
               [org.postgresql/postgresql "42.2.19"]

/dev/resources/dev.edn

{:duct.database/sql
 ;sqlite の場合
 {:connection-uri "jdbc:sqlite:db/dev.sqlite"}
 ;postgres の場合
 {:connection-uri "jdbc:postgresql://localhost/postgres"}

.gitignore

  /dev/src/local.clj
+ /db/dev.sqlite