Packages

Typed route definitions for seamless fullstack development !

Current section

Files

Jump to
gleatter src gleatter@service.erl
Raw

src/gleatter@service.erl

-module(gleatter@service).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([new/0, with_root_path/2, with_base_type/3, with_base_converter/2, with_upsert_type/3, with_upsert_converter/2, create_route/1, get_all_route/1, get_route/1, update_route/1, delete_route/1]).
-export_type([route_service/2]).
-type route_service(IVN, IVO) :: {route_service,
list(binary()),
{fun((IVN) -> gleam@json:json()),
fun((gleam@dynamic:dynamic_()) -> {ok, IVN} |
{error, list(gleam@dynamic:decode_error())})},
{fun((IVO) -> gleam@json:json()),
fun((gleam@dynamic:dynamic_()) -> {ok, IVO} |
{error, list(gleam@dynamic:decode_error())})}}.
-file("/home/runner/work/gleatter/gleatter/src/gleatter/service.gleam", 76).
-spec nil_converter() -> {fun((any()) -> gleam@json:json()),
fun((any()) -> {ok, nil} | {error, any()})}.
nil_converter() ->
{fun(_) -> gleam@json:null() end, fun(_) -> {ok, nil} end}.
-file("/home/runner/work/gleatter/gleatter/src/gleatter/service.gleam", 82).
-spec new() -> route_service(nil, nil).
new() ->
{route_service, [], nil_converter(), nil_converter()}.
-file("/home/runner/work/gleatter/gleatter/src/gleatter/service.gleam", 87).
-spec with_root_path(route_service(IVS, IVT), list(binary())) -> route_service(IVS, IVT).
with_root_path(Service, Root_path) ->
erlang:setelement(2, Service, Root_path).
-file("/home/runner/work/gleatter/gleatter/src/gleatter/service.gleam", 96).
-spec with_base_type(
route_service(any(), IWC),
fun((IWF) -> gleam@json:json()),
fun((gleam@dynamic:dynamic_()) -> {ok, IWF} |
{error, list(gleam@dynamic:decode_error())})
) -> route_service(IWF, IWC).
with_base_type(Service, Base_encoder, Base_decoder) ->
{route_service,
erlang:element(2, Service),
{Base_encoder, Base_decoder},
erlang:element(4, Service)}.
-file("/home/runner/work/gleatter/gleatter/src/gleatter/service.gleam", 107).
-spec with_base_converter(route_service(any(), IWN), convert:converter(IWQ)) -> route_service(IWQ, IWN).
with_base_converter(Service, Converter) ->
{route_service, erlang:element(2, Service), {fun(Val) -> _pipe = Val,
convert@json:json_encode(_pipe, Converter) end, convert@json:json_decode(
Converter
)}, erlang:element(4, Service)}.
-file("/home/runner/work/gleatter/gleatter/src/gleatter/service.gleam", 123).
-spec with_upsert_type(
route_service(IWV, any()),
fun((IWZ) -> gleam@json:json()),
fun((gleam@dynamic:dynamic_()) -> {ok, IWZ} |
{error, list(gleam@dynamic:decode_error())})
) -> route_service(IWV, IWZ).
with_upsert_type(Service, Upsert_encoder, Upsert_decoder) ->
{route_service,
erlang:element(2, Service),
erlang:element(3, Service),
{Upsert_encoder, Upsert_decoder}}.
-file("/home/runner/work/gleatter/gleatter/src/gleatter/service.gleam", 137).
-spec with_upsert_converter(route_service(IXG, any()), convert:converter(IXK)) -> route_service(IXG, IXK).
with_upsert_converter(Service, Converter) ->
{route_service,
erlang:element(2, Service),
erlang:element(3, Service),
{fun(Val) -> _pipe = Val,
convert@json:json_encode(_pipe, Converter) end, convert@json:json_decode(
Converter
)}}.
-file("/home/runner/work/gleatter/gleatter/src/gleatter/service.gleam", 148).
-spec create_route(route_service(IXP, IXQ)) -> gleatter@route:route(nil, nil, IXQ, IXP).
create_route(Service) ->
_pipe = gleatter@route:new(),
_pipe@1 = gleatter@route:with_method(_pipe, post),
_pipe@2 = gleatter@route:with_path(
_pipe@1,
gleatter@path:static_path(erlang:element(2, Service))
),
_pipe@3 = gleatter@route:with_request_body(
_pipe@2,
gleatter@body:json_body(
erlang:element(1, erlang:element(4, Service)),
erlang:element(2, erlang:element(4, Service))
)
),
gleatter@route:with_response_body(
_pipe@3,
gleatter@body:json_body(
erlang:element(1, erlang:element(3, Service)),
erlang:element(2, erlang:element(3, Service))
)
).
-file("/home/runner/work/gleatter/gleatter/src/gleatter/service.gleam", 159).
-spec get_all_route(route_service(IXX, any())) -> gleatter@route:route(nil, nil, nil, list(IXX)).
get_all_route(Service) ->
_pipe = gleatter@route:new(),
_pipe@1 = gleatter@route:with_method(_pipe, get),
_pipe@2 = gleatter@route:with_path(
_pipe@1,
gleatter@path:static_path(erlang:element(2, Service))
),
gleatter@route:with_response_body(
_pipe@2,
gleatter@body:json_body(fun(V) -> _pipe@3 = V,
gleam@json:array(
_pipe@3,
erlang:element(1, erlang:element(3, Service))
) end, gleam@dynamic:list(
erlang:element(2, erlang:element(3, Service))
))
).
-file("/home/runner/work/gleatter/gleatter/src/gleatter/service.gleam", 172).
-spec get_route(route_service(IYG, any())) -> gleatter@route:route(binary(), nil, nil, IYG).
get_route(Service) ->
_pipe = gleatter@route:new(),
_pipe@1 = gleatter@route:with_method(_pipe, get),
_pipe@2 = gleatter@route:with_path(
_pipe@1,
gleatter@path:id_path(erlang:element(2, Service))
),
gleatter@route:with_response_body(
_pipe@2,
gleatter@body:json_body(
erlang:element(1, erlang:element(3, Service)),
erlang:element(2, erlang:element(3, Service))
)
).
-file("/home/runner/work/gleatter/gleatter/src/gleatter/service.gleam", 182).
-spec update_route(route_service(IYO, IYP)) -> gleatter@route:route(binary(), nil, IYP, IYO).
update_route(Service) ->
_pipe = gleatter@route:new(),
_pipe@1 = gleatter@route:with_method(_pipe, post),
_pipe@2 = gleatter@route:with_path(
_pipe@1,
gleatter@path:id_path(erlang:element(2, Service))
),
_pipe@3 = gleatter@route:with_request_body(
_pipe@2,
gleatter@body:json_body(
erlang:element(1, erlang:element(4, Service)),
erlang:element(2, erlang:element(4, Service))
)
),
gleatter@route:with_response_body(
_pipe@3,
gleatter@body:json_body(
erlang:element(1, erlang:element(3, Service)),
erlang:element(2, erlang:element(3, Service))
)
).
-file("/home/runner/work/gleatter/gleatter/src/gleatter/service.gleam", 194).
-spec delete_route(route_service(any(), any())) -> gleatter@route:route(binary(), nil, nil, binary()).
delete_route(Service) ->
_pipe = gleatter@route:new(),
_pipe@1 = gleatter@route:with_method(_pipe, delete),
_pipe@2 = gleatter@route:with_path(
_pipe@1,
gleatter@path:id_path(erlang:element(2, Service))
),
gleatter@route:with_response_body(
_pipe@2,
gleatter@body:json_body(
fun gleam@json:string/1,
fun gleam@dynamic:string/1
)
).