diff --git a/frontend/src/actions/playlistActions.js b/frontend/src/actions/playlistActions.js index 598f9ac0a894f413f0a6625e0d75d1ff1a4aee4a..e275d5df3f79fea9e18fd2bfab232549ed77af47 100644 --- a/frontend/src/actions/playlistActions.js +++ b/frontend/src/actions/playlistActions.js @@ -49,7 +49,7 @@ export const getGenres = () => dispatch => { export const getUnsavedPlaylists = (owner) => dispatch => { dispatch(setUnsavedPlaylistLoading()); console.log(owner); - axios.get(`https://thespotifierapp.herokuapp.com/parties/${owner}/0`) + axios.get(`https://thespotifierapp.herokuapp.com/api/parties/${owner}/0`) .then(res => dispatch({ type: GET_UNSAVEDPLAYLISTS, @@ -65,7 +65,7 @@ export const getUnsavedPlaylists = (owner) => dispatch => { export const getPartyDetails = (partyId) => dispatch => { dispatch(setPartyDetailsLoading()); - axios.get(`https://thespotifierapp.herokuapp.com/partydetails/${partyId}`) + axios.get(`https://thespotifierapp.herokuapp.com/api/partydetails/${partyId}`) .then(res => dispatch({ type: GET_PARTYDETAILS, @@ -95,7 +95,7 @@ export const addPlaylist = (plData,history,owner) => dispatch =>{ } axios - .post(`https://thespotifierapp.herokuapp.com/addparty/${owner}`,updatedplData) + .post(`https://thespotifierapp.herokuapp.com/api/addparty/${owner}`,updatedplData) .then(res => { dispatch({ type: ADDED_PLAYLIST, @@ -112,10 +112,10 @@ export const addPlaylist = (plData,history,owner) => dispatch =>{ export const savePlaylist = (body,history) => dispatch => { axios - .post(`https://thespotifierapp.herokuapp.com/saveplaylist/${body.id}`, body) + .post(`https://thespotifierapp.herokuapp.com/api/saveplaylist/${body.id}`, body) .then(res => { history.push('/dashboard') - window.location.href="https://thespotifierapp.herokuapp.com//dashboard" + window.location.href="https://thespotifierapp.herokuapp.com/dashboard" dispatch({ type: ADDED_PLAYLIST, payload: {} @@ -154,7 +154,7 @@ export const editPlaylist = (id,plData,history) => dispatch => export const deletePlaylist = (id,history) => dispatch => { axios - .delete(`https://thespotifierapp.herokuapp.com/deleteparty/${id}`) + .delete(`https://thespotifierapp.herokuapp.com/api/deleteparty/${id}`) .then(res => { history.push('/dashboard'); window.location.href="https://thespotifierapp.herokuapp.com/dashboard" diff --git a/server.js b/server.js index 033c9990e418fb1687c6f90b430eeff4fdb7ff87..34d378366b3ee38643ebda97aecad164f332f9ce 100644 --- a/server.js +++ b/server.js @@ -68,7 +68,7 @@ app.get('/callback', function (req, res) { request.post(authOptions, function (error, response, body) { var access_token = body.access_token console.log(access_token); - let uri = process.env.FRONTEND_URI || 'https://thespotifierapp.herokuapp.com/:3000/' + let uri = process.env.FRONTEND_URI || 'https://thespotifierapp.herokuapp.com/' uri= uri + '?access_token=' + access_token console.log(req.query.state); if (req.query.state){ @@ -80,7 +80,7 @@ app.get('/callback', function (req, res) { }) }); -app.get('/parties/:owner/:saved', (req, res) => { +app.get('/api/parties/:owner/:saved', (req, res) => { const owner = req.params.owner const status = req.params.saved db.all('SELECT party.id, party_owner, party_name, num_tracks, genres, COUNT(party_members.id) AS memberCount FROM party LEFT JOIN party_members ON party.id = party_members.party_id WHERE party.party_owner=? AND party.saved=? GROUP BY party.id;', [owner, status], @@ -89,7 +89,7 @@ app.get('/parties/:owner/:saved', (req, res) => { }); }); -app.post('/addparty/:owner', (req, res) => { +app.post('/api/addparty/:owner', (req, res) => { if (req.body.party_name == undefined || req.body.party_genres == undefined) { return res.status(400).json({message: 'Missing request body'}); } @@ -105,7 +105,7 @@ db.run('INSERT INTO party(party_owner,party_name, genres,num_tracks) VALUES (?,? }) }); -app.post('/joinparty/:partyid', (req, res) => { +app.post('/api/joinparty/:partyid', (req, res) => { if (req.body.member_id == undefined || req.body.member_name == undefined || req.body.token == undefined) { return res.status(400).json({message: 'Missing request body'}) } @@ -189,7 +189,7 @@ app.post('/joinparty/:partyid', (req, res) => { }); -app.get('/memberlist/:partyid', (req,res) => { +app.get('/api/memberlist/:partyid', (req,res) => { const party_id = req.params.partyid; db.all('SELECT member_name, member_id FROM party_members WHERE party_id=?', [party_id], (err, rows) => { @@ -197,7 +197,7 @@ app.get('/memberlist/:partyid', (req,res) => { }); }); -app.get('/partydetails/:partyid', (req,res) => { +app.get('/api/partydetails/:partyid', (req,res) => { const partyId = req.params.partyid db.all('SELECT party_name FROM party WHERE id=?', [partyId], (err,rows) => { @@ -219,7 +219,7 @@ app.get('/partydetails/:partyid', (req,res) => { }); -app.delete('/deleteparty/:id', (req,res) => { +app.delete('/api/deleteparty/:id', (req,res) => { db.run('DELETE FROM party WHERE id=?',[req.params.id], () =>{ db.run('DELETE FROM party_members WHERE party_id=?', [req.params.id], () =>{ db.run('DELETE FROM songs WHERE party_id=?',[req.params.id], () =>{ @@ -229,7 +229,7 @@ app.delete('/deleteparty/:id', (req,res) => { }) }); -app.post('/saveplaylist/:id', (req,res) => { +app.post('/api/saveplaylist/:id', (req,res) => { var config ={ headers: {Authorization: 'Bearer ' + req.body.token} }; @@ -273,10 +273,6 @@ app.post('/saveplaylist/:id', (req,res) => { }); -app.post('/teszt' , (req,res) => { - res.send(status(200)) -}); - const port = process.env.PORT || 8888 console.log( `Listening on port ${port}. Go /login to initiate authentication flow.`)