Skip to content

hiterm/bookshelf-api

Repository files navigation

ci deploy

Bookshelf API

Backend server for Bookshelf.

How to run server

Set up Auth0

Set up auth0 by following:

https://auth0.com/developers/hub/code-samples/api/actix-web-rust/basic-authorization

Setup .env

mv .env.template .env
vim .env  # Fill your value

Run migration

cargo install sqlx-cli
sqlx migrate run

Start server

cargo run

Run via Docker Compose

cp .env.template .env.docker
vim .env.docker  # Fill your value
docker-compose up --build

Test

cargo test

E2E test

# 1) Start containers
cp .env.template .env.docker
docker compose -f docker-compose-test.yml up -d

# 2) Database setup (install sqlx if needed)
cargo install sqlx-cli --no-default-features --features postgres,rustls
sqlx database create
sqlx migrate run
docker compose -f docker-compose-test.yml exec -T db psql -U postgres -c "CREATE ROLE bookshelf WITH LOGIN PASSWORD 'password';"
docker compose -f docker-compose-test.yml exec -T db psql -U postgres -c "CREATE DATABASE bookshelf OWNER bookshelf;"

# 3) Start application server (in a separate terminal)
PORT=8080 AUTH0_AUDIENCE=<your-auth0-audience> AUTH0_DOMAIN=<your-auth0-domain> DATABASE_URL=<your-database-url> ALLOWED_ORIGINS=http://localhost:8080 \
  cargo run

# 4) Run E2E tests
TEST_SERVER_URL=http://localhost:8080 \
  cargo test -p bookshelf-e2e -- --test-threads=1

token

auth0 test token --no-input <client-id> -a <your-auth0-audience>

GraphQL Playground

Run server and access /graphql/playground.

Generate GraphQL schema

cargo run --bin gen_schema

Deploy to production

Publish a new release.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors