This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-07
Channels
- # announcements (27)
- # babashka (29)
- # beginners (280)
- # calva (34)
- # cider (4)
- # circleci (11)
- # cljfx (10)
- # cljsrn (1)
- # clojure (526)
- # clojure-dev (9)
- # clojure-europe (42)
- # clojure-finland (5)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-taiwan (2)
- # clojure-uk (14)
- # clojurescript (40)
- # clr (43)
- # community-development (5)
- # css (4)
- # cursive (7)
- # duct (82)
- # events (1)
- # fulcro (72)
- # garden (44)
- # hoplon (3)
- # java (40)
- # jobs (4)
- # juxt (1)
- # luminus (53)
- # meander (13)
- # off-topic (26)
- # pathom (14)
- # pedestal (3)
- # portal (2)
- # rdf (3)
- # re-frame (54)
- # releases (10)
- # remote-jobs (3)
- # sci (74)
- # shadow-cljs (47)
- # startup-in-a-month (5)
- # testing (9)
- # tools-deps (73)
- # vim (12)
so I did change the file to this :
{:duct.profile/base
{:duct.core/project-ns todo
:duct.router/ataraxy
{:routes {[:get "/"] [:todo.handler/index]}}
[:duct.handler.static/ok :todo.handler/index]
{:body {:entries "/entries"}}}
:duct.migrator/ragtime
{:migrations [#ig/ref :todo.migration/create-entries]}
[:duct.migrator.ragtime/sql :todo.migration/create-entries]
{:up ["CREATE TABLE entries (id INTEGER PRIMARY KEY, content TEXT)"]
:down ["DROP TABLE entries"]}
:duct.profile/dev #duct/include "dev"
:duct.profile/local #duct/include "local"
:duct.profile/prod {}
:duct.module/logging {}
:duct.module.web/api
{}
:duct.module/sql
{}}
but now I see this error message
Execution error (IllegalArgumentException) at clojure.java.jdbc/get-connection (jdbc.clj:292).
db-spec null is missing a required parameter
I think you at least need to move :duct.migrator/ragtime
and [:duct.migrator.ragtime/sql :todo.migration/create-entries]
into the :duct.profile/base
map
Here is a fixed version:
{:duct.profile/base
{:duct.core/project-ns todo
:duct.router/ataraxy
{:routes {[:get "/"] [:todo.handler/index]}}
[:duct.handler.static/ok :todo.handler/index]
{:body {:entries "/entries"}}
:duct.migrator/ragtime
{:migrations [#ig/ref :todo.migration/create-entries]}
[:duct.migrator.ragtime/sql :todo.migration/create-entries]
{:up ["CREATE TABLE entries (id INTEGER PRIMARY KEY, content TEXT)"]
:down ["DROP TABLE entries"]}}
:duct.profile/dev #duct/include "dev"
:duct.profile/local #duct/include "local"
:duct.profile/prod {}
:duct.module/logging {}
:duct.module.web/api {}
:duct.module/sql {}}
the two keys I mentioned are now inside of the map of :duct.profile/base
, not in the top level map
it looks now this in vs code :
{:duct.profile/base
{:duct.core/project-ns todo :duct.router/ataraxy
{:routes {[:get "/"] [:todo.handler/index]}} [:duct.handler.static/ok :todo.handler/index]
{:body {:entries "/entries"}} :duct.migrator/ragtime
{:migrations [#ig/ref :todo.migration/create-entries]} [:duct.migrator.ragtime/sql :todo.migration/create-entries]
{:up ["CREATE TABLE entries (id INTEGER PRIMARY KEY, content TEXT)"]
:down ["DROP TABLE entries"]}} :duct.profile/dev #duct/include "dev" :duct.profile/local #duct/include "local" :duct.profile/prod {} :duct.module/logging {} :duct.module.web/api {} :duct.module/sql {}}
Hopefully it'll fix your error. Here's a small overview about the difference between base / profile / module configs https://github.com/duct-framework/duct/wiki/Configuration#duct-base-profiles-and-modules
hmm maybe a error in the tutorial
First, add a new POST route:
:duct.router/ataraxy
{:routes
{[:get "/"] [:todo.handler/index]
[:get "/entries"] [:todo.handler.entries/list]
[:post "/entries" {{:keys [description]} :body-params}]
[:todo.handler.entries/create description]}}
The new Ataraxy route not only matches the method and URI of the request, it also destructures the request body and places the description of the todo entry into the result.
When we come to write the associated handler, we need some way of getting the information from the result. Ataraxy places the result into the :ataraxy/result key on the request map, so we can destructure the request to find the description of the new entry:
[:duct.handler.sql/insert :todo.handler.entries/create]
{:request {[_ description] :ataraxy/result}
:sql ["INSERT INTO entries (description) VALUES (?)" description]}
because of this error message :
Missing definitions for refs: :todo.handlers.entries.create
Also I've never used sql handlers, I feel that it doesn't really give me enough control over my handlers
:dependencies [[org.clojure/clojure "1.10.0"]
[duct/core "0.7.0"]
[duct/handler.sql "0.4.0"]
[duct/module.logging "0.4.0"]
[duct/module.web "0.7.0"]
[duct/module.ataraxy "0.3.0"]
[duct/module.sql "0.5.0"]
[org.xerial/sqlite-jdbc "3.25.2"]]
Oh I see, you have :todo.handlers.entries.create
but I think that should be :todo.handlers.entries/create
The error is saying it can't find a key for :todo.handlers.entries.create
, which makes sense
now another problem not related to duct I think
http post :3000/entries description="Write Duct guide"
http: error: ConnectionError: HTTPConnectionPool(host='localhost', port=3000): Max retries exceeded with url: /entries (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7c4f0ff4f0>: Failed to establish a new connection: [Errno 111] Connection refused')) while doing POST request to URL:
(dev)
switches you to the development namespace (`dev.clj`). Afterwards to start the server you have to use (go)
and now the error re appears again
Execution error (ExceptionInfo) at integrant.core/missing-refs-exception (core.cljc:191).
Missing definitions for refs: :todo.handlers.entries/create
hmmm, and another wierd error:
{:duct.profile/base
{:duct.core/project-ns todo
:duct.router/ataraxy
{:routes {[:get "/"] [:todo.handler/index]
[:get "/entries"] [:todo.handler.entries/list]
[:post "/entries" {{:keys [description]} :body-params}]
[:todo.handler.entries/create description]
[:get "/entries/" id] [todo.handler.entries/find ^int id]
[:delete "entries/" id] [todo.handler.entries/destroy ^int id]}}
[:duct handler.sql/query-one :todo.handler.entries/find]
{:request {[_ id] :ataraxy/result}
:sql ["SELECT * FROM entries WHERE id = ?" id]
:hrefs {:href "entries/{id}"}}
[:duct.handler.sql/execute :todo.handler.entries/destroy]
{:request {[_ id] :ataraxy/result}
:sql ["DELETE FROM entries WHERE id =?" id]}
[:duct.handler.static/ok :todo.handler/index]
{:body {:entries "/entries"}}
[:duct.handler.sql/query :todo.handler.entries/list]
{:sql ["SELECT * FROM entries"]
:hrefs {:href "/entries/{id}"}}
[:duct.handler.sql/insert :todo.handler.entries/create]
{:request {[_ description] :ataraxy/result}
:sql ["INSERT INTO entries (description) VALUES (?)" description]
:location "entries/{last_insert_rowid}"}
:duct.migrator/ragtime
{:migrations [#ig/ref :todo.migration/create-entries]}
[:duct.migrator.ragtime/sql :todo.migration/create-entries]
{:up ["CREATE TABLE entries (id INTEGER PRIMARY KEY, description TEXT)"]
:down ["DROP TABLE entries"]}}
:duct.profile/dev #duct/include "dev"
:duct.profile/local #duct/include "local"
:duct.profile/prod {}
:duct.module/logging {}
:duct.module.web/api {}
:duct.module/sql {}}
reset)
:reloading ()
Execution error (AssertionError) at integrant.core/eval3789$fn (core.cljc:64).
Assert failed: (namespace parent)
The error is super cryptic (A bit of an Integrant issue). But I looks like you have a typo here: [:duct handler.sql/query-one :todo.handler.entries/find]
but now see this :
Execution error (AssertionError) at ataraxy.core/parse (core.clj:105).
Assert failed: (valid? routes)
There aren't many tutorials sadly. But be sure to understand how Integrant works https://github.com/weavejester/integrant/