This commit is contained in:
Rodrigo Pinto 2019-12-17 01:07:08 -05:00
commit 306b26caac
4 changed files with 113 additions and 31 deletions

2
.gitignore vendored
View file

@ -22,7 +22,7 @@
.env.development.local
.env.test.local
.env.production.local
/config
config.json
npm-debug.log*
yarn-debug.log*

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Rodrigo Pedroso Leite Pinto
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

119
README.md
View file

@ -1,5 +1,95 @@
# React Spotify API
## App structure
Single-page application written in ReactJS to harness the Spotify API.
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
The app uses React hooks to hold state and effects.
Props are passed between components through the router, built with react-router-dom.
```
.
├── public
│   ├── favicon.ico
│   ├── index.html
│   ├── logo192.png
│   ├── logo512.png
│   ├── manifest.json
│   └── robots.txt
├── src
│   ├── components
│   │   ├── Album.jsx
│   │   ├── Album.scss
│   │   ├── Artist.jsx
│   │   ├── Artist.scss
│   │   └── Router.jsx
│   ├── views
│   │   ├── Albums.jsx
│   │   ├── ArtistSearch.jsx
│   │   ├── ArtistSearch.scss
│   │   ├── Login.jsx
│   │   └── Login.scss
│   ├── App.css
│   ├── App.js
│   ├── App.test.js
│   ├── history.js
│   ├── index.css
│   ├── index.js
│   ├── logo.svg
│   ├── serviceWorker.js
│   └── setupTests.js
├── README.md
├── config.json
├── package-lock.json
├── package.json
├── pbcopy
└── server.js
```
4 directories, 31 files
## Installation
1. Setup a Spotify account and [register an application](https://developer.spotify.com/documentation/general/guides/app-settings/#register-your-app);
2. Clone this repository;
3. Create a file at the root called `config.json` containing 3 information: *client_id*, *client_secret* and *redirect_uri*.
This file is ignored in commits to the repository, and without it the app won't work.
It should look like this:
```json
{
"client_id": "94cf43fb07ab3ds8a5c8891eadc461a1",
"client_secret": "4d6aeac027254230b773e41p353bbdc1",
"redirect_uri": "http://localhost:8888/callback"
}
```
Use the *client_id* and *client_secret* from the app you created in your Spotify account.
Keep the *redirect_api* as shown above.
4. Install dependencies:
npm i
5. Initiate the server:
node server.js
6. Start the app:
npm start
7. A browser should open with the app. If not, open one and navigate to http://localhost:3000.
## Available Scripts
In the project directory, you can run:
@ -37,32 +127,3 @@ Instead, it will copy all the configuration files and the transitive dependencie
You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
### Analyzing the Bundle Size
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
### Making a Progressive Web App
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
### Advanced Configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
### Deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
### `npm run build` fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

View file

@ -12,7 +12,7 @@ const request = require('request'); // "Request" library
const cors = require('cors');
const querystring = require('querystring');
const cookieParser = require('cookie-parser');
const env = require('./config/config.json')
const env = require('./config.json')
const client_id = env.client_id
const client_secret = env.client_secret