Showing
7 changed files
with
468 additions
and
103 deletions
... | @@ -9,6 +9,7 @@ var indexRouter = require('./routes/index'); | ... | @@ -9,6 +9,7 @@ var indexRouter = require('./routes/index'); |
9 | var userRouter = require('./routes/userlogin/user'); | 9 | var userRouter = require('./routes/userlogin/user'); |
10 | var loginRouter = require('./routes/userlogin/login'); | 10 | var loginRouter = require('./routes/userlogin/login'); |
11 | var registerRouter = require('./routes/userlogin/register'); | 11 | var registerRouter = require('./routes/userlogin/register'); |
12 | +var folderRouter = require('./routes/folders'); | ||
12 | 13 | ||
13 | 14 | ||
14 | var passport = require('passport'); | 15 | var passport = require('passport'); |
... | @@ -17,19 +18,19 @@ var config = require('./routes/modules/config'); | ... | @@ -17,19 +18,19 @@ var config = require('./routes/modules/config'); |
17 | 18 | ||
18 | //port | 19 | //port |
19 | passport.serializeUser(function(user, done) { | 20 | passport.serializeUser(function(user, done) { |
20 | - console.log('serialized'); | 21 | + console.log('serialized'); |
21 | - done(null, user); | 22 | + done(null, user); |
22 | }); | 23 | }); |
23 | passport.deserializeUser(function(user, done) { | 24 | passport.deserializeUser(function(user, done) { |
24 | - console.log('deserialized'); | 25 | + console.log('deserialized'); |
25 | - done(null, user); | 26 | + done(null, user); |
26 | }); | 27 | }); |
27 | 28 | ||
28 | 29 | ||
29 | var app = express(); | 30 | var app = express(); |
30 | 31 | ||
31 | // view engine setup | 32 | // view engine setup |
32 | -app.set('views', [path.join(__dirname, 'views'),path.join(__dirname ,'dist')]); | 33 | +app.set('views', [path.join(__dirname, 'views'), path.join(__dirname, 'dist')]); |
33 | // app.set('view engine', 'ejs'); | 34 | // app.set('view engine', 'ejs'); |
34 | 35 | ||
35 | app.use(logger('dev')); | 36 | app.use(logger('dev')); |
... | @@ -39,9 +40,9 @@ app.use(cookieParser()); | ... | @@ -39,9 +40,9 @@ app.use(cookieParser()); |
39 | app.use(express.static(path.join(__dirname, 'public'))); | 40 | app.use(express.static(path.join(__dirname, 'public'))); |
40 | 41 | ||
41 | app.use(session({ | 42 | app.use(session({ |
42 | - secret: 'mykey', | 43 | + secret: 'mykey', |
43 | - saveUninitialized: true, | 44 | + saveUninitialized: true, |
44 | - resave: true | 45 | + resave: true |
45 | })); | 46 | })); |
46 | 47 | ||
47 | app.use(express.static('public')); | 48 | app.use(express.static('public')); |
... | @@ -54,22 +55,23 @@ app.use('/api/', indexRouter); | ... | @@ -54,22 +55,23 @@ app.use('/api/', indexRouter); |
54 | app.use('/api/user', userRouter); | 55 | app.use('/api/user', userRouter); |
55 | app.use('/api/login', loginRouter); | 56 | app.use('/api/login', loginRouter); |
56 | app.use('/api/RegistUser', registerRouter); | 57 | app.use('/api/RegistUser', registerRouter); |
58 | +app.use('/api/folder', folderRouter); | ||
57 | //app.use('/users', usersRouter); | 59 | //app.use('/users', usersRouter); |
58 | 60 | ||
59 | // catch 404 and forward to error handler | 61 | // catch 404 and forward to error handler |
60 | app.use(function(req, res, next) { | 62 | app.use(function(req, res, next) { |
61 | - next(createError(404)); | 63 | + next(createError(404)); |
62 | }); | 64 | }); |
63 | 65 | ||
64 | // error handler | 66 | // error handler |
65 | app.use(function(err, req, res, next) { | 67 | app.use(function(err, req, res, next) { |
66 | - // set locals, only providing error in development | 68 | + // set locals, only providing error in development |
67 | - res.locals.message = err.message; | 69 | + res.locals.message = err.message; |
68 | - res.locals.error = req.app.get('env') === 'development' ? err : {}; | 70 | + res.locals.error = req.app.get('env') === 'development' ? err : {}; |
69 | 71 | ||
70 | - // render the error page | 72 | + // render the error page |
71 | - res.status(err.status || 500); | 73 | + res.status(err.status || 500); |
72 | - res.render('error'); | 74 | + res.render('error'); |
73 | }); | 75 | }); |
74 | 76 | ||
75 | -module.exports = app; | 77 | +module.exports = app; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -153,6 +153,11 @@ | ... | @@ -153,6 +153,11 @@ |
153 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", | 153 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", |
154 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" | 154 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" |
155 | }, | 155 | }, |
156 | + "base64-js": { | ||
157 | + "version": "1.3.1", | ||
158 | + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", | ||
159 | + "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" | ||
160 | + }, | ||
156 | "basic-auth": { | 161 | "basic-auth": { |
157 | "version": "2.0.1", | 162 | "version": "2.0.1", |
158 | "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", | 163 | "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", |
... | @@ -200,6 +205,16 @@ | ... | @@ -200,6 +205,16 @@ |
200 | "concat-map": "0.0.1" | 205 | "concat-map": "0.0.1" |
201 | } | 206 | } |
202 | }, | 207 | }, |
208 | + "buffer": { | ||
209 | + "version": "4.9.1", | ||
210 | + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", | ||
211 | + "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", | ||
212 | + "requires": { | ||
213 | + "base64-js": "^1.0.2", | ||
214 | + "ieee754": "^1.1.4", | ||
215 | + "isarray": "^1.0.0" | ||
216 | + } | ||
217 | + }, | ||
203 | "bytes": { | 218 | "bytes": { |
204 | "version": "3.0.0", | 219 | "version": "3.0.0", |
205 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", | 220 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", |
... | @@ -438,6 +453,11 @@ | ... | @@ -438,6 +453,11 @@ |
438 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", | 453 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", |
439 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" | 454 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" |
440 | }, | 455 | }, |
456 | + "events": { | ||
457 | + "version": "1.1.1", | ||
458 | + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", | ||
459 | + "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" | ||
460 | + }, | ||
441 | "express": { | 461 | "express": { |
442 | "version": "4.16.4", | 462 | "version": "4.16.4", |
443 | "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", | 463 | "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", |
... | @@ -650,6 +670,11 @@ | ... | @@ -650,6 +670,11 @@ |
650 | "safer-buffer": ">= 2.1.2 < 3" | 670 | "safer-buffer": ">= 2.1.2 < 3" |
651 | } | 671 | } |
652 | }, | 672 | }, |
673 | + "ieee754": { | ||
674 | + "version": "1.1.13", | ||
675 | + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", | ||
676 | + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" | ||
677 | + }, | ||
653 | "inherits": { | 678 | "inherits": { |
654 | "version": "2.0.3", | 679 | "version": "2.0.3", |
655 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", | 680 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", |
... | @@ -720,6 +745,11 @@ | ... | @@ -720,6 +745,11 @@ |
720 | "minimatch": "^3.0.4" | 745 | "minimatch": "^3.0.4" |
721 | } | 746 | } |
722 | }, | 747 | }, |
748 | + "jmespath": { | ||
749 | + "version": "0.15.0", | ||
750 | + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", | ||
751 | + "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" | ||
752 | + }, | ||
723 | "js-stringify": { | 753 | "js-stringify": { |
724 | "version": "1.0.2", | 754 | "version": "1.0.2", |
725 | "resolved": "https://registry.npmjs.org/js-stringify/-/js-stringify-1.0.2.tgz", | 755 | "resolved": "https://registry.npmjs.org/js-stringify/-/js-stringify-1.0.2.tgz", |
... | @@ -829,6 +859,11 @@ | ... | @@ -829,6 +859,11 @@ |
829 | "brace-expansion": "^1.1.7" | 859 | "brace-expansion": "^1.1.7" |
830 | } | 860 | } |
831 | }, | 861 | }, |
862 | + "moment": { | ||
863 | + "version": "2.26.0", | ||
864 | + "resolved": "https://registry.npmjs.org/moment/-/moment-2.26.0.tgz", | ||
865 | + "integrity": "sha512-oIixUO+OamkUkwjhAVE18rAMfRJNsNe/Stid/gwHSOfHrOtw9EhAY2AHvdKZ/k/MggcYELFCJz/Sn2pL8b8JMw==" | ||
866 | + }, | ||
832 | "morgan": { | 867 | "morgan": { |
833 | "version": "1.9.1", | 868 | "version": "1.9.1", |
834 | "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz", | 869 | "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz", |
... | @@ -1066,15 +1101,26 @@ | ... | @@ -1066,15 +1101,26 @@ |
1066 | "integrity": "sha512-GMu3M5nUL3fju4/egXwZO0XLi6fW/K3T3VTgFQ14GxNi8btlxgT5qZL//JwZFm/2Fa64J/PNS8AZeys3wiMkVA==" | 1101 | "integrity": "sha512-GMu3M5nUL3fju4/egXwZO0XLi6fW/K3T3VTgFQ14GxNi8btlxgT5qZL//JwZFm/2Fa64J/PNS8AZeys3wiMkVA==" |
1067 | }, | 1102 | }, |
1068 | "punycode": { | 1103 | "punycode": { |
1104 | +<<<<<<< HEAD | ||
1069 | "version": "2.1.1", | 1105 | "version": "2.1.1", |
1070 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", | 1106 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", |
1071 | "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" | 1107 | "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" |
1108 | +======= | ||
1109 | + "version": "1.3.2", | ||
1110 | + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", | ||
1111 | + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" | ||
1112 | +>>>>>>> 677e924ea1f8968d4b256c5c0ca83390eb370802 | ||
1072 | }, | 1113 | }, |
1073 | "qs": { | 1114 | "qs": { |
1074 | "version": "6.5.2", | 1115 | "version": "6.5.2", |
1075 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", | 1116 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", |
1076 | "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" | 1117 | "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" |
1077 | }, | 1118 | }, |
1119 | + "querystring": { | ||
1120 | + "version": "0.2.0", | ||
1121 | + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", | ||
1122 | + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" | ||
1123 | + }, | ||
1078 | "random-bytes": { | 1124 | "random-bytes": { |
1079 | "version": "1.0.0", | 1125 | "version": "1.0.0", |
1080 | "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", | 1126 | "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", |
... | @@ -1173,6 +1219,11 @@ | ... | @@ -1173,6 +1219,11 @@ |
1173 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", | 1219 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", |
1174 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" | 1220 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" |
1175 | }, | 1221 | }, |
1222 | + "sax": { | ||
1223 | + "version": "1.2.1", | ||
1224 | + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", | ||
1225 | + "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" | ||
1226 | + }, | ||
1176 | "send": { | 1227 | "send": { |
1177 | "version": "0.16.2", | 1228 | "version": "0.16.2", |
1178 | "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", | 1229 | "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", |
... | @@ -1276,6 +1327,16 @@ | ... | @@ -1276,6 +1327,16 @@ |
1276 | "requires": { | 1327 | "requires": { |
1277 | "psl": "^1.1.28", | 1328 | "psl": "^1.1.28", |
1278 | "punycode": "^2.1.1" | 1329 | "punycode": "^2.1.1" |
1330 | +<<<<<<< HEAD | ||
1331 | +======= | ||
1332 | + }, | ||
1333 | + "dependencies": { | ||
1334 | + "punycode": { | ||
1335 | + "version": "2.1.1", | ||
1336 | + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", | ||
1337 | + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" | ||
1338 | + } | ||
1339 | +>>>>>>> 677e924ea1f8968d4b256c5c0ca83390eb370802 | ||
1279 | } | 1340 | } |
1280 | }, | 1341 | }, |
1281 | "tunnel-agent": { | 1342 | "tunnel-agent": { |
... | @@ -1342,6 +1403,25 @@ | ... | @@ -1342,6 +1403,25 @@ |
1342 | "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", | 1403 | "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", |
1343 | "requires": { | 1404 | "requires": { |
1344 | "punycode": "^2.1.0" | 1405 | "punycode": "^2.1.0" |
1406 | +<<<<<<< HEAD | ||
1407 | +======= | ||
1408 | + }, | ||
1409 | + "dependencies": { | ||
1410 | + "punycode": { | ||
1411 | + "version": "2.1.1", | ||
1412 | + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", | ||
1413 | + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" | ||
1414 | + } | ||
1415 | + } | ||
1416 | + }, | ||
1417 | + "url": { | ||
1418 | + "version": "0.10.3", | ||
1419 | + "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", | ||
1420 | + "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", | ||
1421 | + "requires": { | ||
1422 | + "punycode": "1.3.2", | ||
1423 | + "querystring": "0.2.0" | ||
1424 | +>>>>>>> 677e924ea1f8968d4b256c5c0ca83390eb370802 | ||
1345 | } | 1425 | } |
1346 | }, | 1426 | }, |
1347 | "util-deprecate": { | 1427 | "util-deprecate": { |
... | @@ -1355,9 +1435,15 @@ | ... | @@ -1355,9 +1435,15 @@ |
1355 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" | 1435 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" |
1356 | }, | 1436 | }, |
1357 | "uuid": { | 1437 | "uuid": { |
1438 | +<<<<<<< HEAD | ||
1358 | "version": "3.4.0", | 1439 | "version": "3.4.0", |
1359 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", | 1440 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", |
1360 | "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" | 1441 | "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" |
1442 | +======= | ||
1443 | + "version": "3.3.2", | ||
1444 | + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", | ||
1445 | + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" | ||
1446 | +>>>>>>> 677e924ea1f8968d4b256c5c0ca83390eb370802 | ||
1361 | }, | 1447 | }, |
1362 | "vary": { | 1448 | "vary": { |
1363 | "version": "1.1.2", | 1449 | "version": "1.1.2", |
... | @@ -1398,6 +1484,20 @@ | ... | @@ -1398,6 +1484,20 @@ |
1398 | "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", | 1484 | "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", |
1399 | "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=" | 1485 | "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=" |
1400 | }, | 1486 | }, |
1487 | + "xml2js": { | ||
1488 | + "version": "0.4.19", | ||
1489 | + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", | ||
1490 | + "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", | ||
1491 | + "requires": { | ||
1492 | + "sax": ">=0.6.0", | ||
1493 | + "xmlbuilder": "~9.0.1" | ||
1494 | + } | ||
1495 | + }, | ||
1496 | + "xmlbuilder": { | ||
1497 | + "version": "9.0.7", | ||
1498 | + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", | ||
1499 | + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" | ||
1500 | + }, | ||
1401 | "yargs": { | 1501 | "yargs": { |
1402 | "version": "3.10.0", | 1502 | "version": "3.10.0", |
1403 | "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", | 1503 | "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", | ... | ... |
... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
6 | "start": "node ./bin/www" | 6 | "start": "node ./bin/www" |
7 | }, | 7 | }, |
8 | "dependencies": { | 8 | "dependencies": { |
9 | + "aws-sdk": "^2.683.0", | ||
9 | "cookie-parser": "~1.4.4", | 10 | "cookie-parser": "~1.4.4", |
10 | "crypto-js": "^4.0.0", | 11 | "crypto-js": "^4.0.0", |
11 | "debug": "~2.6.9", | 12 | "debug": "~2.6.9", |
... | @@ -13,6 +14,7 @@ | ... | @@ -13,6 +14,7 @@ |
13 | "express": "~4.16.1", | 14 | "express": "~4.16.1", |
14 | "express-session": "^1.17.1", | 15 | "express-session": "^1.17.1", |
15 | "http-errors": "~1.6.3", | 16 | "http-errors": "~1.6.3", |
17 | + "moment": "^2.26.0", | ||
16 | "morgan": "~1.9.1", | 18 | "morgan": "~1.9.1", |
17 | "mysql": "^2.18.1", | 19 | "mysql": "^2.18.1", |
18 | "passport": "^0.4.1", | 20 | "passport": "^0.4.1", | ... | ... |
backend/routes/folders.js
0 → 100644
1 | +const express = require('express'); | ||
2 | +const router = express.Router(); | ||
3 | +const AWS = require("aws-sdk"); | ||
4 | +const moment = require("moment"); | ||
5 | + | ||
6 | +const BUCKET_NAME = "hong-s3-cloud"; | ||
7 | +let curPath = ""; | ||
8 | +let user_id = ""; | ||
9 | + | ||
10 | +const s3 = new AWS.S3({ | ||
11 | + accessKeyId: process.env.AWS_ACCESS_KEY_ID, | ||
12 | + secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, | ||
13 | + region: "ap-northeast-2" | ||
14 | +}); | ||
15 | + | ||
16 | +router.get('/show', function(req, res, next) { | ||
17 | + console.log(req.query); | ||
18 | + user_id = req.query.id; | ||
19 | + curPath = req.query.cur; | ||
20 | + folders = {} | ||
21 | + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | ||
22 | + connection.query(checkfolder, [curPath, user_id], function(err, rows, fields) { | ||
23 | + if (rows.length != 0) { | ||
24 | + res.status(200).send({ | ||
25 | + folders: rows, | ||
26 | + cur: curPath | ||
27 | + }) | ||
28 | + } else { | ||
29 | + res.send({ error: "Does not exist" }); | ||
30 | + } | ||
31 | + }); | ||
32 | +}); | ||
33 | + | ||
34 | + | ||
35 | +router.post('/makefolder', function(req, res, next) { | ||
36 | + | ||
37 | + user_id = req.body.user_id; | ||
38 | + let cur = req.body.cur; | ||
39 | + curPath = user_id + cur; | ||
40 | + let folder_name = req.body.folder_name; | ||
41 | + let date = moment().format(); | ||
42 | + let params = { | ||
43 | + Bucket: BUCKET_NAME, | ||
44 | + Key: curPath + folder_name + '/', | ||
45 | + Body: "", | ||
46 | + ACL: "public-read-write" | ||
47 | + }; | ||
48 | + let checksql = 'SELECT * FROM folders WHERE location = ? AND folder_name = ?;'; | ||
49 | + console.log(req.body) | ||
50 | + connection.query(checksql, [cur, folder_name], function(err, rows, fields) { | ||
51 | + if (rows.length == 0) { | ||
52 | + s3.putObject(params, function(err, data) { | ||
53 | + if (err) { | ||
54 | + console.log('s3 error'); | ||
55 | + throw err; | ||
56 | + } else { | ||
57 | + console.log(data); | ||
58 | + } | ||
59 | + }); | ||
60 | + let sql = 'INSERT INTO folders (folder_name,location,user_id,created) values (?,?,?,?);'; | ||
61 | + let values = [folder_name, cur, user_id, date]; | ||
62 | + connection.query(sql, values, function(err, result, field) { | ||
63 | + if (err) { | ||
64 | + console.log('insert error'); | ||
65 | + throw err; | ||
66 | + } else { | ||
67 | + folders = {} | ||
68 | + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | ||
69 | + connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { | ||
70 | + if (rows.length != 0) { | ||
71 | + res.status(200).send({ | ||
72 | + folders: rows, | ||
73 | + cur: curPath | ||
74 | + }) | ||
75 | + } else { | ||
76 | + res.send({ error: "Does not exist" }); | ||
77 | + } | ||
78 | + }); | ||
79 | + } | ||
80 | + }); | ||
81 | + | ||
82 | + | ||
83 | + } else { | ||
84 | + res.status(404).send({ error: "same name error" }); | ||
85 | + } | ||
86 | + }); | ||
87 | +}); | ||
88 | + | ||
89 | + | ||
90 | +router.post('/delfolder', function(req, res, next) { | ||
91 | + | ||
92 | + user_id = req.body.user_id; | ||
93 | + curPath = user_id + req.body.cur; | ||
94 | + let folder_name = req.body.folder_name; | ||
95 | + let params = { | ||
96 | + Bucket: BUCKET_NAME + curPath, | ||
97 | + Key: folder_name + '/' | ||
98 | + }; | ||
99 | + let checksql = 'SELECT * FROM folders WHERE location = ? AND folder_name = ?;'; | ||
100 | + let values = [curPath, folder_name]; | ||
101 | + | ||
102 | + connection.query(checksql, values, function(err, rows, fields) { | ||
103 | + if (rows.length != 0) { | ||
104 | + s3.deleteObject(params, function(err, data) { | ||
105 | + if (err) { | ||
106 | + //throw err; | ||
107 | + } else { | ||
108 | + let sql = 'DELETE FROM folders WHERE location = ? AND folder_name = ?;'; | ||
109 | + connection.query(sql, values, function(err, result, field) { | ||
110 | + if (err) { | ||
111 | + //throw err; | ||
112 | + } else { | ||
113 | + folders = {} | ||
114 | + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | ||
115 | + connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { | ||
116 | + if (rows.length != 0) { | ||
117 | + res.status(200).send({ | ||
118 | + folders: rows, | ||
119 | + cur: curPath | ||
120 | + }) | ||
121 | + } else { | ||
122 | + res.send({ error: "Does not exist" }); | ||
123 | + } | ||
124 | + }); | ||
125 | + | ||
126 | + } | ||
127 | + }); | ||
128 | + } | ||
129 | + }); | ||
130 | + | ||
131 | + | ||
132 | + } else { | ||
133 | + res.send({ error: "Does not exist" }); | ||
134 | + } | ||
135 | + }); | ||
136 | +}); | ||
137 | + | ||
138 | + | ||
139 | +router.post('/move', function(req, res, next) { | ||
140 | + | ||
141 | + user_id = req.body.user_id; | ||
142 | + curPath = user_id + req.body.cur; | ||
143 | + let name = req.body.mfile; | ||
144 | + let newPath = req.body.newPath; | ||
145 | + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND folder_name = ?;'; | ||
146 | + if (req.body.isfolder) { | ||
147 | + connection.query(checkfolder, [curPath, name], function(err1, rows, fields) { | ||
148 | + if (rows.length != 0) { | ||
149 | + let copy_params = { | ||
150 | + Bucket: BUCKET_NAME + curPath, | ||
151 | + CopySource: BUCKET_NAME + curPath + file + '/', | ||
152 | + Key: newPath + file + '/' | ||
153 | + }; | ||
154 | + | ||
155 | + let del_params = { | ||
156 | + Bucket: BUCKET_NAME + curPath, | ||
157 | + Key: file + '/' | ||
158 | + }; | ||
159 | + s3.copyObject(copy_params, function(err, data) { | ||
160 | + console.log(err, data); | ||
161 | + }); | ||
162 | + s3.deleteObject(del_params, function(err, data) { | ||
163 | + console.log(err, data); | ||
164 | + }); | ||
165 | + let values = [newPath, curPath, name]; | ||
166 | + let updatesql = 'UPDATE folders SET location = ? WHERE location = ? AND folder_name = ?;'; | ||
167 | + connection.query(updatesql, values, function(err3, result, field) { | ||
168 | + if (err3) { | ||
169 | + throw err; | ||
170 | + } else { | ||
171 | + folders = {} | ||
172 | + connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { | ||
173 | + if (rows.length != 0) { | ||
174 | + res.status(200).send({ | ||
175 | + folders: rows, | ||
176 | + cur: curPath | ||
177 | + }) | ||
178 | + } else { | ||
179 | + res.send({ error: "Does not exist" }); | ||
180 | + } | ||
181 | + }); | ||
182 | + } | ||
183 | + }); | ||
184 | + | ||
185 | + | ||
186 | + } else { | ||
187 | + res.send({ error: "Does not exist" }); | ||
188 | + } | ||
189 | + }); | ||
190 | + } else { | ||
191 | + let checkfile = 'SELECT * FROM files WHERE location = ? AND file_name = ?'; | ||
192 | + | ||
193 | + connection.query(checkfile, [curPath, name], function(err1, rows, fields) { | ||
194 | + if (rows.length != 0) { | ||
195 | + let copy_params = { | ||
196 | + Bucket: BUCKET_NAME + curPath, | ||
197 | + CopySource: BUCKET_NAME + curPath + file, | ||
198 | + Key: newPath + file | ||
199 | + }; | ||
200 | + | ||
201 | + let del_params = { | ||
202 | + Bucket: BUCKET_NAME + curPath, | ||
203 | + Key: file | ||
204 | + }; | ||
205 | + s3.copyObject(copy_params, function(err, data) { | ||
206 | + console.log(err, data); | ||
207 | + }); | ||
208 | + s3.deleteObject(del_params, function(err, data) { | ||
209 | + console.log(err, data); | ||
210 | + }); | ||
211 | + let values = [newPath, curPath, name]; | ||
212 | + let updatesql = 'UPDATE files SET location = ? WHERE location = ? AND file_name = ?;'; | ||
213 | + connection.query(updatesql, values, function(err3, result, field) { | ||
214 | + if (err3) { | ||
215 | + throw err; | ||
216 | + } else { | ||
217 | + folders = {} | ||
218 | + connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { | ||
219 | + if (rows.length != 0) { | ||
220 | + res.status(200).send({ | ||
221 | + folders: rows, | ||
222 | + cur: curPath | ||
223 | + }) | ||
224 | + } else { | ||
225 | + res.send({ error: "Does not exist" }); | ||
226 | + } | ||
227 | + }); | ||
228 | + } | ||
229 | + }); | ||
230 | + | ||
231 | + | ||
232 | + } else { | ||
233 | + res.send({ error: "Does not exist" }); | ||
234 | + } | ||
235 | + }); | ||
236 | + | ||
237 | + } | ||
238 | +}); | ||
239 | + | ||
240 | + | ||
241 | +router.post('/search/:target', function(req, res, next) { | ||
242 | + user_id = req.params.id; | ||
243 | + let cur = req.params.cur; | ||
244 | + folders = {} | ||
245 | + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | ||
246 | + connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { | ||
247 | + if (rows.length != 0) { | ||
248 | + res.status(200).send({ | ||
249 | + folders: folders | ||
250 | + }) | ||
251 | + } else { | ||
252 | + res.send({ error: "Does not exist" }); | ||
253 | + } | ||
254 | + }); | ||
255 | +}); | ||
256 | + | ||
257 | +module.exports = router; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -5,21 +5,26 @@ const instance = axios.create({ | ... | @@ -5,21 +5,26 @@ const instance = axios.create({ |
5 | }); | 5 | }); |
6 | 6 | ||
7 | function registerUser(userData) { | 7 | function registerUser(userData) { |
8 | - // const url = 'http://localhost:3000/api/signup' | 8 | + // const url = 'http://localhost:3000/api/signup' |
9 | return axios.post('/api/RegistUser', userData); | 9 | return axios.post('/api/RegistUser', userData); |
10 | - } | 10 | +} |
11 | - | 11 | + |
12 | - function loginUser(userData) { | 12 | +function loginUser(userData) { |
13 | // const url = 'http://localhost:3000/api/login' | 13 | // const url = 'http://localhost:3000/api/login' |
14 | return axios.post('/api/login', userData); | 14 | return axios.post('/api/login', userData); |
15 | - } | ||
16 | - | ||
17 | -function dropbox(userData){ | ||
18 | - return axios.get(`/api/folder/show/${userData}`); | ||
19 | } | 15 | } |
20 | 16 | ||
21 | -function makeFolder(folderData){ | 17 | +function folder(curData) { |
22 | - return axios.post('/api/folder/makefolder', folderData); | 18 | + return axios.get('/api/folder/show', { |
19 | + params: { | ||
20 | + id: curData.id, | ||
21 | + cur: curData.cur | ||
22 | + } | ||
23 | + }); | ||
24 | +} | ||
25 | + | ||
26 | +function makeFolder(folderData) { | ||
27 | + return axios.post('/api/folder/makefolder', folderData); | ||
23 | } | 28 | } |
24 | 29 | ||
25 | - export { registerUser, loginUser, dropbox, makeFolder }; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
30 | +export { registerUser, loginUser, folder, makeFolder }; | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -12,10 +12,8 @@ | ... | @@ -12,10 +12,8 @@ |
12 | hide-details | 12 | hide-details |
13 | ></v-text-field> | 13 | ></v-text-field> |
14 | </v-toolbar> | 14 | </v-toolbar> |
15 | - | ||
16 | <v-list two-line subheader> | 15 | <v-list two-line subheader> |
17 | <v-subheader inset>Folders</v-subheader> | 16 | <v-subheader inset>Folders</v-subheader> |
18 | - | ||
19 | <v-list-item | 17 | <v-list-item |
20 | v-for="item in this.$store.getters.folderL" | 18 | v-for="item in this.$store.getters.folderL" |
21 | :key="item.title" | 19 | :key="item.title" |
... | @@ -24,22 +22,17 @@ | ... | @@ -24,22 +22,17 @@ |
24 | <v-list-item-avatar> | 22 | <v-list-item-avatar> |
25 | <v-icon>mdi-folder</v-icon> | 23 | <v-icon>mdi-folder</v-icon> |
26 | </v-list-item-avatar> | 24 | </v-list-item-avatar> |
27 | - | ||
28 | <v-list-item-content> | 25 | <v-list-item-content> |
29 | <v-list-item-title v-text="item.folder_name"></v-list-item-title> | 26 | <v-list-item-title v-text="item.folder_name"></v-list-item-title> |
30 | </v-list-item-content> | 27 | </v-list-item-content> |
31 | - | ||
32 | <v-list-item-action> | 28 | <v-list-item-action> |
33 | <v-btn icon> | 29 | <v-btn icon> |
34 | <v-icon color="grey lighten-1">mdi-information</v-icon> | 30 | <v-icon color="grey lighten-1">mdi-information</v-icon> |
35 | </v-btn> | 31 | </v-btn> |
36 | </v-list-item-action> | 32 | </v-list-item-action> |
37 | </v-list-item> | 33 | </v-list-item> |
38 | - | ||
39 | <v-divider inset></v-divider> | 34 | <v-divider inset></v-divider> |
40 | - | ||
41 | <v-subheader inset>Files</v-subheader> | 35 | <v-subheader inset>Files</v-subheader> |
42 | - | ||
43 | <v-list-item | 36 | <v-list-item |
44 | v-for="item in this.$store.getters.fileL" | 37 | v-for="item in this.$store.getters.fileL" |
45 | :key="item.title" | 38 | :key="item.title" |
... | @@ -48,11 +41,9 @@ | ... | @@ -48,11 +41,9 @@ |
48 | <v-list-item-avatar> | 41 | <v-list-item-avatar> |
49 | <v-icon> mdi-file</v-icon> | 42 | <v-icon> mdi-file</v-icon> |
50 | </v-list-item-avatar> | 43 | </v-list-item-avatar> |
51 | - | ||
52 | <v-list-item-content> | 44 | <v-list-item-content> |
53 | <v-list-item-title v-text="item"></v-list-item-title> | 45 | <v-list-item-title v-text="item"></v-list-item-title> |
54 | </v-list-item-content> | 46 | </v-list-item-content> |
55 | - | ||
56 | <v-list-item-action> | 47 | <v-list-item-action> |
57 | <v-btn icon> | 48 | <v-btn icon> |
58 | <v-icon color="grey lighten-1">mdi-information</v-icon> | 49 | <v-icon color="grey lighten-1">mdi-information</v-icon> |
... | @@ -81,7 +72,6 @@ | ... | @@ -81,7 +72,6 @@ |
81 | > | 72 | > |
82 | {{ text }} | 73 | {{ text }} |
83 | </v-chip> | 74 | </v-chip> |
84 | - | ||
85 | <span | 75 | <span |
86 | v-else-if="index === 2" | 76 | v-else-if="index === 2" |
87 | class="overline grey--text text--darken-3 mx-2" | 77 | class="overline grey--text text--darken-3 mx-2" |
... | @@ -89,7 +79,7 @@ | ... | @@ -89,7 +79,7 @@ |
89 | +{{ files.length - 2 }} File(s) | 79 | +{{ files.length - 2 }} File(s) |
90 | </span> | 80 | </span> |
91 | </template> | 81 | </template> |
92 | - </v-file-input> | 82 | + </v-file-input> |
93 | <v-btn | 83 | <v-btn |
94 | bottom | 84 | bottom |
95 | color="blue" | 85 | color="blue" |
... | @@ -112,7 +102,7 @@ | ... | @@ -112,7 +102,7 @@ |
112 | <v-container> | 102 | <v-container> |
113 | <div> | 103 | <div> |
114 | <v-icon>mdi-folder</v-icon> | 104 | <v-icon>mdi-folder</v-icon> |
115 | - <v-text-field placeholder="name" id="foldername" type="text" v-model="foldername" ></v-text-field> | 105 | + <v-text-field placeholder="name" id="foldername" type="text" v-model="foldername"></v-text-field> |
116 | </div> | 106 | </div> |
117 | </v-container> | 107 | </v-container> |
118 | <v-card-actions> | 108 | <v-card-actions> |
... | @@ -133,54 +123,57 @@ | ... | @@ -133,54 +123,57 @@ |
133 | </template> | 123 | </template> |
134 | 124 | ||
135 | <script> | 125 | <script> |
136 | -import { dropbox, makeFolder } from '../api/index'; | 126 | +import { folder, makeFolder } from '../api/index'; |
137 | export default { | 127 | export default { |
138 | data() { | 128 | data() { |
139 | return { | 129 | return { |
140 | - foldername: '', | 130 | + foldername:'', |
141 | folders: [], | 131 | folders: [], |
142 | files: [], | 132 | files: [], |
143 | search:'', | 133 | search:'', |
144 | id: '', | 134 | id: '', |
145 | - dialog: false, | 135 | + dialog:false |
146 | } | 136 | } |
147 | }, | 137 | }, |
148 | async created(){ | 138 | async created(){ |
149 | try { | 139 | try { |
150 | - const userData = this.$store.state.id; | 140 | + const curData = { |
151 | - console.log(this.id); | 141 | + id : this.$store.state.id, |
152 | - | 142 | + cur: this.$store.state.cur |
153 | - const response = await dropbox(userData); | 143 | + } |
144 | + const response = await folder(curData); | ||
154 | console.log(response); | 145 | console.log(response); |
155 | this.$store.commit('setFolder', response.data.folders); | 146 | this.$store.commit('setFolder', response.data.folders); |
156 | - this.$store.commit('setFile', response.data.files); | 147 | + this.$store.commit('setCur', response.data.cur); |
157 | } catch (error) { | 148 | } catch (error) { |
158 | console.log("에러"); | 149 | console.log("에러"); |
159 | - console.log(error.response.data); | 150 | + console.log(error.response.data); |
160 | } | 151 | } |
161 | }, | 152 | }, |
162 | - methods: { | 153 | + methods: { |
163 | - initFolderName(){ | 154 | + initFolderName(){ |
164 | - this.foldername = ''; | 155 | + this.foldername = ''; |
165 | - }, | 156 | + }, |
166 | - async makeF(){ | 157 | + async makeF(){ |
167 | - try { | 158 | + try { |
168 | - const folderData = { | 159 | + const folderData = { |
169 | - user_id : this.$store.state.id, | 160 | + user_id : this.$store.state.id, |
170 | - cur : this.$store.state.id, | 161 | + cur : this.$store.state.cur, |
171 | - folder_name : this.foldername | 162 | + folder_name : this.foldername |
172 | - }; | 163 | + }; |
173 | - const response = await makeFolder(folderData); | 164 | + const response = await makeFolder(folderData); |
174 | - this.$store.commit('setFolder', response.data.folders); | 165 | + console.log(response.data) |
175 | - console.log("폴더 생성 완료"); | 166 | + console.log("폴더 생성 완료"); |
176 | - } catch (error) { | 167 | + this.$store.commit('setFolder', response.data.folders); |
177 | - console.log("에러"); | 168 | + } catch (error) { |
178 | - console.log(error.response.data); | 169 | + console.log("에러"); |
179 | - } finally{ | 170 | + console.log(error.response.data); |
180 | - this.initFolderName(); | 171 | + } finally{ |
181 | - this.dialog = false; | 172 | + this.initFolderName(); |
182 | - } | 173 | + this.dialog = false; |
183 | - } | 174 | + } |
184 | - } | 175 | + } |
176 | + | ||
177 | + } | ||
185 | } | 178 | } |
186 | </script> | 179 | </script> | ... | ... |
... | @@ -4,38 +4,44 @@ import Vuex from 'vuex' | ... | @@ -4,38 +4,44 @@ import Vuex from 'vuex' |
4 | Vue.use(Vuex) | 4 | Vue.use(Vuex) |
5 | 5 | ||
6 | export default new Vuex.Store({ | 6 | export default new Vuex.Store({ |
7 | - state: { | 7 | + state: { |
8 | - id: '', | 8 | + id: '', |
9 | - folders: [], | 9 | + folders: {}, |
10 | - files: [], | 10 | + files: {}, |
11 | - cur:'/', | 11 | + cur: '/', |
12 | - }, | ||
13 | - mutations: { | ||
14 | - setId(state, userid){ | ||
15 | - state.id = userid; | ||
16 | }, | 12 | }, |
17 | - clearid(state){ | 13 | + mutations: { |
18 | - state.id= ''; | 14 | + setId(state, userid) { |
15 | + state.id = userid; | ||
16 | + }, | ||
17 | + clearid(state) { | ||
18 | + state.id = ''; | ||
19 | + }, | ||
20 | + setFolder(state, folderlist) { | ||
21 | + state.folders = folderlist; | ||
22 | + }, | ||
23 | + setFile(state, filelist) { | ||
24 | + state.files = filelist; | ||
25 | + }, | ||
26 | + setCur(state, cur) { | ||
27 | + state.cur = cur; | ||
28 | + } | ||
19 | }, | 29 | }, |
20 | - setFolder(state, folderlist){ | 30 | + getters: { |
21 | - state.folders = folderlist; | 31 | + isLogin(state) { |
22 | - }, | 32 | + return state.id !== ''; |
23 | - setFile(state, filelist){ | 33 | + }, |
24 | - state.files = filelist; | 34 | + userID(state) { |
25 | - }, | 35 | + return state.id; |
26 | - }, | 36 | + }, |
27 | - getters: { | 37 | + folderL(state) { |
28 | - isLogin(state){ | 38 | + return state.folders; |
29 | - return state.id !== ''; | 39 | + }, |
30 | - }, | 40 | + fileL(state) { |
31 | - userID(state){ | 41 | + return state.files; |
32 | - return state.id; | 42 | + }, |
33 | - }, | 43 | + cur(state) { |
34 | - folderL(state){ | 44 | + return state.cur; |
35 | - return state.folders; | 45 | + } |
36 | - }, | ||
37 | - fileL(state){ | ||
38 | - return state.files; | ||
39 | } | 46 | } |
40 | - } | 47 | +}) |
41 | -}) | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment