swa07016

mysql DB연결(aws rds)

...@@ -3,3 +3,4 @@ json_datas.json ...@@ -3,3 +3,4 @@ json_datas.json
3 client/public/images 3 client/public/images
4 client/node_modules 4 client/node_modules
5 client/src/config 5 client/src/config
6 +database.json
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -31,6 +31,11 @@ ...@@ -31,6 +31,11 @@
31 "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", 31 "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
32 "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" 32 "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
33 }, 33 },
34 + "bignumber.js": {
35 + "version": "9.0.0",
36 + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz",
37 + "integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A=="
38 + },
34 "body-parser": { 39 "body-parser": {
35 "version": "1.19.0", 40 "version": "1.19.0",
36 "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", 41 "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
...@@ -150,6 +155,11 @@ ...@@ -150,6 +155,11 @@
150 "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 155 "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
151 "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" 156 "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
152 }, 157 },
158 + "core-util-is": {
159 + "version": "1.0.2",
160 + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
161 + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
162 + },
153 "date-fns": { 163 "date-fns": {
154 "version": "2.13.0", 164 "version": "2.13.0",
155 "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.13.0.tgz", 165 "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.13.0.tgz",
...@@ -347,6 +357,11 @@ ...@@ -347,6 +357,11 @@
347 "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", 357 "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
348 "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" 358 "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8="
349 }, 359 },
360 + "isarray": {
361 + "version": "1.0.0",
362 + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
363 + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
364 + },
350 "json-parse-better-errors": { 365 "json-parse-better-errors": {
351 "version": "1.0.2", 366 "version": "1.0.2",
352 "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", 367 "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
...@@ -404,6 +419,17 @@ ...@@ -404,6 +419,17 @@
404 "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 419 "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
405 "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 420 "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
406 }, 421 },
422 + "mysql": {
423 + "version": "2.18.1",
424 + "resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz",
425 + "integrity": "sha512-Bca+gk2YWmqp2Uf6k5NFEurwY/0td0cpebAucFpY/3jhrwrVGuxU2uQFCHjU19SJfje0yQvi+rVWdq78hR5lig==",
426 + "requires": {
427 + "bignumber.js": "9.0.0",
428 + "readable-stream": "2.3.7",
429 + "safe-buffer": "5.1.2",
430 + "sqlstring": "2.3.1"
431 + }
432 + },
407 "negotiator": { 433 "negotiator": {
408 "version": "0.6.2", 434 "version": "0.6.2",
409 "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", 435 "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
...@@ -478,6 +504,11 @@ ...@@ -478,6 +504,11 @@
478 "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", 504 "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
479 "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" 505 "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY="
480 }, 506 },
507 + "process-nextick-args": {
508 + "version": "2.0.1",
509 + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
510 + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
511 + },
481 "proxy-addr": { 512 "proxy-addr": {
482 "version": "2.0.6", 513 "version": "2.0.6",
483 "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", 514 "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz",
...@@ -528,6 +559,20 @@ ...@@ -528,6 +559,20 @@
528 "pify": "^3.0.0" 559 "pify": "^3.0.0"
529 } 560 }
530 }, 561 },
562 + "readable-stream": {
563 + "version": "2.3.7",
564 + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
565 + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
566 + "requires": {
567 + "core-util-is": "~1.0.0",
568 + "inherits": "~2.0.3",
569 + "isarray": "~1.0.0",
570 + "process-nextick-args": "~2.0.0",
571 + "safe-buffer": "~5.1.1",
572 + "string_decoder": "~1.1.1",
573 + "util-deprecate": "~1.0.1"
574 + }
575 + },
531 "require-directory": { 576 "require-directory": {
532 "version": "2.1.1", 577 "version": "2.1.1",
533 "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", 578 "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
...@@ -650,6 +695,11 @@ ...@@ -650,6 +695,11 @@
650 "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", 695 "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz",
651 "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==" 696 "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q=="
652 }, 697 },
698 + "sqlstring": {
699 + "version": "2.3.1",
700 + "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz",
701 + "integrity": "sha1-R1OT/56RR5rqYtyvDKPRSYOn+0A="
702 + },
653 "statuses": { 703 "statuses": {
654 "version": "1.5.0", 704 "version": "1.5.0",
655 "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", 705 "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
...@@ -665,6 +715,14 @@ ...@@ -665,6 +715,14 @@
665 "strip-ansi": "^5.1.0" 715 "strip-ansi": "^5.1.0"
666 } 716 }
667 }, 717 },
718 + "string_decoder": {
719 + "version": "1.1.1",
720 + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
721 + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
722 + "requires": {
723 + "safe-buffer": "~5.1.0"
724 + }
725 + },
668 "strip-ansi": { 726 "strip-ansi": {
669 "version": "5.2.0", 727 "version": "5.2.0",
670 "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", 728 "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
...@@ -710,6 +768,11 @@ ...@@ -710,6 +768,11 @@
710 "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 768 "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
711 "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" 769 "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
712 }, 770 },
771 + "util-deprecate": {
772 + "version": "1.0.2",
773 + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
774 + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
775 + },
713 "utils-merge": { 776 "utils-merge": {
714 "version": "1.0.1", 777 "version": "1.0.1",
715 "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 778 "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
18 "body-parser": "^1.19.0", 18 "body-parser": "^1.19.0",
19 "concurrently": "^5.2.0", 19 "concurrently": "^5.2.0",
20 "express": "^4.17.1", 20 "express": "^4.17.1",
21 - "iconv-lite": "^0.5.1" 21 + "iconv-lite": "^0.5.1",
22 + "mysql": "^2.18.1"
22 } 23 }
23 } 24 }
......
1 const express = require('express'); 1 const express = require('express');
2 const bodyParser = require('body-parser'); 2 const bodyParser = require('body-parser');
3 const fs = require('fs'); 3 const fs = require('fs');
4 +const mysql = require('mysql');
4 var iconv = require('iconv-lite'); 5 var iconv = require('iconv-lite');
5 6
6 const app = express(); 7 const app = express();
...@@ -8,10 +9,24 @@ const port = process.env.PORT || 5000; ...@@ -8,10 +9,24 @@ const port = process.env.PORT || 5000;
8 9
9 const dataBuffer = fs.readFileSync('json_datas.json') 10 const dataBuffer = fs.readFileSync('json_datas.json')
10 11
12 +
13 +// db connection
14 +const data = fs.readFileSync('./database.json');
15 +const conf = JSON.parse(data);
16 +
17 +const connection = mysql.createConnection({
18 + host: conf.host,
19 + user: conf.user,
20 + password: conf.password,
21 + port: conf.port,
22 + database: conf.database
23 +});
24 +
25 +connection.connect();
26 +
11 app.use(bodyParser.json()); 27 app.use(bodyParser.json());
12 app.use(bodyParser.urlencoded({ extended: true })); 28 app.use(bodyParser.urlencoded({ extended: true }));
13 29
14 -
15 app.get('/api/hello', (req, res) => { 30 app.get('/api/hello', (req, res) => {
16 res.send('Hello skrrrr!'); 31 res.send('Hello skrrrr!');
17 }); 32 });
......