Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kanerix/rust-api-example


https://github.com/kanerix/rust-api-example

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# rust-api-example

This is an example repo that shows how i would implement a REST API using the Rust programming language.

!! To run this project you must have Rust installed on your system !!

### Requirements

#### Generate Public and Private key for JWT.

Run these commands:

1. `openssl genpkey -algorithm ed25519 -out keys/private.pem`
2. `openssl pkey -in keys/private.pem -pubout -out keys/public.pem`

### Start the project

- For SQLx to work properly, you also need to have a database.
- Run `docker compose up postgres -d` to start a development database.
- Full out a `.env` file with the `.env.example` variables.
- Migrate your database with `SQLx` (`sqlx migrate dev`).
- Run the command `cargo run`.

### Using docker

- Run `docker compose up -d` to start the project running in the background.