Rest API
https://flow-api.herokuapp.com
Nodejs install via brew (OSX):
then, install nodejs package:
brew install node
NPM is used as dependencies/package manager.
To install the needed modules for this Nodejs app,
run the following command from the rootof the project:
sudo npm install
Note that these dependencies are not checked in on the repo and thus are only available on the local machine.
Create a .env file in the root directory of your project. Add these environment-specific variables on new lines in the form of NAME=VALUE:
DB_HOST=<PROJECTID>.mongolab.com
DB_NAME=database_name
DB_PORT=default_port
DB_USER=username
DB_PASSWORD=password
NODE_ENV=development
LOCAL_HOST=localhost
LOCAL_DBPORT=default_port
Startup mongo by running:
mongo
Create a database, named flow:
use flow
Sample data can be found in the samples dir, import by running:
via the provided shell script, found in root:
./data_import.sh
or manually on each file:
mongoimport -d db_name -c collection_name --file filename.json --jsonArray
Finally, from root of the project run:
nodemon app.js
Nodemon will monitor for any changes and automatically restart the server if needed. Open up a new browser tab and go to the follow to check if server is properly running:
| Path | Method | Parameters | Description |
|---|---|---|---|
| /api/v1/artists | GET | none | Retrieve all artists details. |
| /api/v1/artists/artistId | GET | String, artistName | Retrieve details for a specific artist. |
| Path | Method | Parameters | Description |
|---|---|---|---|
| /api/v1/albums | GET | none | Retrieve albums details. |
| /api/v1/albums/artistId | GET | String, artistName | Retrieve albums details for a specific artist. |
| Path | Method | Parameters | Description |
|---|---|---|---|
| /api/v1/tracks | GET | none | Retrieve all tracks details. |
| /api/v1/tracks/artistId | GET | String, artistName | Retrieve all tracks details for a specific artist. |
| */api/v1/tracks/albumId/ | GET | String, albumName | Retrieve all tracks details for a specific album. |
*Not yet implemented
| Path | Method | Parameters | Description |
|---|---|---|---|
| /api/v1/genres | GET | String | Retrieve all genres details. |
| /api/v1/genres/genreId | GET | String, genreName | Retrieve details for a specific genre. |
For every API endpoint there are tests, see test dir.
To run the Mocha tests, from root run:
npm test
Note that by running tests, the local mongodb is dropped and it's collections is dropped!
Every test will create a fresh collection and runs with that collection, afterwards
the collection will again be dropped. You will have to (re)run the data_import.sh script, as described here, to
get sample data in to the database.
Every change to the master branch will trigger an automatic deployment of the backend to Heroku, after a succeeded build by the CI buildserver.
The backend is accessible via:
https://flow-api.herokuapp.com
Copyright 2015 srmds
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.