Creating an API server in Rust with Rocket, SeaORM and JWT

Build your own REST API server with the safety and performance of Rust using Rocket, SeaORM and JWT authentication.

Ratings: 4.46 / 5.00




Description

In this course, we'll create a REST API server in Rust to represent a bookstore. This bookstore would allow us to add books and authors.


Using this system, we'll be able to:

  • Create, list, update and delete authors

  • Create, list, update and delete books

  • Associate and disassociate books and authors

  • List all books by a particular author


We'll learn how to:

  • Create a new Rust project using cargo

  • Build and run our Rust project

  • Add crates and enable crate features


We'll learn about basic API concepts such:

  • Routing and HTTP methods

  • Extracting data from HTTP requests

  • Interacting with the database to query and insert data

  • Creating user accounts

  • Authentication using JWT

  • Creating and using relationships between models to query and list associated data


Along with these concepts, we'll learn how to:

  • Handle incoming (request) and outgoing (response) data in a type safe way

  • Handle CORS

  • Create and run database migrations

  • Create one-to-many database relationships

  • Create entities from database tables


We'll have a bonus lecture at the end to learn how to Dockerize our API server to deploy and run it anywhere.


We'll be using the following crates:

  1. Rocket: a web framework for Rust that makes it simple to write fast, secure web applications without sacrificing flexibility, usability, or type safety.

  2. SeaORM: is a relational ORM to help you build web services in Rust.

  3. jsonwebtoken to create and decode JWTs in a strongly typed way.

  4. serde_json for serializing and deserializing Rust data structures efficiently and generically.


What You Will Learn!

  • Create a Rust project
  • Create a REST API server using Rocket
  • Interacting with a database using SeaORM
  • Authenticating APIs using JWT
  • Writing database migrations using SeaORM CLI

Who Should Attend!

  • Programmers curios about creating REST API servers and other projects using Rust
  • Beginner Rust developers looking to use the Rocket web framework
  • Beginner Rust developers looking to use SeaORM for database interactions
  • Beginner Rust developers curios about JWT authentication