Skip to content

Releases: coast-framework/coast

Improved postgres db creation!

31 Jul 20:20
Compare
Choose a tag to compare

Thanks to @nate !

From the commit:

The current db create make task wasn't using the db configuration
for anything but the db name and so the command would fail if it
required login or the db was on another host (like in docker).
These changes make it use values from the environment and then
fall back to using values from the config in order to specify
arguments to createdb.

Postgres env vars were borrowed from:
https://www.postgresql.org/docs/12/libpq-envars.html

🎉

404/500 Updates

24 Apr 16:26
Compare
Choose a tag to compare

coast.theta-1.5.0

A few things in this release:

  • You can now migrate/rollback the database schema from the coast cli in addition to using make
  • The template has changed a little bit, :home/index is now in :site.home/index
  • 404 and 500 pages are now just plain html by default although the old :home/not-found and :home/server-error fns still work

Migration changes

Instead of typing make db/migrate and make db/rollback into the terminal to migrate the schema, you can now use the coast cli like this:

coast db migrate

or

coast db rollback

Unification!

Default fn location

There are now two folders in src when you create a new coast app: site and api. This makes it clearer which routes do which stuff whereas before only api fns was in an api folder.

404/500 html files

Before 404 and 500 routes were actually defined in the routes.clj file, then they were removed in favor of convention even though the functions were still in the same place. Now they're just static html files in public that also follow convention.

A little json request body help

06 Apr 20:33
Compare
Choose a tag to compare

A small update, but a useful update.

Coast now sets :raw-body as the unparsed json string on json requests in addition to :body with the parsed json.

Turn off the default logger and handy new functions

06 Apr 20:03
Compare
Choose a tag to compare

A lot of bug fixing surrounding middleware in this release along with a few nice additions:

with-prefix

Now instead of prefix-routes you can use with-prefix to prefix your routes with a given url prefix like so:

(coast/with-prefix "/api"
  [:get "/" :api/status])

Turn off the logger

You can now turn off the logger and substitute with your own logging middleware when you call coast/app:

(coast/app {:routes routes :logger false})

content-type?

There is now a very useful content-type? fn available instead of having to get-in to request headers and compare with string/starts-with?:

(coast/content-type? {:headers {"content-type" "application/json"}} :json) ; => true

There were quite a few problems surrounding middleware and specifically api middleware which are now fixed 🎉. I don't want to blame ring-defaults it was probably my lack of understanding them that caused so much trouble. So now they don't exist anymore! Coast now essentially calls in every single ring middleware library on it's own and sets them up in a way so that they all work correctly depending on if you call coast/site, coast/api or just send coast a vector of routes.

Here's a list of all of the changes that went into 1.4.1

  • a45e501 - Delete unused slurp* fn
  • 571d3ec - Make sure html responses work without layoutw
  • df533f6 - Clean up tests
  • 94cebf5 - Only resolve keyword routes
  • eb6016a - Don't reverse middleware
  • 842cc9d - Clean up wrap-layout
  • d4a9de1 - Delete unused code
  • c22ef30 - Handle nil/blank json body
  • 6ff7d30 - Commit whitespace change
  • ba5f7a9 - Add ability to turn off/substitute log fn
  • 4e0b1c2 - Add much needed, high level route tests
  • 882cabb - Tighten up middleware ring responses
  • 78cd61a - Reorganize middleware
  • 5c199d5 - Add with-prefix
  • 2e46ee5 - Update request/response docs
  • 674fc40 - Fix json body parsing
  • 8aa89f1 - Update upgrading doc
  • 9a0eeea - Fix up middleware ordering
  • 4151a86 - Much better separation between site/api routes
  • 1fb46ef - Add content-type? fn
  • 23f7089 - Get db/first! working

Database Transactions 🤝

28 Mar 15:29
Compare
Choose a tag to compare

There's one huge thing that's been missing from the database side of things and that's database transactions, there wasn't an easy way to do it using coast's existing database functions until now!

Here's how it works:

(coast/transaction connection
  (coast/insert connection {:customer/first-name "Johnny" :customer/last-name "Appleseed"})
  (coast/insert connection {:customer/first-name "Cody", :customer/last-name "Coast"}))

And both of those will either succeed or the whole transaction will fail. There's a new parameter in every coast function, including: q, pluck, fetch, insert, update, and delete.

Thanks to transactions, insert and update now return the inserted/updated row across both sqlite and postgresql!

Delete still returns the number of deleted rows though.

There were a few other improvements, there's now a new fn that checks a request for the X-Requested-With header:

(let [request {:headers {"x-requested-with" "XMLHttpRequest"}}]
  (coast/xhr? request))

That's cool.

There was also one other improvement to parsing json parameters if the content-type is application/json regardless if the route is a "site" route or an "api" route.

🎉

New names for things 🙌

23 Mar 18:31
Compare
Choose a tag to compare

Why is this a x.2.0 release instead of a bug fix release?

I'll tell you why.

Coast relies heavily on an old Clojure library named ring, which it's still a great way to develop web apps with Clojure to this day, but Coast inherited some of the language from ye olden days (2014).

Here's the breakdown, in addition to the last few releases which dramatically simplified the route middleware code and the app middleware code as well, this release changes a few things that may break you, so semantic versioning is out the window at this point, but, it's only one change.

Before, in routes.clj, site-routes used to take an optional layout fn, and then the routes, that's gone now. It only takes routes, so this:

(coast/site-routes :components/layout
  [:get "/" :home/index])

is now this:

(coast/site-routes
  (coast/with-layout
    [:get "/" :home/index]))

That's the breaking change, so if anyone out there is having trouble after updating, this is why.

Also, why did this change happen? I was working on the docs site and noticed that it's more difficult than it should be to change the page title based on some data in a route. That is no longer the case, you can now set a middleware before the layout function and assoc a new page title and it works out as expected.

On to the rest of the changes that aren't breaking:

site-routes is now site
api-routes is now api
wrap-with-layout is now with-layout
wrap-routes is now with

The old functions still exist though, but the newer functions have much better names.

Fix long-standing route middleware bugs

23 Mar 17:56
Compare
Choose a tag to compare

I'm not sure how far back these issues go, but coast is much, much better for it.

Quite a few speed up loops were removed surrounding site route middleware in this release.

Routing improvements 🧠

21 Mar 04:55
Compare
Choose a tag to compare

Determine whether or not routes are wrapped and handle optional var-args or nested route vectors much better!

Also, the parent middleware now runs before the child middleware when using wrap-routes

Bug fixes and improvements

19 Mar 04:57
Compare
Choose a tag to compare

Fix a bug from legacy resource route names

Bug fixes and improvements

19 Mar 04:40
Compare
Choose a tag to compare
  • Where clause generation simplification
  • Pluralize person to people instead of "persons"
  • Add [:resource :only [:index :view]] and [:resource :except [:index :view]] support to routes
  • Add (coast/find-by :table {:where "clause"}) function