Git Product home page Git Product logo

clerk-rs's Introduction

crates.io download count badge

An unofficial Clerk SDK for Rust

For more detailed documentation, please reference the below links:

This SDK is updated frequently to keep up with any changes to the actual Clerk API. If you see anything that needs updated or is not inline with the official Clerk api, please open an issue!

Example

Checkout examples in the /examples directory

Using a traditional http request to a valid clerk endpoint:

use tokio;
use clerk_rs::{clerk::Clerk, ClerkConfiguration, endpoints::ClerkGetEndpoint};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = ClerkConfiguration::new(None, None, Some("sk_test_key".to_string()), None);
    let client = Clerk::new(config);

    let res = client.get(ClerkGetEndpoint::GetUserList).await?;

    Ok(())
}

Using a clerk-rs method:

use tokio;
use clerk_rs::{clerk::Clerk, ClerkConfiguration, apis::emails_api::Email};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = ClerkConfiguration::new(None, None, Some("sk_test_key".to_string()), None);
    let client = Clerk::new(config);

    Email::create(&client, Some(your_clerk_email));

    Ok(())
}

Protecting a actix-web endpoint with Clerk.dev:

use actix_web::{web, App, HttpServer, Responder};
use clerk_rs::{ClerkConfiguration, validators::actix::ClerkMiddleware};

async fn index() -> impl Responder {
    "Hello world!"
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {

    HttpServer::new(|| {
        let config = ClerkConfiguration::new(None, None, Some("sk_test_key".to_string()), None);
        App::new().service(
            web::scope("/app")
                .wrap(ClerkMiddleware::new(config, None, false))
                .route("/index", web::get().to(index)),
        )
    })
    .bind(("127.0.0.1", 8080))?
    .run()
    .await
}

Roadmap

  • Support other http clients along with the default reqwest client (like hyper)
  • Tokio and async-std async runtimes for hyper clients
  • Optional reqwest blocking client
  • Support authorization via __session cookie on same-origin
  • Add validator support for axum, rocket, warp

Production users

  • Tembo
  • Rezon
  • Open a PR and add your company here :)

Note: This SDK is completely maintained by the Rust community and is by no means affiliated with Clerk.dev.


clerk-rs's People

Contributors

darrenbaldwin07 avatar sjmiller609 avatar alexene avatar vrmiguel avatar camilomcatasus avatar notusertelken avatar chymtt avatar

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.