GithubHelp home page GithubHelp logo

rusty-crab / warp-api-starter-template Goto Github PK

View Code? Open in Web Editor NEW
201.0 201.0 17.0 177 KB

A boilerplate template for starting a web services using Warp + SQLx (PostgreSQL) + Redis + Juniper (GraphQL). ❤️

License: MIT License

Rust 94.63% Dockerfile 4.41% Shell 0.96%
boilerplate juniper project-template redis rust sqlx template warp

warp-api-starter-template's People

Contributors

aslamplr avatar dependabot[bot] avatar maxcountryman avatar trifel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

warp-api-starter-template's Issues

Doesn't compile on nightly

Here is stacktrace

➜  warp-api-starter-template git:(master) rustup toolchain remove nightly-2020-10-06-x86_64-unknown-linux-gnu
info: uninstalling toolchain 'nightly-2020-10-06-x86_64-unknown-linux-gnu'
info: toolchain 'nightly-2020-10-06-x86_64-unknown-linux-gnu' uninstalled
➜  warp-api-starter-template git:(master) rm -rf target
➜  warp-api-starter-template git:(master) cargo r
   Compiling libc v0.2.71
   Compiling proc-macro2 v1.0.18
   Compiling unicode-xid v0.2.1
   Compiling syn v1.0.33
   Compiling cfg-if v0.1.10
   Compiling autocfg v1.0.0
   Compiling memchr v2.3.3
   Compiling lazy_static v1.4.0
   Compiling log v0.4.8
   Compiling byteorder v1.3.4
   Compiling version_check v0.9.2
   Compiling serde_derive v1.0.114
   Compiling serde v1.0.114
   Compiling typenum v1.12.0
   Compiling itoa v0.4.6
   Compiling fnv v1.0.7
   Compiling slab v0.4.2
   Compiling futures-core v0.3.5
   Compiling bytes v0.5.5
   Compiling pin-project-internal v0.4.22
   Compiling once_cell v1.4.0
   Compiling getrandom v0.1.14
   Compiling bitflags v1.2.1
   Compiling futures-sink v0.3.5
   Compiling proc-macro-nested v0.1.6
   Compiling proc-macro-hack v0.5.16
   Compiling futures-io v0.3.5
   Compiling hashbrown v0.9.1
   Compiling matches v0.1.8
   Compiling pin-utils v0.1.0
   Compiling tinyvec v0.3.3
   Compiling ppv-lite86 v0.2.8
   Compiling arc-swap v0.4.7
   Compiling ryu v1.0.5
   Compiling pin-project-lite v0.1.7
   Compiling autocfg v0.1.7
   Compiling rand_core v0.4.2
   Compiling percent-encoding v2.1.0
   Compiling regex-syntax v0.6.18
   Compiling serde_json v1.0.59
   Compiling byte-tools v0.3.1
   Compiling base64 v0.12.3
   Compiling pkg-config v0.3.17
   Compiling opaque-debug v0.2.3
   Compiling quick-error v1.2.3
   Compiling adler32 v1.1.0
   Compiling httparse v1.3.4
   Compiling fake-simd v0.1.2
   Compiling remove_dir_all v0.5.3
   Compiling gimli v0.21.0
   Compiling failure_derive v0.1.8
   Compiling object v0.20.0
   Compiling unicode-width v0.1.8
   Compiling glob v0.2.11
   Compiling rustc-demangle v0.1.16
   Compiling version_check v0.1.5
   Compiling either v1.5.3
   Compiling openssl v0.10.30
   Compiling foreign-types-shared v0.1.1
   Compiling proc-macro2 v0.4.30
   Compiling unicode-xid v0.1.0
   Compiling native-tls v0.2.4
   Compiling cpuid-bool v0.1.2
   Compiling void v1.0.2
   Compiling termcolor v1.1.0
   Compiling maybe-uninit v2.0.0
   Compiling opaque-debug v0.3.0
   Compiling vec_map v0.8.2
   Compiling mime v0.3.16
   Compiling ansi_term v0.11.0
   Compiling strsim v0.8.0
   Compiling try-lock v0.2.2
   Compiling safemem v0.3.3
   Compiling dtoa v0.4.6
   Compiling utf-8 v0.7.5
   Compiling subtle v1.0.0
   Compiling scopeguard v0.3.3
   Compiling openssl-probe v0.1.2
   Compiling bindgen v0.48.1
   Compiling ascii v0.9.3
   Compiling unicode-segmentation v1.6.0
   Compiling peeking_take_while v0.1.2
   Compiling md5 v0.6.1
   Compiling hex v0.3.2
   Compiling linked-hash-map v0.5.3
   Compiling tower-service v0.3.0
   Compiling maplit v1.0.2
   Compiling hex v0.4.2
   Compiling scoped-tls v1.0.0
   Compiling static_assertions v1.1.0
   Compiling urlencoding v1.1.1
   Compiling spin v0.5.2
   Compiling anyhow v1.0.34
   Compiling dotenv v0.15.0
   Compiling futures v0.1.29
   Compiling untrusted v0.7.1
   Compiling data-encoding v2.2.1
   Compiling smallvec v1.4.0
   Compiling os_str_bytes v2.3.1
   Compiling ansi_term v0.12.1
   Compiling scopeguard v1.1.0
   Compiling strsim v0.10.0
   Compiling thread_local v1.0.1
   Compiling tracing-core v0.1.17
   Compiling sharded-slab v0.1.0
   Compiling num-traits v0.2.14
   Compiling indexmap v1.6.0
   Compiling num-integer v0.1.44
   Compiling crossbeam-utils v0.7.2
   Compiling num-bigint v0.3.1
   Compiling num-iter v0.1.42
   Compiling num-rational v0.3.1
   Compiling generic-array v0.14.4
   Compiling proc-macro-error-attr v1.0.3
   Compiling unicase v2.6.0
   Compiling proc-macro-error v1.0.3
   Compiling futures-task v0.3.5
   Compiling futures-channel v0.3.5
   Compiling http v0.2.1
   Compiling input_buffer v0.3.1
   Compiling unicode-bidi v0.3.4
   Compiling unicode-normalization v0.1.13
   Compiling rand_core v0.3.1
   Compiling rand_jitter v0.1.4
   Compiling block-padding v0.1.5
   Compiling rand_chacha v0.1.1
   Compiling rand_pcg v0.1.2
   Compiling rand v0.6.5
   Compiling humantime v1.3.0
   Compiling miniz_oxide v0.3.7
   Compiling textwrap v0.11.0
   Compiling textwrap v0.12.1
   Compiling nom v4.2.3
   Compiling itertools v0.8.2
   Compiling clang-sys v0.26.4
   Compiling foreign-types v0.3.2
   Compiling unreachable v1.0.0
   Compiling addr2line v0.12.2
   Compiling heck v0.3.1
   Compiling rand_hc v0.1.0
   Compiling rand_isaac v0.1.1
   Compiling rand_xorshift v0.1.1
   Compiling idna v0.2.0
   Compiling aho-corasick v0.7.13
   Compiling twoway v0.1.8
   Compiling buf_redux v0.8.4
   Compiling want v0.3.0
   Compiling tracing-log v0.1.1
   Compiling http-body v0.3.1
   Compiling headers-core v0.2.0
   Compiling quote v1.0.7
   Compiling jobserver v0.1.21
   Compiling num_cpus v1.13.0
   Compiling iovec v0.1.4
   Compiling net2 v0.2.34
   Compiling time v0.1.43
   Compiling signal-hook-registry v1.2.0
   Compiling backtrace v0.3.49
   Compiling atty v0.2.14
   Compiling rand_os v0.1.3
   Compiling rand v0.4.6
   Compiling socket2 v0.3.12
   Compiling listenfd v0.3.3
   Compiling hashbrown v0.1.8
   Compiling combine v3.8.1
   Compiling regex-automata v0.1.9
   Compiling base64 v0.10.1
   Compiling quote v0.6.13
   Compiling generic-array v0.12.3
   Compiling url v2.1.1
   Compiling regex v1.3.9
   Compiling rand_core v0.5.1
   Compiling cc v1.0.55
   Compiling futures-cpupool v0.1.8
   Compiling mio v0.6.22
   Compiling num-complex v0.3.1
   Compiling clap v2.33.1
   Compiling crossbeam-queue v0.2.3
   Compiling tempdir v0.3.7
   Compiling mime_guess v2.0.3
   Compiling matchers v0.0.1
   Compiling digest v0.8.1
   Compiling block-buffer v0.7.3
   Compiling crypto-mac v0.7.0
   Compiling cexpr v0.3.6
   Compiling digest v0.9.0
   Compiling block-buffer v0.9.0
   Compiling rand_chacha v0.2.2
   Compiling env_logger v0.6.2
   Compiling sqlformat v0.1.0
   Compiling mio-uds v0.6.8
   Compiling openssl-sys v0.9.58
   Compiling libloading v0.5.2
   Compiling ring v0.16.15
   Compiling sha-1 v0.8.2
   Compiling md-5 v0.8.0
   Compiling sha2 v0.8.2
   Compiling hmac v0.7.1
   Compiling sha-1 v0.9.1
   Compiling rand v0.7.3
   Compiling syn-mid v0.5.0
   Compiling synstructure v0.12.4
   Compiling derive_utils v0.10.0
   Compiling headers v0.3.2
   Compiling tungstenite v0.11.1
   Compiling tempfile v3.1.0
   Compiling num v0.3.1
   Compiling futures-macro v0.3.5
   Compiling tokio-macros v0.2.5
   Compiling thiserror-impl v1.0.20
   Compiling tracing-attributes v0.1.8
   Compiling async-stream-impl v0.2.1
   Compiling async-trait v0.1.36
   Compiling shrinkwraprs v0.3.0
   Compiling multipart v0.17.0
   Compiling tokio v0.2.21
   Compiling thiserror v1.0.20
   Compiling failure v0.1.8
   Compiling async-stream v0.2.1
   Compiling pin-project v0.4.22
   Compiling tracing v0.1.15
   Compiling juniper_codegen v0.14.2 (https://github.com/graphql-rust/juniper.git?rev=4d77a1a9b9b0e60cbeb200527289bd45afec4141#4d77a1a9)
   Compiling clap_derive v3.0.0-beta.2
   Compiling graphql-parser v0.3.0
   Compiling which v2.0.1
   Compiling futures-util v0.3.5
   Compiling tracing-futures v0.2.4
   Compiling tokio-util v0.3.1
   Compiling async-native-tls v0.3.3
   Compiling futures-executor v0.3.5
   Compiling tokio-tungstenite v0.11.0
   Compiling combine v4.2.1
   Compiling futures v0.3.5
   Compiling chrono v0.4.19
   Compiling uuid v0.8.1
   Compiling toml v0.5.6
   Compiling serde_urlencoded v0.6.1
   Compiling tracing-serde v0.1.2
   Compiling bincode v1.3.1
   Compiling h2 v0.2.5
   Compiling clap v3.0.0-beta.2
   Compiling find-crate v0.5.0
   Compiling bson v1.0.0
   Compiling sqlx-core v0.3.5
   Compiling biscuit v0.5.0-beta2
   Compiling tracing-subscriber v0.2.15
   Compiling futures-enum v0.1.13
error[E0277]: can't compare `tracing_core::LevelFilter` with `tracing::level_filters::LevelFilter`
   --> /home/shirshak/.cargo/registry/src/github.com-1ecc6299db9ec823/tracing-subscriber-0.2.15/src/filter/env/mod.rs:257:49
    |
257 |             .filter(|directive| directive.level > STATIC_MAX_LEVEL)
    |                                                 ^ no implementation for `tracing_core::LevelFilter < tracing::level_filters::LevelFilter` and `tracing_core::LevelFilter > tracing::level_filters::LevelFilter`
    |
    = help: the trait `PartialOrd<tracing::level_filters::LevelFilter>` is not implemented for `tracing_core::LevelFilter`

error[E0277]: `tracing::level_filters::LevelFilter` doesn't implement `std::fmt::Display`
   --> /home/shirshak/.cargo/registry/src/github.com-1ecc6299db9ec823/tracing-subscriber-0.2.15/src/filter/env/mod.rs:319:63
    |
319 |             ctx_note(&format!("the static max level is `{}`", STATIC_MAX_LEVEL));
    |                                                               ^^^^^^^^^^^^^^^^ `tracing::level_filters::LevelFilter` cannot be formatted with the default formatter
    |
    = help: the trait `std::fmt::Display` is not implemented for `tracing::level_filters::LevelFilter`
    = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
    = note: required by `std::fmt::Display::fmt`
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
error: could not compile `tracing-subscriber`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

Split into multiple crates and add feature flags

Split into multiple crates and add feature flags. For example, authentication could go as a separate crate. Or the GraphQL + SQLx etc. So that the boilerplate is minimal for someone looking to get started without any bells and whistles.

error mismatched types on startup

  1. A fresh checkout
  2. docker-compose -f docker-compose.yml up
  3. Error:
api_1      | Error: Error in Postgres: db error: ERROR: relation "movine_migrations" already exists
api_1      |   Applied - 2020-07-06-121519_create_sessions_table
api_1      |   Applied - 2020-07-06-120855_create_accounts_table
api_1      |   Applied - 1970-01-01-000000_movine_init
api_1      | ~> socket http://0.0.0.0:3535/
api_1      | [Running 'cargo run']
api_1      |    Compiling warp-api-starter-template v0.1.0 (/src-root)
api_1      | error[E0308]: mismatched types
api_1      |   --> src/main.rs:28:37
api_1      |    |
api_1      | 28 |     #[clap(required = true, short = "D", long, env)]
api_1      |    |                                     ^^^ expected `char`, found `&str`
api_1      | 
api_1      | error[E0308]: mismatched types
api_1      |   --> src/main.rs:30:37
api_1      |    |
api_1      | 30 |     #[clap(required = true, short = "R", long, env)]
api_1      |    |                                     ^^^ expected `char`, found `&str`
api_1      | 
api_1      | error: aborting due to 2 previous errors
api_1      | 
api_1      | For more information about this error, try `rustc --explain E0308`.
api_1      | error: could not compile `warp-api-starter-template`.
api_1      | 
api_1      | To learn more, run the command again with --verbose.
api_1      | [Finished running. Exit status: 101]

Slow compile times

It seems that something is causing excessively slow compile times. For instance, adding a simple println! costs nearly 40 seconds to recompile:

$ cargo run --database-url ...
   Compiling warp-api-starter-template v0.1.0 (/Users/max/Repositories/warp-api-starter-template)
    Finished dev [unoptimized + debuginfo] target(s) in 39.35s
     Running `target/debug/warp-api-starter-template`

Where the only change is:

diff --git a/src/environment/argon.rs b/src/environment/argon.rs
index b70bcd5..ce58cc9 100644
--- a/src/environment/argon.rs
+++ b/src/environment/argon.rs
@@ -15,6 +15,7 @@ impl Argon {
             argon_iterations,
             ..
         } = args;
+        println!("foo");
         Self {
             secret: argon_secret.to_owned(),
             memory_size: argon_memory_size.to_owned(),

This is actually decently faster than other compile times I've observed, which sometimes exceed two minutes (!) but are not significant changes.

Depending on your development style, this may be a showstopper.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.