109 Commits

Author SHA1 Message Date
Bob Farrell
ae3ed05a7d WIP 2025-05-06 19:41:33 +01:00
Bob Farrell
c887b25ef8 WIP 2025-05-04 20:38:58 +01:00
Bob Farrell
8074f8a221 WIP 2025-05-03 16:55:28 +01:00
Bob Farrell
d3113d12fe WIP 2025-05-03 16:21:54 +01:00
Bob Farrell
e647b0057a WIP 2025-04-30 21:11:41 +01:00
Bob Farrell
74bb659528 WIP 2025-04-28 20:03:02 +01:00
Bob Farrell
94f67dd4a2 WIP 2025-04-27 22:16:12 +01:00
Bob Farrell
3bd296821c WIP 2025-04-27 16:27:59 +01:00
Bob Farrell
ff6d8cf942 Merge branch 'inertia' into websockets 2025-04-27 14:31:11 +01:00
Bob Farrell
6a4f99ca14 Inertia - WIP
Not yet complete but provides some functionality with internal templates
that Websockets/Channels needs so merging in to main and can pick up
later.
2025-04-27 13:00:19 +01:00
Bob Farrell
fa76b75c12 WIP 2025-04-25 21:41:37 +01:00
Bob Farrell
58403986d7 JS RPC 2025-04-23 20:26:28 +01:00
Bob Farrell
e9802bf546 WIP 2025-04-23 19:11:02 +01:00
Bob Farrell
8c2d6806b5 Refactor Server into generic type
We need to have routes available within the server if we are going to do
any kind of dynamic dispatch for Channel Actions.
2025-04-23 12:58:41 +01:00
Bob Farrell
d3b3ae63cf WIP 2025-04-22 19:42:20 +01:00
Bob Farrell
9847efdf4a WIP 2025-04-21 19:50:31 +01:00
Bob Farrell
cd5a00d85f WIP 2025-04-21 15:55:12 +01:00
Bob Farrell
2072b59937 WIP 2025-04-21 15:55:12 +01:00
U-Zyn Chua
4c568f2606
Minor typo fix 2025-04-16 15:59:45 +08:00
Bob Farrell
c26d563898 Zig 0.15 compatibility
Various dependencies updated after changes to `std.zig.Ast` and
`std.LinkedList` and other things.
2025-04-09 20:08:38 +01:00
Bob Farrell
2cb1b4e959 Adjust test, fix memory leak in hashPassword, deinit repo on test app deinit 2025-03-23 13:28:09 +00:00
Sean M. Collins
79574ed861 Use defer to free hashed_pass 2025-03-20 13:54:13 -04:00
Sean M. Collins
aae890998f fix spelling mistake 2025-03-10 22:07:12 -04:00
Sean M. Collins
21bf237437 Shrink database.zig and comment 2025-03-10 21:57:02 -04:00
Sean M. Collins
9e4e8529c5 Create a template file for init
This allows us to use database.zig for CI, while still creating a blank
database.zig for new projects that are created via jetzig init
2025-03-10 21:49:36 -04:00
Sean M. Collins
70a8b0f698 Add tests for login view 2025-03-10 21:20:33 -04:00
Sean M. Collins
22688ccaa3 Set adapter to postgresql 2025-03-10 17:13:08 -04:00
Sean M. Collins
f3788567bb Fix argument to first migration 2025-03-10 17:05:09 -04:00
Sean M. Collins
58f7e0e76a Add User to schema 2025-03-10 16:50:11 -04:00
Sean M. Collins
b070d281e3 Add user table 2025-03-10 16:32:27 -04:00
Sean M. Collins
9012ec3aaf Add an example for using auth for logging in 2025-03-10 16:26:58 -04:00
Sean M. Collins
d8a992ce38 Set same_site to correct type
Fixes #170
2025-03-08 07:52:02 -05:00
Bob Farrell
06674db51f Use fork of zig-args (temporary)
Revert when [this PR](https://github.com/ikskuh/zig-args/pull/67) is
merged.
2025-03-02 13:12:29 +00:00
Bob Farrell
099a2a5349 Use Zig compiler
Default to not using LLVM for application compilation. This gives more
than 2x performance improvement for compilation stage.
2025-03-01 14:33:17 +00:00
Bob Farrell
c0d6fb162b Latest Zig build.zig.zon format compatibility 2025-03-01 12:28:08 +00:00
Bob Farrell
a5430ff380 Zig 0.14 test runner config changes
Update dependencies to match new Zig build config API for test runners,
misc. fixes needed after upgrading dependencies.
2025-02-02 11:31:40 +00:00
Bob Farrell
35adaf3009 Valkey backend for JetKV 2024-12-06 21:31:02 +00:00
Bob Farrell
f44a6b33c5 Routing updates
Implement `/foo/1/edit` route/view.

Allow setting HTTP verb by passing e.g. `/_PATCH` as the last segment of
a URL - this allows browsers to submit a `POST` request with a
pseudo-HTTP verb encoded in the URL which Jetzig can translate, i.e.
allowing forms to submit a `PATCH`.
2024-11-24 20:46:56 +00:00
Bob Farrell
1565ae3b73 Debug console
Use `jetzig server` or `zig build -Ddebug_console=true run` to launch a
development server with the debug console enabled.

When an error is encountered a formatted stack trace is dumped to the
browser along with the current response data. Both outputs are
syntax-highlighted using Prism JS.
2024-11-23 18:07:19 +00:00
Bob Farrell
8095bbcb76 Implement request.renderTemplate
Clean up request state.
2024-11-23 13:42:14 +00:00
Bob Farrell
036aec1682 Misc. tidying 2024-11-23 13:14:11 +00:00
Bob Farrell
6e6f1bec1b Closes #108: Anti-CSRF middleware
Add to middleware in app's `src/main.zig`:

```zig
pub const jetzig_options = struct {
    pub const middleware: []const type = &.{
        jetzig.middleware.AntiCsrfMiddleware,
    };
};
```

CSRF token available in Zmpl templates:

```
{{context.authenticityToken()}}
```
or render a hidden form element:
```
{{context.authenticityFormElement()}}
```

The following HTML requests are rejected (403 Forbidden) if the
submitted query param does not match the value stored in the encrypted
session (added automatically when the token is generated for a template
value):

* POST
* PUT
* PATCH
* DELETE

JSON requests are not impacted - users should either disable JSON
endpoints or implement a different authentication method to protect
them.
2024-11-23 12:49:49 +00:00
Bob Farrell
92dce21244 Database CLI improvements
Eradication of `data` arg to requests. We no longer need to pass this
value around as we have a) type inference, b) nested object insertion
via `put` and `append`.

