Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASAP hot-fix - current master does not work #11

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/template/src/routers/mod.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ pub fn router() -> Router {
.delete(delete_user),
),
];
let static_routers = static_routers::create_static_routers();
no_auth_routers.extend(static_routers);

let router = Router::new()
.hoop(Logger::new())
.hoop(CatchPanic::new())
Expand Down
19 changes: 19 additions & 0 deletions src/utils/create_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ fn write_project_file(

let (src_path, router_path) = create_basic_file(project_path, &handlebars, &data)?;


if is_web_site {
//templates
let template_path = project_path.join("templates");
Expand All @@ -202,9 +203,13 @@ fn write_project_file(
handle_404_file.write_all(handle_404_template_rendered.as_bytes())?;
//assets
let assets_path = project_path.join("assets");
std::fs::create_dir_all(&assets_path)?;


//assets/favicon.ico
let favicon_bytes = include_bytes!("../template/assets/favicon.ico");
let mut favicon_file = File::create(assets_path.join("favicon.ico"))?;

favicon_file.write_all(favicon_bytes)?;
if need_db_conn {
//assets/js
Expand Down Expand Up @@ -260,6 +265,13 @@ fn write_project_file(
let router_user_rendered = handlebars.render_template(router_user_template, &data)?;
let mut router_user_file = File::create(router_path.join("user.rs"))?;
router_user_file.write_all(router_user_rendered.as_bytes())?;

//src/router/static_routers.rs
let router_static_routers_template = include_str!("../template/src/routers/static_routers.hbs");
let router_static_routers_rendered = handlebars.render_template(router_static_routers_template, &data)?;
let mut router_static_routers_file = File::create(router_path.join("static_routers.rs"))?;
router_static_routers_file.write_all(router_static_routers_rendered.as_bytes())?;

//src/services
let services_path = src_path.join("services");
std::fs::create_dir_all(&services_path)?;
Expand All @@ -273,6 +285,7 @@ fn write_project_file(
let services_user_rendered = handlebars.render_template(services_user_template, &data)?;
let mut services_user_file = File::create(services_path.join("user.rs"))?;
services_user_file.write_all(services_user_rendered.as_bytes())?;

//src/utils
let utils_path = src_path.join("utils");
std::fs::create_dir_all(&utils_path)?;
Expand Down Expand Up @@ -649,6 +662,12 @@ fn create_basic_file(
let mut router_demo_file = File::create(router_path.join("demo.rs"))?;
router_demo_file.write_all(router_demo_rendered.as_bytes())?;

//src/router/static_routers.rs
// let router_static_routers_template = include_str!("../template/src/routers/static_routers.hbs");
// let router_static_routers_rendered = handlebars.render_template(router_static_routers_template, &data)?;
// let mut router_static_routers_file = File::create(router_path.join("static_routers.rs"))?;
// router_static_routers_file.write_all(router_static_routers_rendered.as_bytes())?;

Ok((src_path, router_path))
}

Expand Down