Skip to content

Latest commit

 

History

History
168 lines (152 loc) · 3.23 KB

README.md

File metadata and controls

168 lines (152 loc) · 3.23 KB

WeR1 Backend

Apollo Server wrapper for Music Story API

Local Setup (with Docker)

  1. Install Docker
  2. Install Docker Compose
  3. Clone the repository and change into it
git clone [email protected]:SrMoffat/wer1-backend.git
cd wer1-backend
  1. Start the database and the app
docker-compose up --build
  1. Open app
http://localhost:4000/graphql

Local Setup (without Docker)

You need to install PostgreSQL on your machine and run it:

e.g. on Mac OS:

brew install postgresql
brew services start postgresql

When the postgreSQL database it up and running then:

  1. Clone the repository and change into it
git clone [email protected]:SrMoffat/wer1-backend.git
cd wer1-backend
  1. Create environment variables file using template
cat .env.example >> .env
  1. Create a Music Story Account and set the following environment variables in .env:
export MUSIC_STORY_CONSUMER_KEY=
export MUSIC_STORY_CONSUMER_SECRET=
export MUSIC_STORY_ACCESS_TOKEN=
export MUSIC_STORY_ACCESS_TOKEN_SECRET=
export APP_SECRET_KEY=this can be any random string
  1. Add DB credentials to be used for PostgreSQL
export POSTGRES_USER="postgres"
export POSTGRES_PASSWORD="postgres"
export POSTGRES_DB="dev"

// Add server port
export PORT=4000
  1. Export environment variables and then start the server
docker-compose up --build

Queries to test

Sign Up User

mutation signupMutation($email: String!, $password: String!, $name: String!) {
  signup(email: $email, password: $password, name: $name) {
    token
    user {
       id
       name
       email
    }
  }
}
Login User

mutation loginMutation($email: String!, $password: String!) {
  login(email: $email, password: $password) {
    token
    user {
      id
      name
      email
    }
  }
}
Fetch Tracks

query fetchTracksQuery {
  fetchTracks {
    externalId
    title
    type
    length
    isrc
    creationDate
    productionDate
  }
}
Search Track by Title

query searchTrackQuery($title: String!) {
  searchTrackByTitle(title: $title) {
    externalId
    title
    type
    length
    isrc
    creationDate
    productionDate
  } 
}
Search Track by Internal ID

query searchTrackByInternalId($internalId: Int!) {
  searchTrackByInternalId(internalId: $internalId) {
    externalId
    title
    type
    length
    isrc
    creationDate
    productionDate
  } 
}
Update Track Details by ID

mutation updateTrackMutation($creationDate: String, $internalId: String, $isrc: String, $productionDate: String, $title: String, $type: String) {
  updateTrack(creationDate: $creationDate, internalId: $internalId, isrc: $isrc, productionDate: $productionDate, title: $title, type: $type) {
     externalId
    title
    type
    length
    isrc
    creationDate
    productionDate
    
  }
}
Delete Track by ID

mutation deleteTrackMutation($internalId: Int) {
  deleteTrack(internalId: $internalId) {
    externalId
    title
    type
    length
    isrc
    creationDate
    productionDate
    
  }
}