Releases: coast-framework/coast
No Brainer (cont.)
Changes
- 19262fe - Add css and js minification and cache busting
- 994f8fe - Take out old sentence
- eebb444 - Race car in structure
- bd76ca7 - Fix typos in Structure
- da9adf4 - Handle one rels in pull queries
- 87764a4 - Always wrap content type and not modified
- 9c798bb - Don't try to parse args in db errors
Handle one rels in pull queries
This is probably an understatement to just let this one sit there as a commit message. Here's an example that shows off the potency of this change:
(db/pull [:post/title :post/body :post/published-at
{:post/author [:author/name]}]
[:post/id 1]
WHOA NELLY 🐴 that's some sweet foreign key action.
Add css and js minification and cache busting
This is another one that I've been meaning to get to and I finally did. This commit single-handedly adds js and css minification and cache busting in prod all at once. Here's how it works
(ns your-proj
(:require [coast.zeta :as coast]
[coast.components :refer [css js]]))
(def routes [[:get "/" `home]])
(defn layout [req body]
[:html
[:head
(css req "bundle.css")]
[:body
(js req "bundle.js")]])
(def opts {:layout layout
:assets {"bundle.css" ["tachyons.min.css" "app.css"]
"bundle.js" ["jquery.min.js" "app.js"]}})
(def app (coast/app routes opts))
(defn -main [& [port]]
(coast/server app {:port port}))
when the COAST_ENV=prod
env variable is set, it concats, minifies and md5's the files that you list in assets and serves up one file with an md5 of the contents on app startup, so it's always fresh ✨. When COAST_ENV=dev
it just serves them separately and doesn't do anything fancy. You can also separate your files any way you want and you can create as many bundles as you want, just make sure your bundle names are valid file names "bundle.js", "app.js", "hello.css", etc.
This release seems minor but it's kind of a huge step towards finally being an all-in-one clojure web framework to rival what other language communities have had for over a decade.
Mansion
No Brainer
- f3fdd5f - Add wrap-file middleware
- c206335 - Add app namespace which wraps common functions
- 973ecf0 - Add a
time/since
function - f41e6a5 - Turn env into a function
- 82650ab - Send the rest of the server opts along
- e34c9a3 - This commit is a lot of db-related things
- bfd9291 - Run sql and edn migrations in order side by side
- b983886 - Update docs
- 9b2b479 - Add potemkin
- 7fadd65 - Prep docs for eta
- 9639df5 - Updated README @julioberina
- 5625b96 - Modify coast script sed command @ julioberina
- fa7f8ed - Add breakline @julioberina
- 5febe14 - Update README @julioberina
Nested inserts and deletes
And it works like this:
(db/transact {:maker/email "test@test.com"
:maker/name "test"
:maker/todos [{:todo/text "Get transact inserting with rels ✅"}
{:todo/text "Show it off on twitter ✅"}]})
You can also delete all of the nested records in one fell swoop
(db/transact {:maker/email "test@test.com"
:maker/name "test"
:maker/todos []})
Bugfixes & Improvements
- 237401d - Get wrap-reload working
Bug fixes & Improvements
Had the darndest time trying to get columns and tables with dashes working across pull, q, and transact. Finally figured out that I had to put the jdbc extension in a namespace that is required by another namespace for uberjarring.
So kebab to snake case and back again works now 🎉
Bugfixes & Improvements
- 03f3fab - Parse default postgres timestamptz strings
- 13e14e9 - Format offsetdatetime or localdatetime
- f4a917e - Change action-for to take an ident not just a kw
- 7d243cc - Fix bug where delete wouldn't delete
- 69710ec - Fix bug where updated_at wouldn't update on upsert
- 7aac4f3 - Fix bug with > 1 ident cols and db/transact
- 38a434d - Fix bug with multiple cols in the same mig/table
- a594069 - Get rid of trailing spaces in edn mig sql
Bugfixes & Improvements
Bug fixes & improvements
My hack to get routes resolving in uberjars wound up with a bug where I didn't handle middleware in routes. This handles that handles uberjars
It's too late to apologize
coast.zeta.1.3.0
- Fix a bug where no routes would resolve in an uberjar
- Add raise/rescue for application level error handling (i.e. ex-info)
- Perf improvements in validation
Here's an example how to use raise/rescue (which was shamelessly stolen from ruby)
(raise {:extra "info goes here"})
And here is how they work together:
(let [[_ m]
(rescue (raise {:message "Oh no! 😱"}))])
; (= m {:message "Oh no! 😱"})
Coast uses this internally so something like this is now possible
(ns author
(:require [coast.db :as db]
[coast.error :refer [rescue]]
[coast.responses :as res]
[routes :refer [url-for]))
(defn _new [req]
; pretend there's some form html here
)
(defn encrypt-password [params]
; pretend there's an encryption function here
params)
(defn create [req]
(let [[_ errors] (-> (:params req)
(v/validate [[:required [::nickname ::email ::password]]
[:equal [::password ::password-confirmation]
"Password and confirmation password do not match"]
[:min-length 12 ::password]])
(select-keys [::nickname ::email ::password])
(encrypt-password)
(db/transact)
(rescue))]
(if (nil? errors)
(-> (res/redirect (url-for :home/index))
(res/flash "Welcome to coast!"))
(_new (assoc req :errors errors)))))
Validation errors and database errors are now unified (again)! 🙌