Skip to content

Commit

Permalink
chore: backend cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
esteban committed Jun 21, 2021
1 parent a4b4688 commit 1850e06
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 37 deletions.
37 changes: 1 addition & 36 deletions server/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import express from "express";
import axios from "axios"
import { friendsURL, playURL } from "./constants"
import { anyRejectionAnswer400 } from "./predicates"
import TwilioService from "./services";
Expand All @@ -13,41 +12,7 @@ app.get("/api/users/:username", async (req, res, next) => {
// your code here!
const { username } = req?.params;


// const allUserFriendsPromise = axios.get(`${friendsURL.listAll}`)
// const userFriendsDetailsPromise = axios.get(`${friendsURL.detailUserName}${username}`)
// const allUsersPlayInfoPromise = axios.get(`${playURL.listAllUsers}`)
// const userNamePlayDetailsPromise = axios.get(`${playURL.detailUserName}${username}`)

// const promises = [
// allUserFriendsPromise,
// userFriendsDetailsPromise,
// allUsersPlayInfoPromise,
// userNamePlayDetailsPromise
// ]

// const generateBody = result => {
// const dataCleanup = answer => answer?.value?.data
// const [
// allUserFriends,
// userFriendsDetails,
// allUsersPlayInfo,
// userNamePlayDetails
// ] = result.map(dataCleanup)


// return {
// username: username,
// friends: userFriendsDetails.friends.length,
// plays: allUsersPlayInfo.plays.filter(isUserPlay(username)).length,
// tracks: userNamePlayDetails.plays.filter(onlyUnique),
// uri: URIFactory(username)
// }
// }

const promises = twilioService.generatePromises(username)

Promise.allSettled(promises)
Promise.allSettled(twilioService.generatePromises(username))
.then((results) => {
console.log(`Hello ${username}`)
anyRejectionAnswer400(results) ?
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const reducer = (state, action) => {
case actionTypes.SEARCH_TERM: return Object.assign({}, state, { searchTerm: action.payload })
case actionTypes.GET_SUGGESTIONS: return Object.assign({}, state, { getSuggetions: action.payload })
case actionTypes.UPDATE_USER_DETAILS: return Object.assign({}, state, { userDetail: action.payload, searchTerm: "" })
// escape hatch for async data fetching
// escape hatch for async data fetching to be solved with useEffect
case actionTypes.ENTER_KEY_PRESSED: {
axios.get(`/api/users/${state.searchTerm}`)
.then(result => action.dispatch({ type: actionTypes.UPDATE_USER_DETAILS, payload: result.data }))
Expand Down

0 comments on commit 1850e06

Please sign in to comment.