From c8519ed1452246355c85aff6a8458bfffa13789b Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 5 Dec 2020 21:02:45 -0600 Subject: [PATCH 1/3] back-end endpoint add_to_library --- back-end/index.js | 40 +++++++++++++++-- back-end/package-lock.json | 5 +++ back-end/package.json | 3 +- front-end/.eslintcache | 2 +- front-end/package-lock.json | 90 +++++++++++++++++++++---------------- front-end/package.json | 2 +- 6 files changed, 98 insertions(+), 44 deletions(-) diff --git a/back-end/index.js b/back-end/index.js index 70af35e..d2a2ca1 100644 --- a/back-end/index.js +++ b/back-end/index.js @@ -18,12 +18,46 @@ app.use(express.json()) // END POINTS +//test +//response.send(

hey this is working

) +//start up the back end node index.js, copy paste endpoint into the localhost:3001/add_to_library +//look at the documentation - either console log or respond +//console/log([data]) +//response.json([data]) +//or just actually check the database -app.get('/', (request, response) => { - response.send('

Hello world!

') +app.post('/add_to_library', async (request, response) => { -}) + const body = request.body + + /* + track number, title, artist, url + */ + + try{ + + const data = { + "track 1": { + "id" : body.id, + "title" : body.title, + "artist" : body.artist, + "url" : body.url + } + } + //there's probably a cleaner way to do this + + + db.collection('moods').doc('happy').set(data); + // ----------EDIT CODE ABOVE HERE + } catch(error){ + console.log(error) + } + response.send('

