-
Make sure Docker is installed and running
-
Make sure sqlx cli is installed
-
settup postgresql locally with docker: ``docker run -p 5432:5432 --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres````
-
Create a
.env
file. This file will store environment variables. Specifically,DATABASE_URL
andPOSTGRES_PASSWORD
. It should look like this:DATABASE_URL=postgres://postgres:mysecretpassword@localhost:5432/postgres
NOTE:
When deploying the API, make sure to change the default PostgreSQL password. -
To Test the api locally with Cargo:
$ cargo run
Add a user:
Create a post request to (in postman or an equivalent tool): localhost:3000/user,
body:
{ "name": "Daniel Ahmed", "email": "[email protected]" }
-
Update
docker-compose.yml
and changenuaip
to your own Docker Hub username.
- Run an instance of PostgreSQL. This can be done via Docker:
docker pull postgres docker run --name example-db -e POSTGRES_PASSWORD=postgrespw -p 5432:5432 -d postgres
- Run SQL migrations:
sqlx migrate run
- Start server:
cargo run
- Test routes. I like to use Postman.
- Run API via Docker Compose:
docker-compose up
- Test routes. I like to use Postman.