110 Commits

Author SHA1 Message Date
Bob Farrell
3861bd8dea Update Zmpl 2024-11-06 08:53:31 +00:00
Bob Farrell
c7b79f144a Fixes for https://github.com/ziglang/zig/pull/21817 2024-11-06 08:44:07 +00:00
IbrahimOuhamou
cea2781391 updated zmpl and added session.remove() thanks to Allah 2024-11-03 11:39:03 +01:00
Bob Farrell
9b2d6274ff Update http.zig
Resolves overflow vuln.
2024-09-27 18:27:22 +01:00
Bob Farrell
dda433bb73 Update Zmpl - adds Data.Object.items() and Data.Array.items()
`Data.Object` now preserves insertion order.
2024-09-07 12:01:40 +01:00
Bob Farrell
bed877b16a Update Zmpl
Misc. improvements to Zmpl from @T-136
2024-09-07 11:01:40 +01:00
Bob Farrell
47f9455060 Update Zmpl
Includes update that allows using arbitrary structs as Data-compatible
values (thanks @T-136 !)
2024-09-02 21:44:03 +01:00
Bob Farrell
af4de258f0 More Type fixes 2024-08-30 19:02:56 +01:00
Bob Farrell
ca049012b6 Update Zmpl - more Type fixes 2024-08-30 19:00:53 +01:00
Bob Farrell
15b0fa1af9 Latest Zig master compatibility 2024-08-30 18:43:12 +01:00
Bob Farrell
e98c5ec3df Update http.zig
Refactor routes generation to standalone exe (fixes some build-time vs.
run-time issues).
2024-08-24 11:18:08 +01:00
Karl Seguin
3f22e03723 Update the smtp_client dependency.
smtp_client was making a wrong local copy of
an internal buffer.

Diff between current version and this updated one.

964152ad4e...48971bc919
2024-08-11 21:14:48 +08:00
Bob Farrell
9971cde875 Close #89: Implement file upload support
Use `request.file("form-field-name")` to try to find a multipart-encoded
form value for the given name. Returns `jetzig.http.File` if a match is
found which provides `content` (uploaded file content) and `filename`
(filename as passed by browser).
2024-06-19 20:47:05 +01:00
Bob Farrell
e30d340a7a Embed static routes in compiled exe
Remove need for static routes output files to be copied/generated in
deployment.
2024-06-08 19:37:41 +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
Bob Farrell
b304a3509b Windows compatibility fixes 2024-06-01 18:05:01 +01:00
Bob Farrell
b6b67f8dd6 Use http.zig arena pool 2024-05-26 21:37:48 +01:00
Bob Farrell
80ca764c0f Update Zmpl for template inheritance
Permit setting template during view render with `request.setTemplate()`

Permit middleware to define custom routes to static content with
`pub const Routes` (implemented for something no longer needed but seems
useful anyway).

Implement globbing on custom routes, `/foo/:bar*` will glob all path
segments including and after `/foo/...`, e.g. `/foo/bar/baz/qux` will
pass invoke the custom view function with an array of `bar`, `baz`,
`qux` as first argument (instead of typical resource ID).
2024-05-26 17:20:21 +01:00
Bob Farrell
3b30ab4625 Update build.zig and deps for 0.13 build system 2024-05-21 19:42:56 +01:00
rimuspp
4952cae74d
Fixed zigargs reference
MasterQ32 changed his github name
2024-05-16 18:42:40 -05:00
Bob Farrell
3519483f34 Switch to http.zig
Use Karl Seguin's http.zig as HTTP server backend:
https://github.com/karlseguin/http.zig

Update loggers to use new `jetzig.loggers.LogQueue` to offload logging
to a background thread.

Numerous other optimizations to remove unneeded allocs.

Performance jump on a simple request from approx. 2k requests/second to
approx. 40k requests/second (Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz).

Color support for Windows

