24 Commits

Author SHA1 Message Date
Bob Farrell
3882eba2f3 Clean up static params and init script 2024-06-09 11:13:33 +01:00
Bob Farrell
2d921a1c27 Add jetzig routes command
Output all current routes. Invokes `zig build jetzig:routes`.
2024-06-05 21:26:23 +01:00
Bob Farrell
a46bc0ed19 Test helpers
Add `jetzig test` command which runs build step `jetzig:test`.

Add `jetzig.testing` namespace which provides test helpers and a test
app.

Add tests to view generator (i.e. include tests for generated routes).
2024-06-03 21:56:32 +01:00
JSantoro
b7217593de Fixed jetzig generate layout from zmpl v1 syntax 2024-05-22 00:05:31 +02:00
Bob Farrell
65edd20092 Allow mailers to modify mail template params
Remove need to add all mail template params to view response data. This
was originally intended functionality but the wrong value was passed to
the `deliver` function, and no `data` argument was given, making it
cumbersome to create new values.
2024-05-05 20:04:57 +01:00
Bob Farrell
6b940e8a53 0.13 support
Add support for 0.13. For now, we can be compatible with both 0.12 and
0.13. We will drop 0.12 after a while.
2024-04-27 23:03:53 +01:00
Bob Farrell
47c35632b5 Email framework
Create mailers with `jetzig generate mailer <name>`. Mailers define
default values for email fields (e.g. subject, from address, etc.).
Mailers use Zmpl for rendering text/HTML parts.

Send an email from a request with `request.mail()`. Call
`deliver(.background, .{})` on the return value to use the built-in
mail job to send the email asynchronously.

Improve query/HTTP request body param parsing - unescape `+` and `%XX`
characters.
2024-04-21 21:00:03 +01:00
Bob Farrell
0c7a11497f Background jobs
Use in-memory KV store (JetKV) for simple job queue.

Build script generates an array of Zig modules in `src/app/jobs/` and
stores their name + run function (`run(allocator, params, logger)`).

View functions schedule jobs with arbitrary params.

Thread pool spawns a (configurable) number of workers and pops jobs from
the queue, then invokes the appropriate run function.
2024-04-15 18:12:40 +01:00
Bob Farrell
68ca4d3bba jetzig bundle improvements
Generate a bundle that includes markdown files (needed for dynamic
markdown rendering). In future these will be compiled into static
outputs by the bundle command but for now we copy them into the source
tree. `bundle.tar.gz` includes one directory which is named after the
compiled exe, containing a `server` executable, `public` and `static`
directories, and any markdown files.

Windows support removed for now - will re-add when we overhaul all of
this to no longer do command line invocation of `tar` (we will build
tarball/Zip file ourselves).
2024-04-07 15:47:15 +01:00
Bob Farrell
ec045cccd6 Add environments, use pretty-printed JSON in development
Fix secret generation - overallocate length to ensure we have enough
bytes.

Error if no secret provided in production mode.
2024-03-28 22:39:58 +00:00
bobf
c2cc9c50f2
Merge pull request #46 from jetzig-framework/replicate-exe-imports
Replicate exe imports
2024-03-28 21:54:14 +00:00
Bob Farrell
29d13917a6 Add a dependency to demo app
Use as a regression test to ensure dependencies always work.
2024-03-28 21:07:16 +00:00
axispx
397e76b2d0 Print message when server detects changes after build failure 2024-03-28 10:00:17 +05:45
Froxcey
94a325fcbc
Cli: Fix bad code
Silly me, made some dumb mistakes. Welp, here's a commmit to fix all of
that!
2024-03-26 13:52:12 +08:00
Froxcey
f01abb86f5
Cli: Reload for fail build
When zig build fails, the `jetzig server` command also exits. This
should be an uninteneded behavior. This commit fixes this by catching
failed build and restart after file change is detected.
Fixes #33
2024-03-25 18:12:34 +08:00
Froxcey
19c04f1482
Cli: Add zig compiler color
The compiler doesn't pass color to the parent process unless it is
called with `--colour on`. This commit adds those arguments to add
support for coloring in compiler outputs.
2024-03-25 18:08:27 +08:00
Froxcey
646c45ea65
Replace exit with std.process.exit
`std.os.exit` got removed in [cd62005](cd62005f19 (diff-4284cdf770ea88be46f4aab7f82ed3c58821e4b3433b7c6152278a9911348dc5))
This commit fixes this by replacing all `std.os.exit` calls with
`std.process.exit`.
2024-03-25 18:03:49 +08:00
Bob Farrell
09bbcebb56 Deployment bundle
This needs some work (and testing on Windows) but it solves simple cases
and provides a starting point for a more advanced bundler.
2024-03-20 23:14:51 +00:00
Bob Farrell
87bcc4c9e0 Provide tooling for running Jetzig in deployment 2024-03-19 23:03:55 +00:00
Bob Farrell
304c2cba42 Fix Windows "jetzig server" command 2024-03-14 20:32:43 +00:00
Bob Farrell
aa036fde8b Implement layouts
Latest Zmpl provides `template.renderWithLayout(other_template, data)`,
allowing a template to be renedered within another template.

Create layouts in `src/app/views/layouts/` or use
`jetzig generate layout [name]` and set `pub const layout = "name";` in
each view file.
2024-03-11 22:36:18 +00:00
Bob Farrell
e980782316 Implement jetzig server command
Runs a development server and auto-reloads when changes are detected to
files.

Note that a "change" is just an mtime update, Zig does a more
intelligent change detection so avoids unnecessary recompiles, so the
server reloads very quickly.
2024-03-11 18:38:48 +00:00
Bob Farrell
bec5f9c905 Add update command to CLI tool
Automatically update to latest version of Jetzig with `jetzig update`.
2024-03-09 19:45:59 +00:00
Bob Farrell
f954439489 CLI generate command
Provide `jetzig generate ...` commands for views, middleware, and
partials.
2024-03-09 18:47:08 +00:00