Focal API is a Phoenix/Elixir API that pairs with Focal App.
To start your Phoenix server:
- Clone the project
git clone https://github.com/Focal-App/focal-api.git
- Navigate to project
cd focal-api
- Install dependencies with
mix deps.get
- Create and migrate your database with
mix ecto.setup
- Setup Environment Variables. Create a .env file in your project folder root and add the following
export GOOGLE_CLIENT_ID="Get from Teammate"
export GOOGLE_CLIENT_SECRET="Get from Teammate"
export CLIENT_HOST=http://localhost:<client_port>
- Start Phoenix endpoint
source .env
mix phx.server
- Run tests
source .env
mix text
- Optional - See all routes
mix phx.routes
. Note that all routes are authenticated except for/api/users
, which I purposely left public for demonstration purposes.
Now you can visit localhost:4000
from your browser.
Running routes with Postman is easiest on the local development.
- On your browser, open your developer console to the network tab
- Run the local frontend application and log in with google
- Move around the site until you see a cookie header pop up in the network tab
- Copy this into your Postman Request, COOKIE header
- Proceed with any requests
GET
/api/users/:user_uuid/clients
GET
/api/clients/:client_uuid/data
POST
/api/clients
PUT
/api/clients/:client_uuid
DELETE
/api/clients/:client_uuid
GET
/api/packages/:package_uuid
POST
/api/clients/:client_uuid/packages
PUT
/api/packages/:package_uuid
DELETE
/api/packages/:package_uuid
GET
/api/events/:event_uuid
POST
/api/packages/:package_uuid/events
PUT
/api/events/:event_uuid
DELETE
/api/events/:event_uuid
mix ecto.drop --repo FocalApi.Repo
mix ecto.create
mix ecto.migrate
mix run priv/repo/seeds.exs
mix ecto.rollback
mix ecto.migrate
mix run priv/repo/seeds.exs
dropdb focal_api_test
mix ecto.migrate
git push heroku <branch_name>:master
heroku pg:info // get db_name from add-on field.
heroku pg:reset DB_NAME
heroku run MIX_ENV=prod mix ecto.migrate
heroku run MIX_ENV=prod mix run priv/repo/seeds.exs
heroku restart
- Update schema and create new migration record
- Update any views related to the schema
- Drop Test database
- Run migration
- Run all tests
Migrations, when run, cannot be updated. If you need to make any updates to the migration changes you just made, you will need to either delete the migration file and create a new one with all correct changes. Or, create a new migration file specifying the changes you missed.