Zmpl partial arg type coercion
2024-05-12 21:33:26 +01:00
Bob Farrell
e4bd14e80d Windows SMTP compatibility 2024-05-06 14:55:53 +01:00
Bob Farrell
deb6f9604b Update JetKV - bugfix 2024-05-06 10:43:49 +01: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
b7d750c54f Formalise JetKV interface for store, cache, jobs
Provide configuration for JetKV backend (memory or file allocator).
2024-05-05 12:27:59 +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
9d12b5c717 Update Zmpl, adds Markdown mode formatters
Also adds support for `.md.zmpl` templates - root node is Markdown.
2024-04-27 22:22:30 +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
25587d4258 Update Zmpl - add support for one-liner slots rendering
```
{{slots}}
```
will render all slots `\n`-separated.
2024-04-13 20:11:44 +01:00
Bob Farrell
0b968c3b44 Minor improvements to request params and headers
Fully disambiguate request params from body and query string and clean
up convoluted code, reduce allocs. Implement
`jetzig.http.Request.queryParams` which always returns only the parsed
query string, never the request body.

Deprecate `headers.getFirstValue` in favour of `headers.get`, implement
`headers.getAll`.
2024-04-13 19:24:40 +01:00
Bob Farrell
4de9f4d248 Update zmpl/zmd - code/block bugfixes 2024-04-13 11:22:02 +01:00
Bob Farrell
b42d0411c1 Update Zmpl and zmd - misc zmd bugfixes 2024-04-12 21:54:41 +01:00
Bob Farrell
2c81c64c93 Update Zmpl - sync zmd versions 2024-04-11 20:50:06 +01:00
Bob Farrell
d5c7f97036 Update zmd - fixes parenthesis parsing 2024-04-11 20:47:38 +01:00
Bob Farrell
88abe2243d Update Zmpl
Numerous fixes and improvements to v2 parser.
2024-04-10 22:06:11 +01:00
Bob Farrell
1cf3dcc106 Update zmpl and zmd - misc. markdown fixes 2024-04-07 21:54:25 +01:00
Bob Farrell
a85389a199 Update Zmpl
Misc. minor bugfixes
2024-04-07 12:20:34 +01:00
Bob Farrell
16204a4832 Zmpl v2
Update to Zmpl v2, update demo app to be compatible with v2 syntax. Add
deprecation warning for v1 (v1 is default for now - will force v2 soon).
2024-04-07 10:34:34 +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
Bob Farrell
0e29934718 Implement Markdown
Create `.md` files instead of `.zmpl` files to render static markdown
content.
2024-03-26 22:20:27 +00:00
Bob Farrell
f8d1db5460 Inject jetzig_view and jetzig_action into Zmpl templates 2024-03-22 20:37:02 +00:00
Bob Farrell
381c38d85d Overhaul logging, implement JSON logger
Log errors to separate files, specify minimum log level, implement JSON
logging.
2024-03-20 21:17:14 +00:00
Bob Farrell
87bcc4c9e0 Provide tooling for running Jetzig in deployment 2024-03-19 23:03:55 +00:00
Bob Farrell
9664cf8e80 Update Zmpl, provides partial args (with type inference) 2024-03-16 21:13:06 +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
7e804c6935 Update Zmpl, fix issue with non-linebreak-terminated templates
Latest update normalizes input by adding a terminating linebreak to end
of input stream if not already present, fixing an issue where parsing
finalised with content still present in the char buf. A warning is also
raised requesting a bug report if this occurs.
2024-03-09 12:34:13 +00:00
Bob Farrell
de40af0dc6 Fix init on Windows, update Zmpl for Windows module path fix 2024-03-07 18:41:09 +00:00
Bob Farrell
d3a3582136 Implement init command, get rid of old init script/artifacts
Remove old bash script for setting up a new project, do everything in
Zig to make it platform agnostic and give us an easy place to add
scaffolding commands in future.
2024-03-06 22:57:11 +00:00
Bob Farrell
29f4771264 Upgrade Zmpl (latest version provides partials), fix mime map memory leak 2024-03-03 14:12:35 +00:00