joy-framework / joy Goto Github PK
View Code? Open in Web Editor NEWA full stack web framework written in janet
Home Page: https://joy.swlkr.com
License: MIT License
A full stack web framework written in janet
Home Page: https://joy.swlkr.com
License: MIT License
When you try and create a <script src="/app.js" type="module">
joy has no idea what content-type it is. It should be 'application/js' but is getting no type. To reproduce:
Take your default scaffolding, and update layout.janet to this:
(import joy :prefix "")
(defn app [{:body body :request request}]
(text/html
(doctype :html5)
[:html {:lang "en"}
[:head
[:meta {:charset "utf-8"}]
[:meta {:name "viewport" :content "width=device-width, initial-scale=1"}]
[:meta {:name "csrf-token" :content (authenticity-token request)}]
[:link {:href "/app.css" :rel "stylesheet"}]
[:title "test"]]
[:body
body
[:script {:src "/app.js" :type "module"}]]]))
The HTML output is dead right. If you could show me where to make that update I'd be game. I just was not seeing a place that was obvious to me, as I'm currently just learning janet.
Here maybe?
This should be a real function
https://github.com/joy-framework/joy/blob/master/src/joy/router.janet#L124
Hey, just thought I'd leave a friendly note that since Circlet is built on Mongoose, which is GNU GPL licensed, MIT isn't an appropriate license for this project. Do leave a comment if you find an MIT-licensed http server in/for Janet, as that is something I'm interested in.
Hey, nice project, just a small thing: If I send a request to a path like /home?name=something
It would be nice if the request handler could parse the query params into the map. I can see there is a :params struct which is empty, perhaps have another srtuct called :query for easy access to these things? e.g.
:query @{"name" "something"}
<migration-name>
<route-name>
(based on a table in the database)<table-name> '<column definition>' '<column definition>'
(creates a migration with a create table statement)Just not sure. Usually there is some remark where should I get my path but not the script here?
joy add auth table <table>
joy add auth routes <table>
the routes command creates two route files, sessions.janet and <table>.janet
along with common functions for auth and it updates your routes file with defroutes private
<table>
will be the name of the table responsible for authenticating people (accounts, users, whatever)
when you (import auth)
you have access to the default auth middleware (auth)
which should prevent users from accessing anything without [:session :<table> :id]
Generate table <table>
with fields email
, last-sign-in-at
, code
, code-created-at
Send magic link email
Generate a middleware file for checking authentication
- [ ] Generate table <table>
with fields email
, password
, last-sign-in-at
, reset-password-token
, reset-password-token-expires-at
- [ ] Generate session and <table>
routes with sign up/in/out + forgot/reset password functions
- [ ] Generate a reset password "mailer" file
- [ ] Generate a middleware file for checking authentication
- [ ] Send reset password emails
- [ ] Two factor auth
[:p "Powered by" [:a {:href "https://www.w3schools.com/w3css/default.asp" :title "W3.CSS" :target "_blank" :class "w3-hover-text-blue"} "W3.CSS"]]
This code doesn't create: Powered by W3.CSS <-- with the last part as a link
Only output is : Powered by
link is blank
What am I doing wrong here?
and What is poolparty?
Enjoying the framework Thanks!
This will work similarly to what's in coast now
https://github.com/coast-framework/error/blob/master/src/error/core.clj#L5-L28
Hi there,
Keen to give this a go! Running on Ubuntu. The install for janet and joy seemed to go just fine, however I can't run this from the command line. Is there a path you could suggest? I've tried adding this, but I don't think its the right file:
export PATH="/usr/local/lib/janet/bin:$PATH"
thanks!
or since that's probably too hard, update all of the sql functions to snake case every column and then in db/execute
snake case the params
dictionary
Hello, I have an issue with installation vis jpm - here are the last few lines of the output:
Installed as 'tester'.
copying src/tester.janet to /usr/local/Cellar/janet/1.9.0/lib/janet...
From https://github.com/joy-framework/dotenv
* branch master -> FETCH_HEAD
Already up-to-date.
no dependencies found
removing /usr/local/Cellar/janet/1.9.0/lib/janet/dotenv.janet
removing /usr/local/Cellar/janet/1.9.0/lib/janet/.manifests/dotenv.jdn
Uninstalled.
generating /usr/local/Cellar/janet/1.9.0/lib/janet/.manifests/dotenv.jdn...
Installed as 'dotenv'.
copying dotenv.janet to /usr/local/Cellar/janet/1.9.0/lib/janet...
removing /usr/local/bin/joy
Error building git repository dependency: No such file or directory: /usr/local/bin/joy
This one: andrewchambers/janet-logfmt
Hi.
Can you add support for UNIX socket?
Thank you.
It's probably going to wind up looking something like this:
├── app.janet
├── project.janet
├── public
│ ├── app.js
│ ├── app.css
├── test
│ └── app-test.janet
└── watch
Where app.janet
looks like this:
(use joy)
(defn layout [{:body body :request request}]
(text/html
(doctype :html5)
[:html {:lang "en"}
[:head
[:title "new project"]
[:meta {:charset "utf-8"}]
[:meta {:name "viewport" :content "width=device-width, initial-scale=1"}]
(link {:href ["/app.css"]})
(script {:src ["/app.js"] :defer ""})]
[:body
body]]))
(defn home [request]
[:h1 "You found joy!"])
(def routes (routes [:get "/" home]))
(def app (app {:layout layout}))
(server app 9001)
joy create route
fails with the error:
error: bad slot #1, expected string|symbol|keyword|buffer, got nil
in file/write
in <anonymous> [/usr/local/Cellar/janet/1.8.1/lib/janet/joy/cli/routes.janet] on line 112, column 7
in create [/usr/local/Cellar/janet/1.8.1/lib/janet/joy/cli/routes.janet] (tailcall) on line 111, column 5
because route-string
is returning nil
. Adding a few print statements to create
:
(print "Table Name: " table-name)
(print "Route String: " route-textstring)
right after the let
results in:
% joy create route account
Table Name: account
Route String: nil
I don't know Janet, but it looks like columns
goes out of scope before the end of the function.
Anyhow, what am I missing?
Similar to url-for
here
https://github.com/joy-framework/joy/blob/master/src/joy/router.janet#L120
These could be very similar to the coast versions here
https://github.com/coast-framework/router/blob/master/src/router/core.clj#L191-L207
compile error: unknown symbol "id" on line 28, column 23 while compiling src/routes/account.janet
compile error: unknown symbol "account/index" on line 8, column 3 while compiling src/routes.janet
compile error: unknown symbol "routes/app" on line 6, column 14 while compiling src/app.janet
compile error: unknown symbol "app" on line 4, column 1 while compiling main.janet
Following https://github.com/joy-framework/joy/blob/master/docs/tutorial.md . After creating db, running migration and creating route, server fails to start.
Similar to https://github.com/coast-framework/template
Just like the title says switch to h2o from mongoose for the MIT license
https://powerdns.org/libh2o/#hello,andwelcometolibh2o
related to #5
This should probably be a separate project, similar to circlet
I'd like to see this project build and publish docker containers, as well as run tests and code quality checks on each commit. I'm open to the idea I just really enjoy tooling and making stuff automated, and it's not needed in this project.
I was thinking we could use CircleCI or Travis, both have permanent free tiers for open source projects. Ideally the job flow would look like this:
I'm very happy to do this work, explain and document the release process, and steps in the CI config. I'm also going need you to create some accounts that the joy-org "owns", namely:
These can be safely obfuscated by you, and I can show you how to embed these values in either platform. If this seems like something you'd like, let me know and I'll get it knocked out for you!
If you like this we can talk about automated release management, and more. I think it's a good idea to try out the simple case first, see if there is any value for the project, and extend it at a future date.
If merged the MR would be two files:
There's nothing better than running a single command to get things onto the internet, I'm thinking something like
joy login # enter email/password
joy deploy # deploys to either your-project.joyframework.com or somewhere else
And since I hate pushing to a git repo and separately having to deploy the thing, set up a webhook url that deploys on a push to master
Hi,
When running
jpm install joy
I get
error: No such file or directory: nil\.cache
in os/mkdir
in mkdir [E:\Janet-1.9.1\bin\\jpm.janet] on line 145, column 3
in install-git [E:\Janet-1.9.1\bin\\jpm.janet] on line 687, column 3
in install-git [E:\Janet-1.9.1\bin\\jpm.janet] on line 678, column 11
in install [E:\Janet-1.9.1\bin\\jpm.janet] (tailcall) on line 1072, column 20
I do have git installed.
Followed the Getting Started in the readme and got an error after creating the account
route:
error: could not find module joy/db
Resolved by changing the import in src/routes/account.janet
:
- (import joy/db)
+ (import db)
Running on a Mac (Mojave 10.14.6). Joy Version: 0.7.2. Janet Version:1.8.1
Thanks 🙌🏻
Everything is ok now with the following schema
account table
id | name |
---|---|
3 | 'account 1' |
4 | 'account 2' |
todo table
id | name | account_id |
---|---|---|
1 | 'todo 1' | 3 |
2 | 'todo 2' | 3 |
(db/fetch [:account 3 :todo])
emits
select *
from todo
join account on account.id = todo.account_id
where account.id = 3
But if you try something else where the schema doesn't follow the convention where foreign key columns don't match the name of the table (account -> account_id), this doesn't work.
There's currently no way to specify this yet.
after finding joy, I tried based on sample script here but failed with:
joy server error: DATABASE_URL environment variable isn't set in connect [/usr/local/Cellar/janet/1.8.1/lib/janet/db/sqlite/db.janet] on line 10, column 5 in start [src/server.janet] (tailcall) on line 25, column 5 in _thunk [main.janet] on line -1, column -1 in cli-main [boot.janet] on line 2446, column 35
I persist and whilst the db creation all ok, it is obviously not working and the final to do joy server every command. This is the final output:
joy server error: could not find module joy/db: /usr/local/Cellar/janet/1.8.1/lib/janet/joy/db.jimage /usr/local/Cellar/janet/1.8.1/lib/janet/joy/db.janet /usr/local/Cellar/janet/1.8.1/lib/janet/joy/db/init.janet /usr/local/Cellar/janet/1.8.1/lib/janet/joy/db.so joy/db.jimage joy/db.janet joy/db/init.janet joy/db.so in require [boot.janet] on line 2211, column 20 in import* [boot.janet] on line 2229, column 15 in _thunk [src/routes/account.janet] (tailcall) on line 2, column 1 error: DATABASE_URL environment variable isn't set in connect [/usr/local/Cellar/janet/1.8.1/lib/janet/db/sqlite/db.janet] on line 10, column 5 in start [src/server.janet] (tailcall) on line 25, column 5 in _thunk [main.janet] on line -1, column -1 in cli-main [boot.janet] on line 2446, column 35
Any further help?
Right now when you put DATABASE_URL for PostgreSQL in .env
it won't work, because db
will still try to load sqlite3. This is because db
checks for a real ENV variable to determine database type and dotenv loader does not set real variable, I think. Perhaps it should? Or perhaps there should be some mandatory setup step in db
where you pass an URL?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.