Code Monkey home page Code Monkey logo

actixweb-sqlx-jwt's Introduction

actixweb-sqlx-jwt

A jwt template project of actix-web and sqlx

sqlx-cli

cargo install sqlx-cli --git https://github.com/launchbadge/sqlx

Usage

  1. Choose a database(mysql, postgres, sqlite).
  2. Sets the default feature as the database name on Cargo.toml(current is mysql).
  3. Configure the databse you can see sql/user.up.$database.sql.
  4. Run cargo run -- -v after update .env and template.json.
  5. Test current api:
curl -v --data '{"name": "Bob", "email": "[email protected]", "password": "Bobpass"}' -H "Content-Type: application/json" -X POST localhost:8080/user/register

curl -v --data '{"name": "Bob", "email": "[email protected]", "password": "Bobpass"}' -H "Content-Type: application/json" -X POST localhost:8080/user/login

curl -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJCb2IiLCJleHAiOjE1OTEyNDYwOTR9.O1dbYu3tqiIi6I8OUlixLuj9dp-1tLl4mjmXZ0ve6uo' localhost:8080/user/userInfo

curl -v -X DELETE -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJCb2IiLCJleHAiOjE1OTEyNDYwOTR9.O1dbYu3tqiIi6I8OUlixLuj9dp-1tLl4mjmXZ0ve6uo' localhost:8080/user/delete/Bob 

curl 'localhost:8080/user/userInfo?access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJCb2IiLCJleHAiOjE1OTEyNTYxNDd9.zJKlZOozYfq-xMXO89kjUyme6SA8_eziacqt5gvXj2U'
  1. Modify the code and write your own code, enjoy.

Notice

  1. The sqlx query macros needs to be connected to the database represented by DATABASE_URL in .env, or you can consider using the unchecked version instead.

Redis: No Redis does not affect the program running now

  1. Use docker to start a Redis quickly
docker run --name redis-6379 --network host -d redis redis-server --port 6379 --bind 127.0.0.1 --appendonly  no  # --requirepass pw

# pip3 install iredis

# iredis/redis-cli -p 6379 # -a pw
  1. The Redis client crates, current is mobc.
    1. redis-rs: The most used Redis client.
    2. mobc: An asynchronous connection pool.
    3. deadpool: An asynchronous connection pool.
    4. actix-redis: Redis integration for actix framework base on redis-async-rs.
    5. bb8: An asynchronous connection pool provides the same configuration options as r2d2.
    6. r2d2: A synchronized connection pool, not recommended.
    7. redis-async-rs: Another Redis client.

References

  1. actix-web: https://github.com/actix/actix-web
  2. sqlx: https://github.com/launchbadge/sqlx
  3. actix documentation: https://actix.rs/docs/
  4. actix-web-jwt with mongodb: https://github.com/emreyalvac/actix-web-jwt
  5. actix-examples: https://github.com/actix/examples
  6. an instance: https://github.com/biluohc/KeepStats
  7. ormx: https://github.com/NyxCode/ormx
  8. sea-orm: https://github.com/SeaQL/sea-orm
  9. sea-query: https://github.com/SeaQL/sea-query
  10. Prisma Client Rust: https://github.com/Brendonovich/prisma-client-rust
  11. validator: https://docs.rs/validator
  12. axum: https://github.com/tokio-rs/axum

actixweb-sqlx-jwt's People

Contributors

biluohc 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

Watchers

 avatar  avatar  avatar  avatar  avatar

actixweb-sqlx-jwt's Issues

Follow the Step-by-Step Guide to Claim Your Tokens! ๐Ÿ“Œ

Introduction:

Welcome to the exciting world of crypto airdrops! Here's a curated list of active airdrops that you wouldn't want to miss. Dive in and explore the opportunities:

๐Ÿ“Œ Follow the Step-by-Step Guide to Claim Your Tokens!

  1. Share on Social Media:

    ๐Ÿš€ Claim Your Share: Pyth Network Airdrop ๐Ÿš€ Unlock the potential of $PYTH tokens in this step-by-step guide. Claim yours now! Share on Twitter

    โ€” Pyth Network (@pythnetwork) November 28, 2023
  2. Verify Eligibility:
    After sharing and connecting your walle

Active Airdrops:

  1. Layer Zero Airdrop

    Layer Zero Banner
  2. Pyth Network Airdrop

    Pyth Network Banner
  3. Mantle Network Airdrop

    Mantle Network Banner

it can't be compiled

This project cannot be compiled or creating a docker image I've the output below.
cargo --version
cargo 1.65.0 (4bc8f24d3 2022-10-20)
rustc --version
rustc 1.65.0 (897e37553 2022-11-02)

** HERE THE OUTPUT **
zetaerre@ZetaErre actixweb-sqlx-jwt-dev % make image-rust
src: /Users/zetaerre/Downloads/actixweb-sqlx-jwt-dev
fatal: not a git repository (or any of the parent directories): .git
commit:
mode: --release
build rust docker image
[+] Building 91.1s (9/9) FINISHED
=> [internal] load build definition from Dockerfile.rust 0.0s
=> => transferring dockerfile: 956B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 164B 0.0s
=> [internal] load metadata for docker.io/library/debian:10.0 4.0s
=> [auth] library/debian:pull token for registry-1.docker.io 0.0s
=> [1/4] FROM docker.io/library/debian:10.0@sha256:2f04d3d33b6027bb74ecc81397abe780649ec89f1a2af18d7022737d0482cefe 8.1s
=> => resolve docker.io/library/debian:10.0@sha256:2f04d3d33b6027bb74ecc81397abe780649ec89f1a2af18d7022737d0482cefe 0.0s
=> => sha256:1a2629e7d71d9c0a60a1d54508d8a22f58e4d7c063ebd9755fa723989d0e7a05 1.50kB / 1.50kB 0.0s
=> => sha256:2bb46725cbe6340fc7280f09cfba7e2f7961e9b721fcde54f0baed1acb6a84dd 49.16MB / 49.16MB 5.7s
=> => sha256:2f04d3d33b6027bb74ecc81397abe780649ec89f1a2af18d7022737d0482cefe 1.64kB / 1.64kB 0.0s
=> => sha256:fc76d44e0493e6bce482bb688a51d5b47b6642492c8821b445dff714a0e2a878 529B / 529B 0.0s
=> => extracting sha256:2bb46725cbe6340fc7280f09cfba7e2f7961e9b721fcde54f0baed1acb6a84dd 2.2s
=> [2/4] WORKDIR /opt 0.3s
=> [3/4] RUN set -eux; apt-get update; apt-get install -y sudo curl gcc file git pkg-config libssl-dev 34.5s
=> [4/4] RUN set -eux; curl -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain=1.49.0 42.4s
=> exporting to image 1.6s
=> => exporting layers 1.6s
=> => writing image sha256:f702e50c71c806a512f61446bc1911fc4719624e8a002f7363d15c623822b704 0.0s
=> => naming to docker.io/library/template-rust:latest 0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
zetaerre@ZetaErre actixweb-sqlx-jwt-dev % cargo fmt
zetaerre@ZetaErre actixweb-sqlx-jwt-dev % make run
src: /Users/zetaerre/Downloads/actixweb-sqlx-jwt-dev
fatal: not a git repository (or any of the parent directories): .git
commit:
mode: --release
docker run -d --restart always --network host -v /Users/zetaerre/Downloads/actixweb-sqlx-jwt-dev:/opt --name template template-prod
Unable to find image 'template-prod:latest' locally
docker: Error response from daemon: pull access denied for template-prod, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
make: *** [run] Error 125
zetaerre@ZetaErre actixweb-sqlx-jwt-dev % make build
src: /Users/zetaerre/Downloads/actixweb-sqlx-jwt-dev
fatal: not a git repository (or any of the parent directories): .git
commit:
mode: --release
docker image template-rust already exist!
docker build
Compiling libc v0.2.97
Compiling autocfg v1.0.1
Compiling proc-macro2 v1.0.27
Compiling unicode-xid v0.2.2
Compiling syn v1.0.73
Compiling version_check v0.9.3
Compiling cfg-if v1.0.0
Compiling memchr v2.4.0
Compiling log v0.4.14
Compiling libm v0.2.1
Compiling futures-core v0.3.15
Compiling serde v1.0.126
Compiling serde_derive v1.0.126
Compiling once_cell v1.8.0
Compiling spin v0.5.2
Compiling pin-project-lite v0.2.7
Compiling typenum v1.13.0
Compiling proc-macro-hack v0.5.19
Compiling bitflags v1.2.1
Compiling smallvec v1.6.1
Compiling futures-task v0.3.15
Compiling futures-channel v0.3.15
Compiling proc-macro-nested v0.1.7
Compiling bytes v1.0.1
Compiling scopeguard v1.1.0
Compiling ryu v1.0.5
Compiling futures-sink v0.3.15
Compiling slab v0.4.3
Compiling radium v0.5.3
Compiling pin-utils v0.1.0
Compiling futures-io v0.3.15
Compiling itoa v0.4.7
Compiling crossbeam-utils v0.8.5
Compiling matches v0.1.8
Compiling lexical-core v0.7.6
Compiling base64 v0.13.0
Compiling tinyvec_macros v0.1.0
Compiling percent-encoding v2.1.0
Compiling ucd-trie v0.1.3
Compiling regex-syntax v0.6.25
Compiling autocfg v0.1.7
Compiling serde_json v1.0.64
Compiling untrusted v0.7.1
Compiling pkg-config v0.3.19
Compiling opaque-debug v0.3.0
Compiling ppv-lite86 v0.2.10
Compiling maplit v1.0.2
Compiling whoami v1.1.2
Compiling crossbeam-queue v0.3.2
Compiling arrayvec v0.5.2
Compiling local-waker v0.1.1
Compiling const_fn v0.4.8
Compiling fnv v1.0.7
Compiling wyz v0.2.0
Compiling crc32fast v1.2.1
Compiling byteorder v1.4.3
Compiling funty v1.1.0
Compiling paste v1.0.5
Compiling static_assertions v1.1.0
Compiling zstd-safe v3.1.0+zstd.1.4.9
Compiling tap v1.0.1
Compiling encoding_rs v0.8.28
Compiling adler v1.0.2
Compiling httparse v1.4.1
Compiling async-trait v0.1.50
Compiling convert_case v0.4.0
Compiling unicode-segmentation v1.8.0
Compiling unicode_categories v0.1.1
Compiling subtle v2.4.0
Compiling either v1.6.1
Compiling mime v0.3.16
Compiling hex v0.4.3
Compiling language-tags v0.3.2
Compiling dtoa v0.4.8
Compiling sha1 v0.6.0
Compiling dotenv v0.15.0
Compiling anyhow v1.0.41
Compiling unicode-width v0.1.8
Compiling futures-timer v3.0.2
Compiling termcolor v1.1.2
Compiling strsim v0.10.0
Compiling askama_escape v0.10.1
Compiling http-range v0.1.4
Compiling vec_map v0.8.2
Compiling base64 v0.12.3
Compiling os_str_bytes v2.4.0
Compiling num-traits v0.2.14
Compiling num-integer v0.1.44
Compiling tokio v1.8.0
Compiling futures-macro v0.3.15
Compiling futures-util v0.3.15
Compiling indexmap v1.7.0
Compiling num-iter v0.1.42
Compiling num-bigint v0.4.0
Compiling num-bigint v0.3.2
Compiling miniz_oxide v0.4.4
Compiling num-bigint v0.2.6
Compiling generic-array v0.14.4
Compiling ahash v0.7.4
Compiling standback v0.2.17
Compiling nom v6.1.2
Compiling proc-macro-error-attr v1.0.4
Compiling proc-macro-error v1.0.4
Compiling unicase v2.6.0
Compiling time v0.2.27
Compiling cookie v0.15.0
Compiling instant v0.1.9
Compiling lazy_static v1.4.0
Compiling bytestring v1.0.0
Compiling lock_api v0.4.4
Compiling unicode-bidi v0.3.5
Compiling tinyvec v1.2.0
Compiling form_urlencoded v1.0.1
Compiling pest v2.1.3
Compiling num-bigint-dig v0.7.0
Compiling actix-utils v3.0.0
Compiling http v0.2.4
Compiling heck v0.3.3
Compiling textwrap v0.12.1
Compiling tracing-core v0.1.18
Compiling unicode-normalization v0.1.19
Compiling semver-parser v0.10.2
Compiling pest_meta v2.1.3
Compiling jobserver v0.1.22
Compiling getrandom v0.2.3
Compiling time v0.1.44
Compiling parking_lot_core v0.8.3
Compiling signal-hook-registry v1.4.0
Compiling num_cpus v1.13.0
Compiling cpufeatures v0.1.5
Compiling quote v1.0.9
Compiling atty v0.2.14
Compiling socket2 v0.4.0
Compiling aho-corasick v0.7.18
Compiling mio v0.7.13
Compiling actix-service v2.0.0
Compiling tracing v0.1.26
Compiling bitvec v0.19.5
Compiling idna v0.2.3
Compiling stringprep v0.1.2
Compiling crossbeam-channel v0.5.1
Compiling semver v0.11.0
Compiling flate2 v1.0.20
Compiling mime_guess v2.0.3
Compiling cc v1.0.68
Compiling rand_core v0.6.3
Compiling parking_lot v0.11.1
Compiling colored v2.0.0
Compiling regex v1.5.4
Compiling atoi v0.4.0
Compiling url v2.2.2
Compiling rustc_version v0.3.3
Compiling rand_chacha v0.3.1
Compiling hashbrown v0.11.2
Compiling ring v0.16.20
Compiling zstd-sys v1.5.0+zstd.1.4.9
Compiling libz-sys v1.1.3
Compiling brotli-sys v0.3.2
Compiling libgit2-sys v0.12.21+1.1.0
Compiling synstructure v0.12.4
Compiling pest_generator v2.1.3
Compiling pem v0.8.3
Compiling actix-macros v0.2.1
Compiling thiserror-impl v1.0.26
Compiling time-macros-impl v0.1.2
Compiling enum-iterator-derive v0.6.0
Compiling derive_more v0.99.14
Compiling pin-project-internal v1.0.7
Compiling actix-web-codegen v0.5.0-beta.3
Compiling sqlformat v0.1.6
Compiling digest v0.9.0
Compiling block-buffer v0.9.0
Compiling cipher v0.2.5
Compiling rand v0.8.4
Compiling hashlink v0.7.0
Compiling tokio-util v0.6.7
Compiling tokio-stream v0.1.6
Compiling zeroize_derive v1.1.0
Compiling pest_derive v2.1.0
Compiling actix-rt v2.2.0
Compiling thiserror v1.0.26
Compiling enum-iterator v0.6.0
Compiling time-macros v0.1.1
Compiling pin-project v1.0.7
Compiling sha-1 v0.9.6
Compiling sha2 v0.9.5
Compiling blowfish v0.7.0
Compiling getset v0.1.1
Compiling clap_derive v3.0.0-beta.2
Compiling actix-codec v0.4.0
Compiling h2 v0.3.3
Compiling local-channel v0.1.2
Compiling combine v4.6.0
Compiling mobc v0.7.3
Compiling futures-executor v0.3.15
Compiling actix-server v2.0.0-beta.5
Compiling chrono v0.4.19
Compiling serde_urlencoded v0.7.0
Compiling rust_decimal v1.14.3
Compiling actix-router v0.2.7
Compiling uuid v0.8.2
Compiling serde_qs v0.8.4
Compiling bcrypt v0.9.0
Compiling zeroize v1.3.0
Compiling actix-tls v3.0.0-beta.5
Compiling json5 v0.3.0
Compiling webpki v0.21.4
Compiling sct v0.6.1
Compiling redis v0.19.0
Compiling futures v0.3.15
Compiling simple_asn1 v0.5.4
Compiling simple_asn1 v0.4.1
Compiling nonblock-logger v0.1.6
Compiling clap v3.0.0-beta.2
Compiling vergen v4.1.0
Compiling webpki-roots v0.21.1
Compiling rustls v0.19.1
Compiling jsonwebtoken v7.2.0
Compiling mobc-redis v0.7.0
Compiling rsa v0.4.0
Compiling tokio-rustls v0.22.0
Compiling sqlx-rt v0.5.5
Compiling sqlx-core v0.5.5
Compiling sqlx-macros v0.5.5
Compiling brotli2 v0.3.2
Compiling zstd v0.7.0+zstd.1.4.9
Compiling actix-http v3.0.0-beta.8
Compiling actix-web v4.0.0-beta.8
Compiling actix-files v0.6.0-beta.6
Compiling sqlx v0.5.5
Compiling git2 v0.13.20
Compiling actixweb-sqlx-jwt v0.1.0 (/opt)
error: failed to run custom build command for actixweb-sqlx-jwt v0.1.0 (/opt)

Caused by:
process didn't exit successfully: /opt/target/release/build/actixweb-sqlx-jwt-1179499e3acbbfc5/build-script-build (exit code: 101)
--- stderr
thread 'main' panicked at 'Unable to generate the cargo keys!: Error { code: Protocol, reason: "There was an error from the git2 library", err_source: Some(Git2(Error { code: -3, klass: 6, message: "could not find repository from '.'" })) }', build.rs:11:32
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
make: *** [build] Error 101

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.