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

Extracting the module #3

Closed
wants to merge 4 commits into from
Closed

Extracting the module #3

wants to merge 4 commits into from

Conversation

stanistan
Copy link
Owner

@stanistan stanistan commented Mar 7, 2021

It's a PR! to do a thing!

this is branched off of `gen_schema_2`
_but_ there's an issue with `serde` being imported in both libraries.
I'd really like to have that not be the case.

Other changes...

- added the module name to the `Table` trait, could be better for errors
and messaging/debugging.

- figured out _something_ with forwarding external dependencies with
`$crate::Dep`

- `run_proxy!` macro can be used as _main_, so that means, (coolly),
that we don't need tokio to be included in the user's lib, all the stuff
with it not working was just a bad copypasta, and poor error messages
before.
@stanistan stanistan closed this Mar 18, 2021
Copy link
Owner Author

@stanistan stanistan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaning up and refactoring the library.

Comment on lines -10 to -16
num-format = "0.4.0"
warp = "0.2"
url = "2.1.1"
reqwest = { version = "0.10", features = ["json"] }
tokio = { version = "0.2", features = ["full"] }
airtable-proxy = { path = "airtable-proxy" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We explicitly clean up the dependencies, moving them into the proxy (or whatever happened here).

edition = "2018"

[dependencies]
num-format = "0.4.0"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can see that we moved them all here.

use $crate::gen_schema::Table;
use $crate::network::request::*;
use $crate::network::response::One;
use $crate::transform::*;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using $crate makes this better to resolve when used as a dependency.

Comment on lines +21 to +52
(@inner $namespace:ident) => {{
//
// make sure we can airtable, yo, that we have the
// right env setup/permissions here.
let ctx = $crate::airtable::FetchCtx::from_env()?;

//
// get our server port from the environment, default is 3000
let address: ::std::net::SocketAddr = ::std::env::var("HOST")
.unwrap_or_else(|_| "127.0.0.1:3000".to_string())
.parse()?;

//
// make our context async ready
let ctx = $crate::ctx::wrap_ctx(ctx);

//
// grab the generated router
//
// todo: this should print/log the routes, which means
// that `route` methods should probably return a tuple
// of the `warp::filter` with some `debug` struct that we
// can output here.
let router = $namespace::gen::route(ctx);

//TODO: LOGGER
println!("will be serving the app on {}", address);
$crate::warp::serve(router).run(address).await;

Ok(())
}};
}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a macro so that it's nice to run.

@stanistan stanistan changed the title Extract to module [test] Extracting the module Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant