Joy is a full stack web framework written in janet
(use joy)
(route :get "/" :home)
(defn home [request]
(text/plain "You found joy!"))
(def app (app))
(server app 9001)
First make sure janet is installed
Next, install the joy cli like this
jpm install joy
Hopefully the joy
executable will be on your path and ready to roll. If it isn't and you're like me and use homebrew, add this to your .zprofile
:
export PATH=/usr/local/Cellar/janet/<your janet version here>/bin:$PATH
Then make sure you reload the profile:
source ~/.zprofile
Now, run the following from your terminal
joy new my-joy-project
This should create a new directory called my-joy-project
and it should create a few files and things
to get you started.
Now that we have a project set up, it's time to test it out in the browser:
joy server
This should start an http server that's listening at http://localhost:9001.
Next, let's create a database, a table and connect it with routes and a few functions for handling requests.
If you aren't already in the my-joy-project
directory, go ahead and get in there. Now run
joy create db
This creates a new empty database named dev.sqlite3
.
The default template doesn't assume you want a database so you'll need to connect to it in main.janet
:
; # main.janet
(