Skip to content

Releases: coast-framework/coast

No Brainer (cont.)

14 Aug 07:17
Compare
Choose a tag to compare

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

14 Aug 06:52
Compare
Choose a tag to compare
  • b253903 - Add a code sample to README
  • 1c11a25 - Better errors for 1 or n unique constraints
  • 4752562 - Read .nrepl-port file when starting nrepl
  • 983506c - Update README
  • 642e3d0 - Got a little overzealous, delete missing docs
  • 4626d96 - Wrap tree in bash

No Brainer

08 Aug 06:41
Compare
Choose a tag to compare

Nested inserts and deletes

01 Aug 00:24
Compare
Choose a tag to compare

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

26 Jul 15:39
Compare
Choose a tag to compare
  • 237401d - Get wrap-reload working

Bug fixes & Improvements

30 Jul 02:12
Compare
Choose a tag to compare

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

24 Jul 14:53
Compare
Choose a tag to compare
  • 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

21 Jul 22:18
Compare
Choose a tag to compare
  • 31c5291 - Treat schema.edn like a resource, not a file
  • 5802d00 - Get 404 errors working again
  • 06c56da - Add :type back in to errors from first!
  • e84a3e8 - Rescue from specific errors
  • f623041 - Show all validation errors, not the first - whoopsies

Bug fixes & improvements

20 Jul 15:00
Compare
Choose a tag to compare

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

20 Jul 06:41
Compare
Choose a tag to compare

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)! 🙌