Received the data!') +//console.log(data) +//response.json(data) + +}) diff --git a/back-end/package-lock.json b/back-end/package-lock.json index 41cab9e..4879a69 100644 --- a/back-end/package-lock.json +++ b/back-end/package-lock.json @@ -736,6 +736,11 @@ "resolved": "https://registry.npmjs.org/idb/-/idb-3.0.2.tgz", "integrity": "sha512-+FLa/0sTXqyux0o6C+i2lOR0VoS60LU/jzUo5xjfY6+7sEEgy4Gz1O7yFBXvjd7N0NyIGWIRg8DcQSLEG+VSPw==" }, + "index.js": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/index.js/-/index.js-0.0.3.tgz", + "integrity": "sha1-JzOx9IbciQ7QJpiQJPWC2DXFI6w=" + }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", diff --git a/back-end/package.json b/back-end/package.json index a976f07..f4b0a3c 100644 --- a/back-end/package.json +++ b/back-end/package.json @@ -14,6 +14,7 @@ "axios": "^0.21.0", "cors": "^2.8.5", "express": "^4.17.1", - "firebase": "^8.1.2" + "firebase": "^8.1.2", + "index.js": "0.0.3" } } diff --git a/front-end/.eslintcache b/front-end/.eslintcache index ec8f2c5..e35bfa3 100644 --- a/front-end/.eslintcache +++ b/front-end/.eslintcache @@ -1 +1 @@ -[{"C:\\Users\\Aliah\\Documents\\projects\\actual\\techtogether-hack\\front-end\\src\\App.js":"1","C:\\Users\\Aliah\\Documents\\projects\\actual\\techtogether-hack\\front-end\\src\\index.js":"2","C:\\Users\\Aliah\\Documents\\projects\\actual\\techtogether-hack\\front-end\\src\\views\\library.jsx":"3","C:\\Users\\Aliah\\Documents\\projects\\actual\\techtogether-hack\\front-end\\src\\views\\find.jsx":"4"},{"size":498,"mtime":1607133314479,"results":"5","hashOfConfig":"6"},{"size":198,"mtime":1607132095966,"results":"7","hashOfConfig":"6"},{"size":168,"mtime":1607133043445,"results":"8","hashOfConfig":"6"},{"size":172,"mtime":1607133058478,"results":"9","hashOfConfig":"6"},{"filePath":"10","messages":"11","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"19at9bg",{"filePath":"12","messages":"13","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"14","messages":"15","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"16","messages":"17","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\Aliah\\Documents\\projects\\actual\\techtogether-hack\\front-end\\src\\App.js",["18"],"C:\\Users\\Aliah\\Documents\\projects\\actual\\techtogether-hack\\front-end\\src\\index.js",[],"C:\\Users\\Aliah\\Documents\\projects\\actual\\techtogether-hack\\front-end\\src\\views\\library.jsx",["19"],"C:\\Users\\Aliah\\Documents\\projects\\actual\\techtogether-hack\\front-end\\src\\views\\find.jsx",["20"],{"ruleId":"21","severity":1,"message":"22","line":2,"column":17,"nodeType":"23","messageId":"24","endLine":2,"endColumn":21},{"ruleId":"21","severity":1,"message":"25","line":1,"column":17,"nodeType":"23","messageId":"24","endLine":1,"endColumn":25},{"ruleId":"21","severity":1,"message":"25","line":1,"column":17,"nodeType":"23","messageId":"24","endLine":1,"endColumn":25},"no-unused-vars","'Link' is defined but never used.","Identifier","unusedVar","'useState' is defined but never used."] \ No newline at end of file +[{"C:\\Users\\Emily\\techtogether-hack\\front-end\\src\\index.js":"1","C:\\Users\\Emily\\techtogether-hack\\front-end\\src\\App.js":"2","C:\\Users\\Emily\\techtogether-hack\\front-end\\src\\views\\library.jsx":"3","C:\\Users\\Emily\\techtogether-hack\\front-end\\src\\views\\find.jsx":"4","C:\\Users\\Emily\\techtogether-hack\\front-end\\src\\views\\share.jsx":"5"},{"size":209,"mtime":1607139646288,"results":"6","hashOfConfig":"7"},{"size":517,"mtime":1607139646265,"results":"8","hashOfConfig":"7"},{"size":168,"mtime":1607139646291,"results":"9","hashOfConfig":"7"},{"size":172,"mtime":1607139646290,"results":"10","hashOfConfig":"7"},{"size":174,"mtime":1607139646291,"results":"11","hashOfConfig":"7"},{"filePath":"12","messages":"13","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"njx27l",{"filePath":"14","messages":"15","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"16","messages":"17","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"18","messages":"19","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"20","messages":"21","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\Emily\\techtogether-hack\\front-end\\src\\index.js",[],"C:\\Users\\Emily\\techtogether-hack\\front-end\\src\\App.js",["22"],"C:\\Users\\Emily\\techtogether-hack\\front-end\\src\\views\\library.jsx",["23"],"C:\\Users\\Emily\\techtogether-hack\\front-end\\src\\views\\find.jsx",["24"],"C:\\Users\\Emily\\techtogether-hack\\front-end\\src\\views\\share.jsx",["25"],{"ruleId":"26","severity":1,"message":"27","line":2,"column":17,"nodeType":"28","messageId":"29","endLine":2,"endColumn":21},{"ruleId":"26","severity":1,"message":"30","line":1,"column":17,"nodeType":"28","messageId":"29","endLine":1,"endColumn":25},{"ruleId":"26","severity":1,"message":"30","line":1,"column":17,"nodeType":"28","messageId":"29","endLine":1,"endColumn":25},{"ruleId":"26","severity":1,"message":"30","line":1,"column":17,"nodeType":"28","messageId":"29","endLine":1,"endColumn":25},"no-unused-vars","'Link' is defined but never used.","Identifier","unusedVar","'useState' is defined but never used."] \ No newline at end of file diff --git a/front-end/package-lock.json b/front-end/package-lock.json index 39ed20e..009cc7e 100644 --- a/front-end/package-lock.json +++ b/front-end/package-lock.json @@ -1824,6 +1824,8 @@ }, "@testing-library/jest-dom": { "version": "5.11.6", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.11.6.tgz", + "integrity": "sha512-cVZyUNRWwUKI0++yepYpYX7uhrP398I+tGz4zOlLVlUYnZS+Svuxv4fwLeCIy7TnBYKXUaOlQr3vopxL8ZfEnA==", "requires": { "@babel/runtime": "^7.9.2", "@types/testing-library__jest-dom": "^5.9.1", @@ -1848,6 +1850,8 @@ }, "@testing-library/react": { "version": "11.2.2", + "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-11.2.2.tgz", + "integrity": "sha512-jaxm0hwUjv+hzC+UFEywic7buDC9JQ1q3cDsrWVSDAPmLotfA6E6kUHlYm/zOeGCac6g48DR36tFHxl7Zb+N5A==", "requires": { "@babel/runtime": "^7.12.5", "@testing-library/dom": "^7.28.1" @@ -1855,6 +1859,8 @@ }, "@testing-library/user-event": { "version": "12.5.0", + "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-12.5.0.tgz", + "integrity": "sha512-9uXr4+OwjHVUxzdfYZ2yCnF3xlEzr8cZOdqjGnqD8Qb1NoCJrm7UXxG3RUpL2QqcqZ1eqVuxkFJTCky5Yit+XQ==", "requires": { "@babel/runtime": "^7.10.2" } @@ -2095,12 +2101,12 @@ "integrity": "sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw==" }, "@typescript-eslint/eslint-plugin": { - "version": "4.8.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.8.1.tgz", - "integrity": "sha512-d7LeQ7dbUrIv5YVFNzGgaW3IQKMmnmKFneRWagRlGYOSfLJVaRbj/FrBNOBC1a3tVO+TgNq1GbHvRtg1kwL0FQ==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.9.0.tgz", + "integrity": "sha512-WrVzGMzzCrgrpnQMQm4Tnf+dk+wdl/YbgIgd5hKGa2P+lnJ2MON+nQnbwgbxtN9QDLi8HO+JAq0/krMnjQK6Cw==", "requires": { - "@typescript-eslint/experimental-utils": "4.8.1", - "@typescript-eslint/scope-manager": "4.8.1", + "@typescript-eslint/experimental-utils": "4.9.0", + "@typescript-eslint/scope-manager": "4.9.0", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", @@ -2109,50 +2115,50 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "4.8.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.8.1.tgz", - "integrity": "sha512-WigyLn144R3+lGATXW4nNcDJ9JlTkG8YdBWHkDlN0lC3gUGtDi7Pe3h5GPvFKMcRz8KbZpm9FJV9NTW8CpRHpg==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.9.0.tgz", + "integrity": "sha512-0p8GnDWB3R2oGhmRXlEnCvYOtaBCijtA5uBfH5GxQKsukdSQyI4opC4NGTUb88CagsoNQ4rb/hId2JuMbzWKFQ==", "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/scope-manager": "4.8.1", - "@typescript-eslint/types": "4.8.1", - "@typescript-eslint/typescript-estree": "4.8.1", + "@typescript-eslint/scope-manager": "4.9.0", + "@typescript-eslint/types": "4.9.0", + "@typescript-eslint/typescript-estree": "4.9.0", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { - "version": "4.8.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.8.1.tgz", - "integrity": "sha512-QND8XSVetATHK9y2Ltc/XBl5Ro7Y62YuZKnPEwnNPB8E379fDsvzJ1dMJ46fg/VOmk0hXhatc+GXs5MaXuL5Uw==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.9.0.tgz", + "integrity": "sha512-QRSDAV8tGZoQye/ogp28ypb8qpsZPV6FOLD+tbN4ohKUWHD2n/u0Q2tIBnCsGwQCiD94RdtLkcqpdK4vKcLCCw==", "requires": { - "@typescript-eslint/scope-manager": "4.8.1", - "@typescript-eslint/types": "4.8.1", - "@typescript-eslint/typescript-estree": "4.8.1", + "@typescript-eslint/scope-manager": "4.9.0", + "@typescript-eslint/types": "4.9.0", + "@typescript-eslint/typescript-estree": "4.9.0", "debug": "^4.1.1" } }, "@typescript-eslint/scope-manager": { - "version": "4.8.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.8.1.tgz", - "integrity": "sha512-r0iUOc41KFFbZdPAdCS4K1mXivnSZqXS5D9oW+iykQsRlTbQRfuFRSW20xKDdYiaCoH+SkSLeIF484g3kWzwOQ==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.9.0.tgz", + "integrity": "sha512-q/81jtmcDtMRE+nfFt5pWqO0R41k46gpVLnuefqVOXl4QV1GdQoBWfk5REcipoJNQH9+F5l+dwa9Li5fbALjzg==", "requires": { - "@typescript-eslint/types": "4.8.1", - "@typescript-eslint/visitor-keys": "4.8.1" + "@typescript-eslint/types": "4.9.0", + "@typescript-eslint/visitor-keys": "4.9.0" } }, "@typescript-eslint/types": { - "version": "4.8.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.8.1.tgz", - "integrity": "sha512-ave2a18x2Y25q5K05K/U3JQIe2Av4+TNi/2YuzyaXLAsDx6UZkz1boZ7nR/N6Wwae2PpudTZmHFXqu7faXfHmA==" + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.9.0.tgz", + "integrity": "sha512-luzLKmowfiM/IoJL/rus1K9iZpSJK6GlOS/1ezKplb7MkORt2dDcfi8g9B0bsF6JoRGhqn0D3Va55b+vredFHA==" }, "@typescript-eslint/typescript-estree": { - "version": "4.8.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.8.1.tgz", - "integrity": "sha512-bJ6Fn/6tW2g7WIkCWh3QRlaSU7CdUUK52shx36/J7T5oTQzANvi6raoTsbwGM11+7eBbeem8hCCKbyvAc0X3sQ==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.9.0.tgz", + "integrity": "sha512-rmDR++PGrIyQzAtt3pPcmKWLr7MA+u/Cmq9b/rON3//t5WofNR4m/Ybft2vOLj0WtUzjn018ekHjTsnIyBsQug==", "requires": { - "@typescript-eslint/types": "4.8.1", - "@typescript-eslint/visitor-keys": "4.8.1", + "@typescript-eslint/types": "4.9.0", + "@typescript-eslint/visitor-keys": "4.9.0", "debug": "^4.1.1", "globby": "^11.0.1", "is-glob": "^4.0.1", @@ -2162,11 +2168,11 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "4.8.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.8.1.tgz", - "integrity": "sha512-3nrwXFdEYALQh/zW8rFwP4QltqsanCDz4CwWMPiIZmwlk9GlvBeueEIbq05SEq4ganqM0g9nh02xXgv5XI3PeQ==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.9.0.tgz", + "integrity": "sha512-sV45zfdRqQo1A97pOSx3fsjR+3blmwtdCt8LDrXgCX36v4Vmz4KHrhpV6Fo2cRdXmyumxx11AHw0pNJqCNpDyg==", "requires": { - "@typescript-eslint/types": "4.8.1", + "@typescript-eslint/types": "4.9.0", "eslint-visitor-keys": "^2.0.0" } }, @@ -5537,9 +5543,9 @@ "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==" }, "eslint-webpack-plugin": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/eslint-webpack-plugin/-/eslint-webpack-plugin-2.4.0.tgz", - "integrity": "sha512-j0lAJj3RnStAFdIH2P0+nsEImiBijwogZhL1go4bI6DE+9OhQuOmJ/xtmxkLtNr1w0cf5SRNkDlmIe8t/pHgww==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/eslint-webpack-plugin/-/eslint-webpack-plugin-2.4.1.tgz", + "integrity": "sha512-cj8iPWZKuAiVD8MMgTSunyMCAvxQxp5mxoPHZl1UMGkApFXaXJHdCFcCR+oZEJbBNhReNa5SjESIn34uqUbBtg==", "requires": { "@types/eslint": "^7.2.4", "arrify": "^2.0.1", @@ -11081,6 +11087,8 @@ }, "react": { "version": "17.0.1", + "resolved": "https://registry.npmjs.org/react/-/react-17.0.1.tgz", + "integrity": "sha512-lG9c9UuMHdcAexXtigOZLX8exLWkW0Ku29qPRU8uhF2R9BN96dLCt0psvzPLlHc5OWkgymP3qwTRgbnw5BKx3w==", "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1" @@ -11219,6 +11227,8 @@ }, "react-dom": { "version": "17.0.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.1.tgz", + "integrity": "sha512-6eV150oJZ9U2t9svnsspTMrWNyHc6chX0KzDeAOXftRa8bNeOKTTfCJ7KorIwenkHd2xqVTBTCZd79yk/lx/Ug==", "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1", @@ -11288,6 +11298,8 @@ }, "react-scripts": { "version": "4.0.1", + "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-4.0.1.tgz", + "integrity": "sha512-NnniMSC/wjwhcJAyPJCWtxx6CWONqgvGgV9+QXj1bwoW/JI++YF1eEf3Upf/mQ9KmP57IBdjzWs1XvnPq7qMTQ==", "requires": { "@babel/core": "7.12.3", "@pmmmwh/react-refresh-webpack-plugin": "0.4.2", @@ -14257,7 +14269,9 @@ } }, "web-vitals": { - "version": "0.2.4" + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-0.2.4.tgz", + "integrity": "sha512-6BjspCO9VriYy12z356nL6JBS0GYeEcA457YyRzD+dD6XYCQ75NKhcOHUMHentOE7OcVCIXXDvOm0jKFfQG2Gg==" }, "webidl-conversions": { "version": "6.1.0", diff --git a/front-end/package.json b/front-end/package.json index 4fc61a6..3214b0e 100644 --- a/front-end/package.json +++ b/front-end/package.json @@ -9,7 +9,7 @@ "react": "^17.0.1", "react-dom": "^17.0.1", "react-router-dom": "^5.2.0", - "react-scripts": "4.0.1", + "react-scripts": "^4.0.1", "web-vitals": "^0.2.4" }, "scripts": { From 3f803e98d95cd2f09a4d61bd3ca876431b31d716 Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 5 Dec 2020 21:46:27 -0600 Subject: [PATCH 2/3] figured out the tracks --- back-end/index.js | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/back-end/index.js b/back-end/index.js index d2a2ca1..f415dd7 100644 --- a/back-end/index.js +++ b/back-end/index.js @@ -18,44 +18,20 @@ app.use(express.json()) // END POINTS -//test -//response.send(

hey this is working

) -//start up the back end node index.js, copy paste endpoint into the localhost:3001/add_to_library -//look at the documentation - either console log or respond -//console/log([data]) -//response.json([data]) -//or just actually check the database app.post('/add_to_library', async (request, response) => { const body = request.body - - /* - track number, title, artist, url - */ - try{ - - const data = { - "track 1": { - "id" : body.id, - "title" : body.title, - "artist" : body.artist, - "url" : body.url - } - } - //there's probably a cleaner way to do this - + try{ - db.collection('moods').doc('happy').set(data); + db.collection('moods').doc('happy').update(body); // ----------EDIT CODE ABOVE HERE } catch(error){ console.log(error) } response.send('

Received the data!') -//console.log(data) -//response.json(data) }) From ba622f43e0b273e99fbd553af5d75c946b231b9b Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 6 Dec 2020 11:52:40 -0600 Subject: [PATCH 3/3] endpoint add --- back-end/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back-end/index.js b/back-end/index.js index f415dd7..b617c18 100644 --- a/back-end/index.js +++ b/back-end/index.js @@ -17,7 +17,7 @@ app.use(express.static('build')) app.use(express.json()) -// END POINTS +// END POINTS - add_to_library app.post('/add_to_library', async (request, response) => {