API Server
Test using Docker
To simplify the process of bringing up the test environment we will use
docker-compose
1# Download docker compose file
2wget https://raw.githubusercontent.com/prest/prest/main/docker-compose-prod.yml -O docker-compose.yml
3
4# Up (run) PostgreSQL and prestd
5docker-compose up
6# Run data migration to create user structure for access (JWT)
7docker-compose exec prest prestd migrate up auth
8
9# Create user and password for API access (via JWT)
10## user: prest
11## pass: prest
12docker-compose exec postgres psql -d prest -U prest -c "INSERT INTO prest_users (name, username, password) VALUES ('pREST Full Name', 'prest', MD5('prest'))"
13# Check if the user was created successfully (by doing a select on the table)
14docker-compose exec postgres psql -d prest -U prest -c "select * from prest_users"
15
16# Generate JWT Token with user and password created
17curl -i -X POST http://127.0.0.1:3000/auth -H "Content-Type: application/json" -d '{"username": "prest", "password": "prest"}'
18# Access endpoint using JWT Token
19curl -i -X GET http://127.0.0.1:3000/prest/public/prest_users -H "Accept: application/json" -H "Authorization: Bearer {TOKEN}"
Supported Operating System
- Linux
- macOS
- Windows
- BSD
Download the latest version binary here!