feat: load billing adapters #125
2 changed files with 84 additions and 2 deletions
82
utils/generate_actix_handler.sh
Executable file
82
utils/generate_actix_handler.sh
Executable file
|
@ -0,0 +1,82 @@
|
|||
#!/bin/bash
|
||||
|
||||
help() {
|
||||
echo "Usage: generate_actix_handler.sh
|
||||
<domain name in Sentence case>
|
||||
<function name>
|
||||
<route path>
|
||||
<template struct name>
|
||||
<function name in camelCase for payload struct>"
|
||||
}
|
||||
|
||||
|
||||
|
||||
# $1: domain in sentence case
|
||||
# $2: function_name
|
||||
# $3: route
|
||||
# $4: template struct name
|
||||
# $5: function name in camelcase for payload stroct
|
||||
run() {
|
||||
echo "
|
||||
// service config
|
||||
|
||||
cfg.service(${2}_ui_handler);
|
||||
cfg.service(${2}_form_submission_handler);
|
||||
|
||||
// $2 handlers
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[get(\"$3\")]
|
||||
#[tracing::instrument(name = \"$2 UI handler\", skip())]
|
||||
async fn ${2}_ui_handler() -> WebJsonRepsonse<impl Responder> {
|
||||
use web_ui::${1,,}::$2::*;
|
||||
|
||||
let page = $4::page();
|
||||
|
||||
Ok(HttpResponse::Ok()
|
||||
.insert_header(ContentType::html())
|
||||
.body(page))
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)]
|
||||
struct ${5}Payload {
|
||||
password: String,
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[post(\"$3\")]
|
||||
#[tracing::instrument(
|
||||
name = \"$2 form submission handler\"
|
||||
skip(id, req, payload, ${1,,}_cqrs_exec)
|
||||
)]
|
||||
async fn ${2}_form_submission_handler(
|
||||
${1,,}_cqrs_exec: types::Web${1}CqrsExec,
|
||||
req: HttpRequest,
|
||||
id: Identity,
|
||||
payload: web::Form<$5Payload>,
|
||||
) -> WebJsonRepsonse<impl Responder> {
|
||||
let store = \"\";
|
||||
|
||||
Ok(HttpResponse::Ok().json(store))
|
||||
}"
|
||||
}
|
||||
|
||||
if [ -z $1 ]
|
||||
then
|
||||
help
|
||||
elif [ -z $2 ]
|
||||
then
|
||||
help
|
||||
elif [ -z $3 ]
|
||||
then
|
||||
help
|
||||
elif [ -z $4 ]
|
||||
then
|
||||
help
|
||||
elif [ -z $5 ]
|
||||
then
|
||||
help
|
||||
else
|
||||
run $1 $2 $3 $4 $5 | wl-copy
|
||||
run $1 $2 $3 $4 $5
|
||||
fi
|
|
@ -9,8 +9,8 @@ help() {
|
|||
echo "
|
||||
#[actix_rt::test]
|
||||
async fn $1_web_$2_ui_works() {
|
||||
let routes = RoutesRepository::default();
|
||||
page_test_runner( &routes.$2).await;
|
||||
let routes = crate::$1::adapters::input::web::RoutesRepository::default();
|
||||
crate::tests::actix_web_test_utils::page_test_runner( &routes.$2).await;
|
||||
}"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue