- Install Xcode
- Install Brew (if needed)
brew tap vapor/tap
brew install vapor/tap/vapor3
After cloning this repo be sure to install all required dependencies via:
swift package update
Download Postgres 11 if needed
Manually create databases for the app:
VaporTakeHome
Environment variables can be set by creating a .env
file.
An example.env
file is included as a template for the .env
file, this can be copied over and the change-me
s should be replaced.
Required environment variables are:
API_TOKEN
- Discogs API token sent to you by interviewerDATABASE_URL
- a postgres connection URL for the database set up above
vapor3 xcode
- Postgres must be running.
vapor3 run serve
or run button in Xcode
- Postgres must be running.
- Open Xcode and press:
⌘ + U
PostgreSQL Error: role "vapor" does not exist
and PostgreSQL Error: role "username" does not exist
indicate that the database connection string in the DATABASE_URL
or DATABASE_TEST_URL
contains a user value that does not currently exist in Postgres. Update the invalid role above with a valid one by granting the role access the database or creating the needed user role for that database.
This sample project is set up to manage Users in a postgres database and fetch artists from a 3rd party service (Discogs).
You will be adding new endpoints for searching for releases by artists and allowing users to create and manage playlists of these.
There is API documentation for what these endpoints should look like in api.yaml in the project root.
This documentation is in the OpenAPI (previously swagger) format and can be viewed using Swagger UI plugins in different editors, or by copying the contents of that document to http://editor.swagger.io
There is also a postman collection included that has both the existing and new endpoints included in this repo.
An endpoint does not exist on the Discogs API to search releases by both title and artist ID, so use the all releases by artist endpoint
documentation here: https://www.discogs.com/developers#page:database,header:database-artist-releases
and then filter the results by the search string passed in.
Release ids should be used for creating or deleting songs from a playlist. When fetching a playlist detail, fetch the details of each song and return them formatted to match the documentation.
An individual release can be fetched from Discogs using the endpoint documented here:
https://www.discogs.com/developers#page:database,header:database-release