Fix `joinPath` numeric type coercion

Detect empty string params and treat them as blank with expectParams()

Fix error logging/stack trace printing.

Update Zmpl - includes debug tokens + error tracing to source template
in debug builds.
2024-11-19 21:39:01 +00:00
Bob Farrell
b95506caf9 Params helpers
Implement `request.expectParams()` to coerce params to a given struct.
`request.paramsInfo()` provides information about each param (present,
blank, failed + original values and errors where applicable).
2024-11-17 19:07:27 +00:00
Bob Farrell
e3ab49fa5a Refactor Route
Move all route types into a single union and remove leftover junk.

Deprecate view functions that receive a `*jetzig.Data` argument (we will
stay backward-compatible until we have a valid reason to drop support
for legacy view functions - the extra code overhead is pretty minimal).
2024-11-17 15:08:54 +00:00
Bob Farrell
a6d1b92f5e Simplify DevelopmentLogger, add ProductionLogger
Add auth helper to create a user from CLI:

```
jetzig auth user:create user@example.com
```
2024-11-11 22:25:35 +00:00
Bob Farrell
b0613aab10 Import Schema in demo/init config 2024-11-09 18:36:48 +00:00
Bob Farrell
78a9ccaaa4 Fix database config path 2024-11-09 18:06:16 +00:00
Bob Farrell
d27907a1c5 WIP 2024-11-09 17:13:32 +00:00
Bob Farrell
1c2cbaca77 WIP 2024-11-09 17:12:49 +00:00