First, you need to create some environment variable files in the root directory. Below are their names and some examples.
HOST=0.0.0.0
PORT=1204
DATABASE=postgres
DATABASE_URL=postgres://username:password@db:5432/database_name
JWT_KEY=secret
JWT_EXPIRED_TIME=86400
RUST_LOG=DEBUG
POSTGRES_USER=username
POSTGRES_PASSWORD=password
POSTGRES_DB=database_name
And then, in the root of project, run docker-compose up -d
. Now you can use 127.0.0.1:1204
as your backend server.
This folder contains some migration files which auto-generated by diesel_cli.
- api/v1
- controllers: handler for each api.
- db: code to handle database (such as switch between DBMS).
- middlewares: put your middlewares here.
- models: store your database table structure here.
- routes: for routing your api endpoints.
- tests: do some unit testing here.
- types: everything related to types (Trait, Struct, ...).
- utils: some helper functions.
- config: Initialize server configuration.
All API endpoints are here.