diff options
author | Yorhel <git@yorhel.nl> | 2019-07-29 16:48:48 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-07-29 16:53:04 +0200 |
commit | 6cda16f862283b4cb502af8ebdddea25bde29816 (patch) | |
tree | 4a143aade9cd01d9ee7880a4696fd7ed4bdbb959 /lib/VN3/Release/JS.pm | |
parent | e1e1d4e9b85d4ff0b26832fe95374f6f9718511e (diff) |
v3: Define & Generate API responses from Perl
This allows Perl modules to define new API responses and the
corresponding Elm type and parser will be generated automatically. The
primary reason to do this is to ensure that Elm and Perl stay
synchronized and to make sure that errors in generating API responses
can easily be found on the server side.
Also moded json_api() from VN3::Validate to VN3::Prelude, as that seemed
more fitting.
Diffstat (limited to 'lib/VN3/Release/JS.pm')
-rw-r--r-- | lib/VN3/Release/JS.pm | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/VN3/Release/JS.pm b/lib/VN3/Release/JS.pm index c562d4c5..152fd69a 100644 --- a/lib/VN3/Release/JS.pm +++ b/lib/VN3/Release/JS.pm @@ -3,11 +3,11 @@ package VN3::Release::JS; use VN3::Prelude; -my $OUT = tuwf->compile({ aoh => { +my $elm_ReleaseResult = elm_api ReleaseResult => { aoh => { id => { id => 1 }, title => {}, lang => { type => 'array', values => {} }, -}}); +}}; # Fetch all releases assigned to a VN @@ -26,7 +26,7 @@ json_api '/js/release.json', { }); enrich_list1 lang => id => id => sub { sql 'SELECT id, lang FROM releases_lang WHERE id IN', $_[0], 'ORDER BY id, lang' }, $r; - tuwf->resJSON({ReleaseResult => $OUT->analyze->coerce_for_json($r)}); + $elm_ReleaseResult->($r); }; 1; |