- Install latest version of Docker on your machine
- Create a file called
.env
in the root of this project and copy over the contents of.env.example
to it - After that run
docker compose up --scale nginx=0
(or if you have access to themake
command, runmake dc-start-local
instead) in a terminal and monitor the logs to see when the Rust has finished compiling - Once you see a message in the logs that reads something like
Running target/debug/rust-auth
, you should be good to go- I recommend running
docker logs --tail 10 -f rust-auth
to see the last few lines of the logs if you chose to rundocker compose
with the-d
flag
- I recommend running
Upon running the server, you should have access to a few endpoints:
Creates an account and returns to you a JWT that is valid for 24 hours
Request:
{
"username": "String",
"password": "String",
"email": "String"
}
Response:
{
"username": "String",
"email": "String",
"token": "String",
"id": "Number"
}
Returns to you your profile information along with a JWT that is valid for 24 hours.
Request:
{
"username": "String",
"password": "String",
}
Response:
{
"username": "String",
"email": "String",
"token": "String",
"id": "Number"
}
Returns your profile information
Request:
Just Bearer
token in the header
Response:
{
"username": "String",
"email": "String",
"id": "Number"
}
Invalidates the send up JWT, so that you cannot make any more requests with it.
Request:
Just Bearer
token in the header
Response:
{ }
All errors from the API come in this shape. field
is a key that typically maps to the problem field like email
if your email is taken or password
if your password doesn't meet requirements. error
will be some free-form text explaining what is wrong.
You may get back multiple objects at once, so you can map multiple errors to each field.
Array<{
"error": "String",
"field": "String"
}>
examples:
The steps to creating a migration and create an entity from it are as follows:
- First, make sure the
DATABASE_URL
variable is set in your root.env
file - Then, create the new migration file by running
sea-orm-cli migrate generate "name of migration"
- this will create a shell migration file and update the pointer to the latest migration. now, go ahead and edit the migration file
- Run the migrations against the database with
sea-orm-cli migrate up
- After the migrations have been applied, generate the entities with
sea-orm-cli generate entity -o entity/src
- Now, you're ready to start writing Rust code to interact with the database