From 44b4cc199fdd5199af816985326ea3ed3cfe2456 Mon Sep 17 00:00:00 2001 From: maulanaghozii Date: Mon, 9 Sep 2019 18:03:16 +0700 Subject: [PATCH 01/14] releases 0 - 2 done --- index.html | 112 ++++++++++++++++++++++++++++++++++++++++++++++++ script/index.js | 0 style.css | 67 +++++++++++++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 index.html create mode 100644 script/index.js create mode 100644 style.css diff --git a/index.html b/index.html new file mode 100644 index 00000000..2df55148 --- /dev/null +++ b/index.html @@ -0,0 +1,112 @@ + + + + + + + + + + + GO-WEB + + + + +
+

welcome in Hackticle

+

the first Official Website to provide information about hacking in the world

+ +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/script/index.js b/script/index.js new file mode 100644 index 00000000..e69de29b diff --git a/style.css b/style.css new file mode 100644 index 00000000..f38456fc --- /dev/null +++ b/style.css @@ -0,0 +1,67 @@ +*{ + margin: 0; + padding: 0; +} +header{ + height: 100vh; + background: url('https://images.unsplash.com/photo-1516641396056-0ce60a85d49f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80'); + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + background-size: cover; + color: #6C757D; +} + +nav{ + margin-bottom: 0; +} + +.show{ + display: block +} + +.navbar-logo img{ + width: 50px; +} + +.btn-write{ + margin-right: 10px; +} + + .type-search{ + width: 0px; + display: none; +} + +.menu{ + width: 0; + display: none; + height: 100vh; + background-color: #F8F9FA ; + margin-top: 0; + +} + +.menu ul li{ + list-style: none; + margin: 5px 5px; +} + +.menu ul li a{ + color: #6C757D; +} + +.menu button{ + box-sizing: border-box; + width: 30px; + height: 20px; + font-size: 10px; +} + +.menu-show{ + width: 250px; + display: block; + transition: 5s; +} + From 48c53e2d55aede80c41501f6d13968ce34d1b35e Mon Sep 17 00:00:00 2001 From: maulanaghozii Date: Wed, 11 Sep 2019 01:27:48 +0700 Subject: [PATCH 02/14] migration from jquery to vue js --- server/db.json | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 server/db.json diff --git a/server/db.json b/server/db.json new file mode 100644 index 00000000..b9215cc0 --- /dev/null +++ b/server/db.json @@ -0,0 +1,82 @@ +{ + "articles": [ + { + "title": "3 Hacker Remaja Level Dewa Asal Indonesia", + "content": "

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget metus eu justo sollicitudin tincidunt. Nunc sed varius elit. Curabitur maximus, orci tincidunt ultrices pulvinar, ante tellus pulvinar magna, quis efficitur dui ligula sit amet sapien. Fusce commodo nisl id tellus condimentum laoreet. In sollicitudin magna sit amet dolor congue, sed lobortis massa tincidunt. Proin volutpat non ligula quis consectetur. Vestibulum tincidunt in eros vel elementum. Duis ultrices quam a ligula vestibulum, in placerat leo cursus. Integer facilisis orci scelerisque eros finibus convallis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

Vestibulum maximus libero gravida, luctus mi ac, tristique nisl. Praesent porttitor, sapien eu ullamcorper tincidunt, enim diam condimentum nisl, sit amet fermentum nunc sapien nec neque. Vivamus auctor, nisl sed luctus vulputate, enim lectus tincidunt diam, eget volutpat risus neque ut lectus. Quisque lobortis elementum risus, eget hendrerit dolor bibendum vitae. Vivamus velit ligula, congue eget sodales eu, egestas finibus ipsum. Fusce sed turpis quis massa congue iaculis. Curabitur laoreet ipsum in tempus dignissim. Curabitur pretium ultricies enim, non pellentesque enim viverra in. Donec metus erat, placerat et hendrerit ut, rutrum eget odio.

Nulla in ipsum sed augue hendrerit egestas. Donec eget elit pharetra, rhoncus leo at, aliquet purus. Morbi luctus suscipit tellus eget lacinia. In hac habitasse platea dictumst. Quisque tortor felis, condimentum ut velit nec, egestas sagittis risus. Suspendisse potenti. Donec tristique urna turpis, quis tincidunt nunc imperdiet vitae. Nam porta mattis quam et sagittis. Aliquam non ornare mi. Etiam dictum varius nunc, nec ullamcorper lectus placerat vel. Integer rhoncus ut nunc quis molestie. Aliquam tortor nulla, placerat tristique euismod at, lobortis eu risus. Pellentesque cursus, elit ut gravida bibendum, arcu augue porttitor enim, vel mollis metus est nec leo.

Nunc ac nibh ac sem efficitur tempus. Sed placerat nisi vitae nisi mollis, eu consequat dolor commodo. Curabitur rhoncus ante at tellus placerat porttitor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec efficitur ultricies sem nec elementum. Donec ligula arcu, commodo sed dignissim eu, elementum vel ex. Sed convallis metus ut rhoncus consectetur. Cras massa magna, venenatis vitae porta in, tincidunt quis est. Pellentesque facilisis massa non sem auctor, quis auctor sapien euismod.

Integer porta consequat malesuada. Etiam sodales orci sit amet orci commodo rhoncus. Suspendisse odio sem, sodales id elit ut, finibus molestie mi. In feugiat magna eu ante mollis, id sagittis lacus ultrices. Nullam consequat nec odio ac auctor. Nullam vehicula ex eget lectus faucibus tempus. Fusce et vulputate libero, ac pretium diam. Aenean auctor diam quis laoreet tincidunt. Vivamus faucibus sit amet nunc nec congue. Sed euismod aliquam tempor. Praesent efficitur iaculis vestibulum. Mauris elementum libero vel mi molestie, non fringilla arcu pharetra. Nullam ut libero hendrerit, luctus felis faucibus, efficitur ipsum.

Fusce et nunc ac purus blandit efficitur. Duis fringilla, ligula sed dignissim dapibus, libero ante lacinia augue, a pellentesque nisi sapien in ex. Nullam at consequat ligula. Nullam volutpat arcu sit amet finibus suscipit. Mauris nec est sollicitudin nibh convallis commodo facilisis quis sem. Suspendisse blandit dolor erat, eu hendrerit turpis congue vel. Quisque imperdiet non arcu malesuada porta. Proin sit amet elit in turpis tempus feugiat id eleifend ex. Nam ultrices purus mi, a scelerisque augue maximus mattis. Curabitur dapibus commodo mattis. Suspendisse elementum libero quis nulla convallis mollis. Donec id libero quis erat mollis tincidunt. Quisque euismod vel dui sed placerat. Maecenas ut nulla ex.


", + "author": "Ghozi", + "created_at": "2019-8-10", + "id": 1 + }, + { + "title": "Terinspirasi Film Hacker, Siswa SMA Ini Retas Situs KPU", + "content": "

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget metus eu justo sollicitudin tincidunt. Nunc sed varius elit. Curabitur maximus, orci tincidunt ultrices pulvinar, ante tellus pulvinar magna, quis efficitur dui ligula sit amet sapien. Fusce commodo nisl id tellus condimentum laoreet. In sollicitudin magna sit amet dolor congue, sed lobortis massa tincidunt. Proin volutpat non ligula quis consectetur. Vestibulum tincidunt in eros vel elementum. Duis ultrices quam a ligula vestibulum, in placerat leo cursus. Integer facilisis orci scelerisque eros finibus convallis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

Vestibulum maximus libero gravida, luctus mi ac, tristique nisl. Praesent porttitor, sapien eu ullamcorper tincidunt, enim diam condimentum nisl, sit amet fermentum nunc sapien nec neque. Vivamus auctor, nisl sed luctus vulputate, enim lectus tincidunt diam, eget volutpat risus neque ut lectus. Quisque lobortis elementum risus, eget hendrerit dolor bibendum vitae. Vivamus velit ligula, congue eget sodales eu, egestas finibus ipsum. Fusce sed turpis quis massa congue iaculis. Curabitur laoreet ipsum in tempus dignissim. Curabitur pretium ultricies enim, non pellentesque enim viverra in. Donec metus erat, placerat et hendrerit ut, rutrum eget odio.

Nulla in ipsum sed augue hendrerit egestas. Donec eget elit pharetra, rhoncus leo at, aliquet purus. Morbi luctus suscipit tellus eget lacinia. In hac habitasse platea dictumst. Quisque tortor felis, condimentum ut velit nec, egestas sagittis risus. Suspendisse potenti. Donec tristique urna turpis, quis tincidunt nunc imperdiet vitae. Nam porta mattis quam et sagittis. Aliquam non ornare mi. Etiam dictum varius nunc, nec ullamcorper lectus placerat vel. Integer rhoncus ut nunc quis molestie. Aliquam tortor nulla, placerat tristique euismod at, lobortis eu risus. Pellentesque cursus, elit ut gravida bibendum, arcu augue porttitor enim, vel mollis metus est nec leo.

Nunc ac nibh ac sem efficitur tempus. Sed placerat nisi vitae nisi mollis, eu consequat dolor commodo. Curabitur rhoncus ante at tellus placerat porttitor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec efficitur ultricies sem nec elementum. Donec ligula arcu, commodo sed dignissim eu, elementum vel ex. Sed convallis metus ut rhoncus consectetur. Cras massa magna, venenatis vitae porta in, tincidunt quis est. Pellentesque facilisis massa non sem auctor, quis auctor sapien euismod.

Integer porta consequat malesuada. Etiam sodales orci sit amet orci commodo rhoncus. Suspendisse odio sem, sodales id elit ut, finibus molestie mi. In feugiat magna eu ante mollis, id sagittis lacus ultrices. Nullam consequat nec odio ac auctor. Nullam vehicula ex eget lectus faucibus tempus. Fusce et vulputate libero, ac pretium diam. Aenean auctor diam quis laoreet tincidunt. Vivamus faucibus sit amet nunc nec congue. Sed euismod aliquam tempor. Praesent efficitur iaculis vestibulum. Mauris elementum libero vel mi molestie, non fringilla arcu pharetra. Nullam ut libero hendrerit, luctus felis faucibus, efficitur ipsum.

Fusce et nunc ac purus blandit efficitur. Duis fringilla, ligula sed dignissim dapibus, libero ante lacinia augue, a pellentesque nisi sapien in ex. Nullam at consequat ligula. Nullam volutpat arcu sit amet finibus suscipit. Mauris nec est sollicitudin nibh convallis commodo facilisis quis sem. Suspendisse blandit dolor erat, eu hendrerit turpis congue vel. Quisque imperdiet non arcu malesuada porta. Proin sit amet elit in turpis tempus feugiat id eleifend ex. Nam ultrices purus mi, a scelerisque augue maximus mattis. Curabitur dapibus commodo mattis. Suspendisse elementum libero quis nulla convallis mollis. Donec id libero quis erat mollis tincidunt. Quisque euismod vel dui sed placerat. Maecenas ut nulla ex.


", + "author": "Ghozi", + "created_at": "2019-8-10", + "id": 2 + }, + { + "title": "Cara menyadap whatsApp", + "content": "

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget metus eu justo sollicitudin tincidunt. Nunc sed varius elit. Curabitur maximus, orci tincidunt ultrices pulvinar, ante tellus pulvinar magna, quis efficitur dui ligula sit amet sapien. Fusce commodo nisl id tellus condimentum laoreet. In sollicitudin magna sit amet dolor congue, sed lobortis massa tincidunt. Proin volutpat non ligula quis consectetur. Vestibulum tincidunt in eros vel elementum. Duis ultrices quam a ligula vestibulum, in placerat leo cursus. Integer facilisis orci scelerisque eros finibus convallis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

Vestibulum maximus libero gravida, luctus mi ac, tristique nisl. Praesent porttitor, sapien eu ullamcorper tincidunt, enim diam condimentum nisl, sit amet fermentum nunc sapien nec neque. Vivamus auctor, nisl sed luctus vulputate, enim lectus tincidunt diam, eget volutpat risus neque ut lectus. Quisque lobortis elementum risus, eget hendrerit dolor bibendum vitae. Vivamus velit ligula, congue eget sodales eu, egestas finibus ipsum. Fusce sed turpis quis massa congue iaculis. Curabitur laoreet ipsum in tempus dignissim. Curabitur pretium ultricies enim, non pellentesque enim viverra in. Donec metus erat, placerat et hendrerit ut, rutrum eget odio.

Nulla in ipsum sed augue hendrerit egestas. Donec eget elit pharetra, rhoncus leo at, aliquet purus. Morbi luctus suscipit tellus eget lacinia. In hac habitasse platea dictumst. Quisque tortor felis, condimentum ut velit nec, egestas sagittis risus. Suspendisse potenti. Donec tristique urna turpis, quis tincidunt nunc imperdiet vitae. Nam porta mattis quam et sagittis. Aliquam non ornare mi. Etiam dictum varius nunc, nec ullamcorper lectus placerat vel. Integer rhoncus ut nunc quis molestie. Aliquam tortor nulla, placerat tristique euismod at, lobortis eu risus. Pellentesque cursus, elit ut gravida bibendum, arcu augue porttitor enim, vel mollis metus est nec leo.

Nunc ac nibh ac sem efficitur tempus. Sed placerat nisi vitae nisi mollis, eu consequat dolor commodo. Curabitur rhoncus ante at tellus placerat porttitor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec efficitur ultricies sem nec elementum. Donec ligula arcu, commodo sed dignissim eu, elementum vel ex. Sed convallis metus ut rhoncus consectetur. Cras massa magna, venenatis vitae porta in, tincidunt quis est. Pellentesque facilisis massa non sem auctor, quis auctor sapien euismod.

Integer porta consequat malesuada. Etiam sodales orci sit amet orci commodo rhoncus. Suspendisse odio sem, sodales id elit ut, finibus molestie mi. In feugiat magna eu ante mollis, id sagittis lacus ultrices. Nullam consequat nec odio ac auctor. Nullam vehicula ex eget lectus faucibus tempus. Fusce et vulputate libero, ac pretium diam. Aenean auctor diam quis laoreet tincidunt. Vivamus faucibus sit amet nunc nec congue. Sed euismod aliquam tempor. Praesent efficitur iaculis vestibulum. Mauris elementum libero vel mi molestie, non fringilla arcu pharetra. Nullam ut libero hendrerit, luctus felis faucibus, efficitur ipsum.

Fusce et nunc ac purus blandit efficitur. Duis fringilla, ligula sed dignissim dapibus, libero ante lacinia augue, a pellentesque nisi sapien in ex. Nullam at consequat ligula. Nullam volutpat arcu sit amet finibus suscipit. Mauris nec est sollicitudin nibh convallis commodo facilisis quis sem. Suspendisse blandit dolor erat, eu hendrerit turpis congue vel. Quisque imperdiet non arcu malesuada porta. Proin sit amet elit in turpis tempus feugiat id eleifend ex. Nam ultrices purus mi, a scelerisque augue maximus mattis. Curabitur dapibus commodo mattis. Suspendisse elementum libero quis nulla convallis mollis. Donec id libero quis erat mollis tincidunt. Quisque euismod vel dui sed placerat. Maecenas ut nulla ex.


", + "author": "Ghozi", + "created_at": "2019-8-10", + "id": 3 + }, + { + "title": "mantaaap", + "content": "

ngunagdaj

", + "author": "Ghozi", + "created_at": "2019-8-10", + "id": 4 + }, + { + "title": "mencari hacker profesional", + "content": "

wkwkwkwk

", + "author": "Ghozi", + "created_at": "2019-8-10", + "id": 5 + }, + { + "title": "mencari hacker profesional part 4", + "content": "

wkwkwkwk

", + "author": "Ghozi", + "created_at": "2019-8-10", + "id": 6 + }, + { + "title": "makan malam", + "content": "

kekekeke

", + "author": "Ghozi", + "created_at": "2019-8-10", + "id": 7 + }, + { + "title": "makan siang", + "content": "

tas gunung

", + "author": "Ghozi", + "created_at": "2019-8-10", + "id": 8 + }, + { + "title": "sdasdsa", + "content": "

pkpl,pl,pl

", + "author": "Ghozi", + "created_at": "2019-8-10", + "id": 9 + }, + { + "title": "", + "content": "

ini random

", + "author": "Ghozi", + "created_at": "2019-8-10", + "id": 10 + } + ], + "users": [ + { + "id": 1, + "name": "ghozi", + "password": 123456, + "email": "ghozihz@gmail.com" + } + ] +} \ No newline at end of file From 33229d7c965cf0a6e26f28626be7323c99eccf8e Mon Sep 17 00:00:00 2001 From: maulanaghozii Date: Wed, 11 Sep 2019 13:42:14 +0700 Subject: [PATCH 03/14] model server done --- client/index.html | 210 +++++++ script/index.js => client/script/article.js | 0 client/script/index.js | 3 + style.css => client/style.css | 55 +- index.html | 112 ---- server/.env | 2 + server/.env-examples | 0 server/.gitignore | 1 + server/app.js | 29 + server/controllers/article.js | 21 + server/controllers/user.js | 37 ++ server/middlewares/errorHandler.js | 3 + server/models/article.js | 11 + server/models/user.js | 11 + server/package-lock.json | 580 ++++++++++++++++++++ server/package.json | 19 + server/routes/article.js | 10 + server/routes/index.js | 9 + server/routes/user.js | 14 + 19 files changed, 1008 insertions(+), 119 deletions(-) create mode 100644 client/index.html rename script/index.js => client/script/article.js (100%) create mode 100644 client/script/index.js rename style.css => client/style.css (53%) delete mode 100644 index.html create mode 100644 server/.env create mode 100644 server/.env-examples create mode 100644 server/.gitignore create mode 100644 server/app.js create mode 100644 server/controllers/article.js create mode 100644 server/controllers/user.js create mode 100644 server/middlewares/errorHandler.js create mode 100644 server/models/article.js create mode 100644 server/models/user.js create mode 100644 server/package-lock.json create mode 100644 server/package.json create mode 100644 server/routes/article.js create mode 100644 server/routes/index.js create mode 100644 server/routes/user.js diff --git a/client/index.html b/client/index.html new file mode 100644 index 00000000..0ac65b9a --- /dev/null +++ b/client/index.html @@ -0,0 +1,210 @@ + + + + + + + + + + + + GO-WEB + + +
+ +
+

welcome in Hackticle

+

the first Official Website to provide information about hacking in the world

+ +
+ + + + + + + +
+ +
+ + + +
+
+ +
+
+ +
+ +
+ + + +
+
+
+

{{ titleHead }}

+
+ +
+

Author : {{ authorHead }}

+

Publish : {{ createdAthead }}

+
+ +
+

+
+ +
+ +
+

List Article

+
+ +
+
+
+ +
+ + + + + + + + + + \ No newline at end of file diff --git a/script/index.js b/client/script/article.js similarity index 100% rename from script/index.js rename to client/script/article.js diff --git a/client/script/index.js b/client/script/index.js new file mode 100644 index 00000000..6223f849 --- /dev/null +++ b/client/script/index.js @@ -0,0 +1,3 @@ +$('.navbar-toggler').click(function(){ + $('.collapse').toggleClass('show') +}) \ No newline at end of file diff --git a/style.css b/client/style.css similarity index 53% rename from style.css rename to client/style.css index f38456fc..50ee2ad4 100644 --- a/style.css +++ b/client/style.css @@ -1,6 +1,7 @@ *{ margin: 0; padding: 0; + box-sizing: border-box } header{ height: 100vh; @@ -35,33 +36,73 @@ nav{ } .menu{ - width: 0; - display: none; + position: absolute; + transition: 1s; + z-index: 2; + left: -250px; + width: 250px; height: 100vh; background-color: #F8F9FA ; margin-top: 0; - + padding: 2px 5px } .menu ul li{ list-style: none; margin: 5px 5px; + display: flex; + justify-content: space-between; } .menu ul li a{ + color: #6C757D; } .menu button{ box-sizing: border-box; - width: 30px; + padding: 1px 1px; height: 20px; font-size: 10px; } .menu-show{ - width: 250px; - display: block; - transition: 5s; + left: 0; +} + +article{ + z-index: 0; + width: 100%; + display: flex; + justify-content: space-evenly; + margin-top: 10px; +} + +.col-headline{ + border: 1px solid #6C757D; + border-radius: 10px; + width: 56.33%; + padding: 30px; +} + +.col-article{ + border: 1px solid #6C757D; + border-radius: 10px; + width: 20%; + display: flex; + align-items: center; + flex-direction: column +} + +.article-list{ + margin-top: 30px; +} + +.article-list li{ + list-style: none; + margin: 10px 20px; } +.author p{ + margin: 0 10px; +} \ No newline at end of file diff --git a/index.html b/index.html deleted file mode 100644 index 2df55148..00000000 --- a/index.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - GO-WEB - - - - -
-

welcome in Hackticle

-

the first Official Website to provide information about hacking in the world

- -
- - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/server/.env b/server/.env new file mode 100644 index 00000000..9b2ca87c --- /dev/null +++ b/server/.env @@ -0,0 +1,2 @@ +PORT=3000 +BASE_URL=mongodb://localhost:17017/miniwpDB diff --git a/server/.env-examples b/server/.env-examples new file mode 100644 index 00000000..e69de29b diff --git a/server/.gitignore b/server/.gitignore new file mode 100644 index 00000000..b512c09d --- /dev/null +++ b/server/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/server/app.js b/server/app.js new file mode 100644 index 00000000..3028c14b --- /dev/null +++ b/server/app.js @@ -0,0 +1,29 @@ +const express = require('express') +const axios = require('axios') +const cors = require('cors') +const mongoose = require('mongoose') +const indexRouter = require('./routes/index') +const errorHandler = require('./middlewares/errorHandler') + +mongoose.connect(process.env.BASE_URL, { useNewUrlParser : false }) + .then(success => { + console.log('mongoose connected success') + }) + .catch(err => { + console.log(err) + console.log('mongoose connected fail') + }) + +const PORT = process.env.PORT || 3000 +const app = express() + +app.use(express.urlencoded({extended:false})) +app.use(express.json()) +app.use(cors()) + +app.use('/', indexRouter) +app.use(errorHandler) + +app.listen(PORT, () => { + console.log(`Running on PORT ${PORT}`) +}) \ No newline at end of file diff --git a/server/controllers/article.js b/server/controllers/article.js new file mode 100644 index 00000000..2bcfba03 --- /dev/null +++ b/server/controllers/article.js @@ -0,0 +1,21 @@ +const Article = require('../models/article') + +class ArticleController{ + static findAll(req, res, next){ + + } + + static write(req, res, next){ + + } + + static update(req, res, next){ + + } + + static remove( req, res, next){ + + } +} + +module.exports = ArticleController \ No newline at end of file diff --git a/server/controllers/user.js b/server/controllers/user.js new file mode 100644 index 00000000..95eaed7b --- /dev/null +++ b/server/controllers/user.js @@ -0,0 +1,37 @@ +const User = require('../models/user') + +class UserController{ + static findAll(req, res, next){ + + } + + static findOne(req, res, next){ + + } + + static register(req, res, next){ + + } + + static login(req, res, next){ + + } + + static signin(req, res, next){ + + } + + static update(req, res, next){ + + } + + static changePassword(req, res, next){ + + } + + static remove(req, res, next){ + + } +} + +module.exports = UserController \ No newline at end of file diff --git a/server/middlewares/errorHandler.js b/server/middlewares/errorHandler.js new file mode 100644 index 00000000..79c101c5 --- /dev/null +++ b/server/middlewares/errorHandler.js @@ -0,0 +1,3 @@ +module.exports = (err, req, res, next) => { + +} \ No newline at end of file diff --git a/server/models/article.js b/server/models/article.js new file mode 100644 index 00000000..b4ad4df9 --- /dev/null +++ b/server/models/article.js @@ -0,0 +1,11 @@ +const mongoose = require('mongoose') +const Schema = mongoose.Schema + +const articleSchema = new Schema({ + title : String, + author : String, + content : String +}) + +const Article = mongoose.model('Article', articleSchema) +module.exports = Article \ No newline at end of file diff --git a/server/models/user.js b/server/models/user.js new file mode 100644 index 00000000..7d5db9ba --- /dev/null +++ b/server/models/user.js @@ -0,0 +1,11 @@ +const mongoose = require('mongoose') +const Schema = mongoose.Schema + +const userSchema = new Schema({ + name : String, + email : String, + password : String +}) + +const User = mongoose.model('User', userSchema) +module.exports = User \ No newline at end of file diff --git a/server/package-lock.json b/server/package-lock.json new file mode 100644 index 00000000..f62bf0da --- /dev/null +++ b/server/package-lock.json @@ -0,0 +1,580 @@ +{ + "name": "server", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "requires": { + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", + "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", + "requires": { + "lodash": "^4.17.11" + } + }, + "axios": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", + "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", + "requires": { + "follow-redirects": "1.5.10", + "is-buffer": "^2.0.2" + } + }, + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" + }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "bson": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz", + "integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg==" + }, + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + }, + "content-disposition": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "requires": { + "safe-buffer": "5.1.2" + } + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "requires": { + "object-assign": "^4", + "vary": "^1" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "dotenv": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.1.0.tgz", + "integrity": "sha512-GUE3gqcDCaMltj2++g6bRQ5rBJWtkWTmqmD0fo1RnnMuUqHNCt2oTPeDnS9n6fKYvlhn7AeBkb38lymBtWBQdA==" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "requires": { + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", + "content-type": "~1.0.4", + "cookie": "0.4.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.1.2", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ipaddr.js": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", + "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" + }, + "is-buffer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" + }, + "kareem": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.1.tgz", + "integrity": "sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw==" + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "requires": { + "mime-db": "1.40.0" + } + }, + "mongodb": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.3.2.tgz", + "integrity": "sha512-fqJt3iywelk4yKu/lfwQg163Bjpo5zDKhXiohycvon4iQHbrfflSAz9AIlRE6496Pm/dQKQK5bMigdVo2s6gBg==", + "requires": { + "bson": "^1.1.1", + "require_optional": "^1.0.1", + "safe-buffer": "^5.1.2" + } + }, + "mongoose": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.7.0.tgz", + "integrity": "sha512-nE43r4kEUpUBfr32rf+zJKEtzd6I3F5YdbrSHp/DDdVQyej34Cv7gfBdcoRNehrPQDV3khOh0JpiS1aLN9/OCw==", + "requires": { + "async": "2.6.2", + "bson": "~1.1.1", + "kareem": "2.3.1", + "mongodb": "3.3.2", + "mongoose-legacy-pluralize": "1.0.2", + "mpath": "0.6.0", + "mquery": "3.2.1", + "ms": "2.1.2", + "regexp-clone": "1.0.0", + "safe-buffer": "5.1.2", + "sift": "7.0.1", + "sliced": "1.0.1" + }, + "dependencies": { + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, + "mongoose-legacy-pluralize": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz", + "integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ==" + }, + "mpath": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.6.0.tgz", + "integrity": "sha512-i75qh79MJ5Xo/sbhxrDrPSEG0H/mr1kcZXJ8dH6URU5jD/knFxCVqVC/gVSW7GIXL/9hHWlT9haLbCXWOll3qw==" + }, + "mquery": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.1.tgz", + "integrity": "sha512-kY/K8QToZWTTocm0U+r8rqcJCp5PRl6e8tPmoDs5OeSO3DInZE2rAL6AYH+V406JTo8305LdASOQcxRDqHojyw==", + "requires": { + "bluebird": "3.5.1", + "debug": "3.1.0", + "regexp-clone": "^1.0.0", + "safe-buffer": "5.1.2", + "sliced": "1.0.1" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "proxy-addr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", + "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.0" + } + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + }, + "regexp-clone": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz", + "integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw==" + }, + "require_optional": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", + "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", + "requires": { + "resolve-from": "^2.0.0", + "semver": "^5.1.0" + } + }, + "resolve-from": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", + "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + }, + "dependencies": { + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, + "serve-static": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.1" + } + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + }, + "sift": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz", + "integrity": "sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g==" + }, + "sliced": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", + "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + } + } +} diff --git a/server/package.json b/server/package.json new file mode 100644 index 00000000..af728ba0 --- /dev/null +++ b/server/package.json @@ -0,0 +1,19 @@ +{ + "name": "server", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "axios": "^0.19.0", + "cors": "^2.8.5", + "dotenv": "^8.1.0", + "express": "^4.17.1", + "mongoose": "^5.7.0" + } +} diff --git a/server/routes/article.js b/server/routes/article.js new file mode 100644 index 00000000..7a92000b --- /dev/null +++ b/server/routes/article.js @@ -0,0 +1,10 @@ +const express = require('express') +const router = express.Router() +const articleController = require('../controllers/article') + +router.get('/', articleController.findAll) +router.post('/', articleController.write) +router.put('/'. articleController.update) +router.delete('/', articleController.remove) + +module.exports = router \ No newline at end of file diff --git a/server/routes/index.js b/server/routes/index.js new file mode 100644 index 00000000..4162920c --- /dev/null +++ b/server/routes/index.js @@ -0,0 +1,9 @@ +const express = require('express') +const router = express.Router() +const userRouter = require('./user') +const articleRouter = require('./article') + +router.use('/articles', articleRouter) +router.use('/users', userRouter) + +module.exports = router \ No newline at end of file diff --git a/server/routes/user.js b/server/routes/user.js new file mode 100644 index 00000000..fcdec6d0 --- /dev/null +++ b/server/routes/user.js @@ -0,0 +1,14 @@ +const express = require('express') +const router = express.Router() +const userController = require('../controllers/user') + +router.get('/', userController.findAll) +router.get('/:id', userController.findOne) +router.post('/', userController.register) +router.post('/login', userController.login) +router.post('/signin', userController.signin) +router.put('/:id', userController.update) +router.patch('/:id', userController.changePassword) +router.delete(':id', userController.remove) + +module.exports = router \ No newline at end of file From ac13aaca99abf2d5bf886f2b475ca6a08e0f36dc Mon Sep 17 00:00:00 2001 From: maulanaghozii Date: Wed, 11 Sep 2019 14:46:33 +0700 Subject: [PATCH 04/14] connected mongodb --- server/.env | 2 +- server/.gitignore | 3 ++- server/app.js | 10 ++++++++-- server/package.json | 4 +++- server/routes/article.js | 4 ++-- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/server/.env b/server/.env index 9b2ca87c..c35dfbc6 100644 --- a/server/.env +++ b/server/.env @@ -1,2 +1,2 @@ PORT=3000 -BASE_URL=mongodb://localhost:17017/miniwpDB +BASE_URL=mongodb://localhost:27017/miniwpDB \ No newline at end of file diff --git a/server/.gitignore b/server/.gitignore index b512c09d..1dcef2d9 100644 --- a/server/.gitignore +++ b/server/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +.env \ No newline at end of file diff --git a/server/app.js b/server/app.js index 3028c14b..854a635c 100644 --- a/server/app.js +++ b/server/app.js @@ -1,3 +1,7 @@ +if(process.env.NODE_ENV === 'development') { + require('dotenv').config() +} + const express = require('express') const axios = require('axios') const cors = require('cors') @@ -5,7 +9,9 @@ const mongoose = require('mongoose') const indexRouter = require('./routes/index') const errorHandler = require('./middlewares/errorHandler') -mongoose.connect(process.env.BASE_URL, { useNewUrlParser : false }) +console.log(process.env.BASE_URL) + +mongoose.connect(process.env.BASE_URL, { useNewUrlParser : true, useUnifiedTopology: true }) .then(success => { console.log('mongoose connected success') }) @@ -21,7 +27,7 @@ app.use(express.urlencoded({extended:false})) app.use(express.json()) app.use(cors()) -app.use('/', indexRouter) +// app.use('/', indexRouter) app.use(errorHandler) app.listen(PORT, () => { diff --git a/server/package.json b/server/package.json index af728ba0..d301dcc4 100644 --- a/server/package.json +++ b/server/package.json @@ -4,7 +4,9 @@ "description": "", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "dev": "NODE_ENV=development nodemon app.js", + "start": "nodemon app.js" }, "keywords": [], "author": "", diff --git a/server/routes/article.js b/server/routes/article.js index 7a92000b..f9c116bb 100644 --- a/server/routes/article.js +++ b/server/routes/article.js @@ -4,7 +4,7 @@ const articleController = require('../controllers/article') router.get('/', articleController.findAll) router.post('/', articleController.write) -router.put('/'. articleController.update) -router.delete('/', articleController.remove) +// router.put('/:id'. articleController.update) +router.delete('/:id', articleController.remove) module.exports = router \ No newline at end of file From 1963a16c01f00d6e66db5858c798e88ef621c270 Mon Sep 17 00:00:00 2001 From: maulanaghozii Date: Wed, 11 Sep 2019 15:47:21 +0700 Subject: [PATCH 05/14] test --- server/app.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/app.js b/server/app.js index 854a635c..3562355b 100644 --- a/server/app.js +++ b/server/app.js @@ -27,6 +27,9 @@ app.use(express.urlencoded({extended:false})) app.use(express.json()) app.use(cors()) +app.get('/', (req, res) => { + res.send(`Mantappp Connect CCCUUUUKKKKK`) +}) // app.use('/', indexRouter) app.use(errorHandler) From 2464a537f6de17a8c740c1e511ba5b3ac436f28b Mon Sep 17 00:00:00 2001 From: maulanaghozii Date: Thu, 12 Sep 2019 00:34:15 +0700 Subject: [PATCH 06/14] authentication done --- client/index.html | 5 +- server/.env | 3 +- server/app.js | 8 +- server/controllers/article.js | 34 +++++- server/controllers/user.js | 67 ++++++++++-- server/helpers/bcryptjs.js | 11 ++ server/helpers/jwt.js | 11 ++ server/middlewares/authentication.js | 10 ++ server/middlewares/authorization.js | 0 server/middlewares/errorHandler.js | 28 ++++- server/models/article.js | 2 +- server/models/user.js | 21 +++- server/package-lock.json | 150 +++++++++++++++++++++++++++ server/package.json | 6 +- server/routes/article.js | 4 +- server/routes/user.js | 1 - server/testing.js | 0 17 files changed, 334 insertions(+), 27 deletions(-) create mode 100644 server/helpers/bcryptjs.js create mode 100644 server/helpers/jwt.js create mode 100644 server/middlewares/authentication.js create mode 100644 server/middlewares/authorization.js create mode 100644 server/testing.js diff --git a/client/index.html b/client/index.html index 0ac65b9a..cfe245a1 100644 --- a/client/index.html +++ b/client/index.html @@ -143,7 +143,6 @@

List Article

this.authorHead = this.articles[0].author this.createdAthead = this.articles[0].created_at this.contentHead = this.articles[0].content - // console.log(this.articles) }) .catch(err => { console.log(err) @@ -161,7 +160,6 @@

List Article

let getYear = date.getFullYear() let getMonth = date.getMonth() let getDate = date.getDate() - console.log(quill.root.innerHTML) let title = this.title let content = quill.root.innerHTML let author = 'Ghozi' @@ -183,7 +181,7 @@

List Article

}, getPage3 : function(){ if(!quill){ - quill = new Quill('#content', {theme : 'snow', placeholder : 'Content'}); + quill = new Quill('#content',{}); } this.isCreateArticle = true this.isMenu = false @@ -196,7 +194,6 @@

List Article

this.contentHead = content }, showMenu : function(){ - console.log(`<<<<<<<<<<<<<<<,,,,,mausk`) if(this.isMenu) this.isMenu = false else this.isMenu = true } diff --git a/server/.env b/server/.env index c35dfbc6..1a1fbe7a 100644 --- a/server/.env +++ b/server/.env @@ -1,2 +1,3 @@ PORT=3000 -BASE_URL=mongodb://localhost:27017/miniwpDB \ No newline at end of file +BASE_URL=mongodb://localhost:27017/miniwpDB +JWT_SECRET=TANGOBUBBLEGUM \ No newline at end of file diff --git a/server/app.js b/server/app.js index 3562355b..27f05871 100644 --- a/server/app.js +++ b/server/app.js @@ -8,10 +8,9 @@ const cors = require('cors') const mongoose = require('mongoose') const indexRouter = require('./routes/index') const errorHandler = require('./middlewares/errorHandler') +const morgan = require('morgan') -console.log(process.env.BASE_URL) - -mongoose.connect(process.env.BASE_URL, { useNewUrlParser : true, useUnifiedTopology: true }) +mongoose.connect(process.env.BASE_URL, { useNewUrlParser : true, useUnifiedTopology: true, useCreateIndex : true }) .then(success => { console.log('mongoose connected success') }) @@ -26,11 +25,12 @@ const app = express() app.use(express.urlencoded({extended:false})) app.use(express.json()) app.use(cors()) +app.use(morgan('combined')) app.get('/', (req, res) => { res.send(`Mantappp Connect CCCUUUUKKKKK`) }) -// app.use('/', indexRouter) +app.use('/', indexRouter) app.use(errorHandler) app.listen(PORT, () => { diff --git a/server/controllers/article.js b/server/controllers/article.js index 2bcfba03..0cb3efc1 100644 --- a/server/controllers/article.js +++ b/server/controllers/article.js @@ -2,19 +2,45 @@ const Article = require('../models/article') class ArticleController{ static findAll(req, res, next){ - + Article.find().sort([['createdAt', -1]]) + .then(articles => { + res.status(200).json(articles) + }) + .catch(next) } static write(req, res, next){ - + const { title, author, content } = req.body + Article.create({ + title, author, content + }) + .then(article => { + res.status(201).json(article) + }) + .catch(next) } static update(req, res, next){ - + const { title, content } = req.body + Article.findByIdAndUpdate({ + _id : req.params.id + }, { + title, content + }) + .then(() => { + res.status(201).json({message : `Update Success`}) + }) + .catch(next) } static remove( req, res, next){ - + Article.findByIdAndDelete({ + _id : req.params.id + }) + .then(() => { + res.status(200).json(`Delete Success`) + }) + .catch(next) } } diff --git a/server/controllers/user.js b/server/controllers/user.js index 95eaed7b..0937ad7a 100644 --- a/server/controllers/user.js +++ b/server/controllers/user.js @@ -1,20 +1,55 @@ const User = require('../models/user') +const { tokenGenerate } = require('../helpers/jwt') +const { comparePassword } = require('../helpers/bcryptjs') -class UserController{ - static findAll(req, res, next){ - } +class UserController{ static findOne(req, res, next){ - + } static register(req, res, next){ - + const { name, email, password } = req.body + User.create({ + name, password, email + }) + .then(user => { + res.status(201).json(user) + }) + .catch(next) } static login(req, res, next){ - + const { email, password } = req.body + User.findOne({ + email + }) + .then(user => { + let payload = { + id : user._id, + email : user.email + } + + if(user && comparePassword(password, user.password)){ + let token = tokenGenerate(payload) + res.status(201).json({ + message : `Login Success`, + token + }) + } else { + next({ + status : 400, + message : `Email/Password not valid` + }) + } + }) + .catch(err => { + next({ + status : 400, + message : `Email/Password not valid` + }) + }) } static signin(req, res, next){ @@ -24,9 +59,25 @@ class UserController{ static update(req, res, next){ } - + static changePassword(req, res, next){ - + let password = req.body.password + User.findOne({ + _id : req.params.id + }) + .then(user => { + if(!user) { + next({ + status : 204, + message : `User not found` + }) + } else { + user.password = password + user.save() + } + }) + .catch(next) + } static remove(req, res, next){ diff --git a/server/helpers/bcryptjs.js b/server/helpers/bcryptjs.js new file mode 100644 index 00000000..53ba29ec --- /dev/null +++ b/server/helpers/bcryptjs.js @@ -0,0 +1,11 @@ +const bcryptjs = require('bcryptjs') + +module.exports = { + hashPassword : (password) => { + let salt = bcryptjs.genSaltSync(10) + return bcryptjs.hashSync(password, salt) + }, + comparePassword : (password, hash) => { + return bcryptjs.compareSync(password, hash) + } +} \ No newline at end of file diff --git a/server/helpers/jwt.js b/server/helpers/jwt.js new file mode 100644 index 00000000..38b28f93 --- /dev/null +++ b/server/helpers/jwt.js @@ -0,0 +1,11 @@ +const jwt = require('jsonwebtoken') +const JWT_SECRET = `sdjaskdjjsakdsad` //process.env.JWT_SECRET + +module.exports = { + tokenGenerate : (payload) => { + return jwt.sign(payload, JWT_SECRET) + }, + varify : (token) => { + return jwt.verify(token, JWT_SECRET) + } +} \ No newline at end of file diff --git a/server/middlewares/authentication.js b/server/middlewares/authentication.js new file mode 100644 index 00000000..f78d2c5c --- /dev/null +++ b/server/middlewares/authentication.js @@ -0,0 +1,10 @@ +const { varify } = require('../helpers/jwt') +module.exports = (req, res, next) => { + try{ + let decode = varify(req.headers.token) + req.decode = decode + next() + } catch(err) { + next(err) + } +} \ No newline at end of file diff --git a/server/middlewares/authorization.js b/server/middlewares/authorization.js new file mode 100644 index 00000000..e69de29b diff --git a/server/middlewares/errorHandler.js b/server/middlewares/errorHandler.js index 79c101c5..5eacb760 100644 --- a/server/middlewares/errorHandler.js +++ b/server/middlewares/errorHandler.js @@ -1,3 +1,29 @@ module.exports = (err, req, res, next) => { - + console.log(err) + + let status = err.status || 500 + let message = err.message || "Internal Server Eror" + + if(err.name == 'ValidationError'){ + if(err.errors.email.kind){ + status = 400 + message = `Email has been registered` + } else { + status = 400 + message = err.errors.email.message + } + } else if(err.name == 'JsonWebTokenError') { + if(err.message == 'jwt malformed'){ + status = 403 + message = "you don't have the authority to do this action" + } else if(err.message == 'invalid signature'){ + status = 403 + message = "signatured not valid" + } else { + status = 401 + message = "you must logged in firts" + } + } + + res.status(status).json({message}) } \ No newline at end of file diff --git a/server/models/article.js b/server/models/article.js index b4ad4df9..c73e538a 100644 --- a/server/models/article.js +++ b/server/models/article.js @@ -5,7 +5,7 @@ const articleSchema = new Schema({ title : String, author : String, content : String -}) +}, {timestamps : true}) const Article = mongoose.model('Article', articleSchema) module.exports = Article \ No newline at end of file diff --git a/server/models/user.js b/server/models/user.js index 7d5db9ba..60edefee 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -1,11 +1,30 @@ const mongoose = require('mongoose') +const uniqueValidator = require('mongoose-unique-validator') +const { hashPassword } = require('../helpers/bcryptjs') const Schema = mongoose.Schema const userSchema = new Schema({ name : String, - email : String, + email : { + type : String, + unique : [true, `Email has been registered`], + validate : { + validator : function(value){ + let re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + return re.test(value) + }, + message :`Email format is not a valid!` + } + }, password : String }) +userSchema.pre('save', function(next){ + this.password = hashPassword(this.password) + next() +}) + +userSchema.plugin(uniqueValidator) + const User = mongoose.model('User', userSchema) module.exports = User \ No newline at end of file diff --git a/server/package-lock.json b/server/package-lock.json index f62bf0da..b8800a49 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -35,6 +35,19 @@ "is-buffer": "^2.0.2" } }, + "basic-auth": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", + "requires": { + "safe-buffer": "5.1.2" + } + }, + "bcryptjs": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", + "integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=" + }, "bluebird": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", @@ -72,6 +85,11 @@ "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz", "integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg==" }, + "buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=" + }, "bytes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", @@ -132,6 +150,14 @@ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.1.0.tgz", "integrity": "sha512-GUE3gqcDCaMltj2++g6bRQ5rBJWtkWTmqmD0fo1RnnMuUqHNCt2oTPeDnS9n6fKYvlhn7AeBkb38lymBtWBQdA==" }, + "ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "requires": { + "safe-buffer": "^5.0.1" + } + }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -276,6 +302,49 @@ "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" }, + "jsonwebtoken": { + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz", + "integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==", + "requires": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^5.6.0" + }, + "dependencies": { + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, + "jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "requires": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "requires": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, "kareem": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.1.tgz", @@ -286,6 +355,51 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, + "lodash.foreach": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.foreach/-/lodash.foreach-4.5.0.tgz", + "integrity": "sha1-Gmo16s5AEoDH8G3d7DUWWrJ+PlM=" + }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" + }, + "lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8=" + }, + "lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY=" + }, + "lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha1-YZwK89A/iwTDH1iChAt3sRzWg0M=" + }, + "lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w=" + }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" + }, + "lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=" + }, + "lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=" + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -360,6 +474,37 @@ "resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz", "integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ==" }, + "mongoose-unique-validator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/mongoose-unique-validator/-/mongoose-unique-validator-2.0.3.tgz", + "integrity": "sha512-3/8pmvAC1acBZS6eWKAWQUiZBlARE1wyWtjga4iQ2wDJeOfRlIKmAvTNHSZXKaAf7RCRUd7wh7as6yWAOrjpQg==", + "requires": { + "lodash.foreach": "^4.1.0", + "lodash.get": "^4.0.2" + } + }, + "morgan": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz", + "integrity": "sha512-HQStPIV4y3afTiCYVxirakhlCfGkI161c76kKFca7Fk1JusM//Qeo1ej2XaMniiNeaZklMVrh3vTtIzpzwbpmA==", + "requires": { + "basic-auth": "~2.0.0", + "debug": "2.6.9", + "depd": "~1.1.2", + "on-finished": "~2.3.0", + "on-headers": "~1.0.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } + } + }, "mpath": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.6.0.tgz", @@ -400,6 +545,11 @@ "ee-first": "1.1.1" } }, + "on-headers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", + "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==" + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", diff --git a/server/package.json b/server/package.json index d301dcc4..84d3e543 100644 --- a/server/package.json +++ b/server/package.json @@ -13,9 +13,13 @@ "license": "ISC", "dependencies": { "axios": "^0.19.0", + "bcryptjs": "^2.4.3", "cors": "^2.8.5", "dotenv": "^8.1.0", "express": "^4.17.1", - "mongoose": "^5.7.0" + "jsonwebtoken": "^8.5.1", + "mongoose": "^5.7.0", + "mongoose-unique-validator": "^2.0.3", + "morgan": "^1.9.1" } } diff --git a/server/routes/article.js b/server/routes/article.js index f9c116bb..f7c8416a 100644 --- a/server/routes/article.js +++ b/server/routes/article.js @@ -1,10 +1,12 @@ const express = require('express') const router = express.Router() const articleController = require('../controllers/article') +const authenticaton = require('../middlewares/authentication') +router.use(authenticaton) router.get('/', articleController.findAll) router.post('/', articleController.write) -// router.put('/:id'. articleController.update) +router.put('/:id', articleController.update) router.delete('/:id', articleController.remove) module.exports = router \ No newline at end of file diff --git a/server/routes/user.js b/server/routes/user.js index fcdec6d0..a4684588 100644 --- a/server/routes/user.js +++ b/server/routes/user.js @@ -2,7 +2,6 @@ const express = require('express') const router = express.Router() const userController = require('../controllers/user') -router.get('/', userController.findAll) router.get('/:id', userController.findOne) router.post('/', userController.register) router.post('/login', userController.login) diff --git a/server/testing.js b/server/testing.js new file mode 100644 index 00000000..e69de29b From f29f7d4c105f666a9a1cf27b259072a8e6790866 Mon Sep 17 00:00:00 2001 From: maulanaghozii Date: Mon, 16 Sep 2019 07:33:47 +0700 Subject: [PATCH 07/14] migrate from global to component --- client/.gitignore | 3 + client/index.html | 219 +------- client/package-lock.json | 421 +++++++++++++++ client/package.json | 26 + client/script/article.js | 0 client/script/index.js | 3 - client/src/App.vue | 85 ++++ client/src/components/article.vue | 86 ++++ client/src/components/firstPage.vue | 37 ++ client/src/components/landingPgae.vue | 49 ++ client/src/components/login.vue | 196 +++++++ client/src/components/navContent.vue | 66 +++ client/src/components/navbar.vue | 123 +++++ client/src/components/register.vue | 145 ++++++ client/src/components/secondPage.vue | 78 +++ client/src/components/title.vue | 102 ++++ client/src/components/wygiwys.vue | 705 ++++++++++++++++++++++++++ client/src/main.js | 14 + client/src/vueWysiwyg.js | 1 + client/style.css | 108 ---- server/.env | 7 +- server/controllers/article.js | 83 ++- server/controllers/user.js | 173 +++++-- server/helpers/jwt.js | 2 +- server/middlewares/authorization.js | 16 + server/models/article.js | 20 +- server/models/user.js | 26 +- server/package-lock.json | 160 ++++++ server/package.json | 1 + server/routes/article.js | 6 +- server/routes/user.js | 2 - 31 files changed, 2558 insertions(+), 405 deletions(-) create mode 100644 client/.gitignore create mode 100644 client/package-lock.json create mode 100644 client/package.json delete mode 100644 client/script/article.js delete mode 100644 client/script/index.js create mode 100644 client/src/App.vue create mode 100644 client/src/components/article.vue create mode 100644 client/src/components/firstPage.vue create mode 100644 client/src/components/landingPgae.vue create mode 100644 client/src/components/login.vue create mode 100644 client/src/components/navContent.vue create mode 100644 client/src/components/navbar.vue create mode 100644 client/src/components/register.vue create mode 100644 client/src/components/secondPage.vue create mode 100644 client/src/components/title.vue create mode 100644 client/src/components/wygiwys.vue create mode 100644 client/src/main.js create mode 100644 client/src/vueWysiwyg.js delete mode 100644 client/style.css diff --git a/client/.gitignore b/client/.gitignore new file mode 100644 index 00000000..587e4ec7 --- /dev/null +++ b/client/.gitignore @@ -0,0 +1,3 @@ +node_modules +.cache +dist \ No newline at end of file diff --git a/client/index.html b/client/index.html index cfe245a1..e06f6ec9 100644 --- a/client/index.html +++ b/client/index.html @@ -1,207 +1,32 @@ + - - - - - - GO-WEB + + + + Hackticle + - -
- -
-

welcome in Hackticle

-

the first Official Website to provide information about hacking in the world

- -
- - - - - - - -
- -
- - - -
-
- -
-
- -
- -
- - - -
-
-
-

{{ titleHead }}

-
- -
-

Author : {{ authorHead }}

-

Publish : {{ createdAthead }}

-
- -
-

-
- -
- -
-

List Article

-
- -
-
-
- -
- - - - - - - - + +
+ + + + + + \ No newline at end of file diff --git a/client/package-lock.json b/client/package-lock.json new file mode 100644 index 00000000..72437588 --- /dev/null +++ b/client/package-lock.json @@ -0,0 +1,421 @@ +{ + "name": "client", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@vue/component-compiler-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@vue/component-compiler-utils/-/component-compiler-utils-3.0.0.tgz", + "integrity": "sha512-am+04/0UX7ektcmvhYmrf84BDVAD8afFOf4asZjN84q8xzxFclbk5x0MtxuKGfp+zjN5WWPJn3fjFAWtDdIGSw==", + "dev": true, + "requires": { + "consolidate": "^0.15.1", + "hash-sum": "^1.0.2", + "lru-cache": "^4.1.2", + "merge-source-map": "^1.1.0", + "postcss": "^7.0.14", + "postcss-selector-parser": "^5.0.0", + "prettier": "1.16.3", + "source-map": "~0.6.1", + "vue-template-es2015-compiler": "^1.9.0" + } + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "anymatch": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.0.tgz", + "integrity": "sha512-Ozz7l4ixzI7Oxj2+cw+p0tVUt27BpaJ+1+q1TCeANWxHpvyn2+Un+YamBdfKu0uh8xLodGhoa1v7595NhKDAuA==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "axios": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", + "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", + "requires": { + "follow-redirects": "1.5.10", + "is-buffer": "^2.0.2" + } + }, + "binary-extensions": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", + "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", + "dev": true + }, + "bluebird": { + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", + "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==", + "dev": true + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "chokidar": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.0.2.tgz", + "integrity": "sha512-c4PR2egjNjI1um6bamCQ6bUNPDiyofNQruHvKgHQ4gDUP/ITSVSzNsiI5OWtHOsX323i5ha/kk4YmOZ1Ktg7KA==", + "dev": true, + "requires": { + "anymatch": "^3.0.1", + "braces": "^3.0.2", + "fsevents": "^2.0.6", + "glob-parent": "^5.0.0", + "is-binary-path": "^2.1.0", + "is-glob": "^4.0.1", + "normalize-path": "^3.0.0", + "readdirp": "^3.1.1" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "consolidate": { + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/consolidate/-/consolidate-0.15.1.tgz", + "integrity": "sha512-DW46nrsMJgy9kqAbPt5rKaCr7uFtpo4mSUvLHIUbJEjm0vo+aY5QLwBUq3FK4tRnJr/X0Psc0C4jf/h+HtXSMw==", + "dev": true, + "requires": { + "bluebird": "^3.1.1" + } + }, + "cssesc": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-2.0.0.tgz", + "integrity": "sha512-MsCAG1z9lPdoO/IUMLSBWBSVxVtJ1395VGIQ+Fc2gNdkQ1hNDnQdw3YhA71WJCBW1vdwA0cAnk/DnW6bqoEUYg==", + "dev": true + }, + "de-indent": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz", + "integrity": "sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" + } + }, + "fsevents": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.0.7.tgz", + "integrity": "sha512-a7YT0SV3RB+DjYcppwVDLtn13UQnmg0SWZS7ezZD0UjnLwXmy8Zm21GMVGLaFGimIqcvyMQaOJBrop8MyOp1kQ==", + "dev": true, + "optional": true + }, + "glob-parent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.0.0.tgz", + "integrity": "sha512-Z2RwiujPRGluePM6j699ktJYxmPpJKCfpGA13jz2hmFZC7gKetzrWvg5KN3+OsIFmydGyZ1AVwERCq1w/ZZwRg==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "hash-sum": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/hash-sum/-/hash-sum-1.0.2.tgz", + "integrity": "sha1-M7QHd3VMZDJXPBIMw4CLvRDUfwQ=", + "dev": true + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, + "indexes-of": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/indexes-of/-/indexes-of-1.0.1.tgz", + "integrity": "sha1-8w9xbI4r00bHtn0985FVZqfAVgc=", + "dev": true + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-buffer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "dev": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "material-icons": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/material-icons/-/material-icons-0.3.1.tgz", + "integrity": "sha512-5Hbj76A6xDPcDZEbM4oxTknhWuMwGWnAHVLLPCEq9eVlcHb0fn4koU9ZeyMy1wjARtDEPAHfd5ZdL2Re5hf0zQ==" + }, + "merge-source-map": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/merge-source-map/-/merge-source-map-1.1.0.tgz", + "integrity": "sha512-Qkcp7P2ygktpMPh2mCQZaf3jhN6D3Z/qVZHSdWvQ+2Ef5HgRAPBO57A77+ENm0CPx2+1Ce/MYKi3ymqdfuqibw==", + "dev": true, + "requires": { + "source-map": "^0.6.1" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "picomatch": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.0.7.tgz", + "integrity": "sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA==", + "dev": true + }, + "postcss": { + "version": "7.0.18", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.18.tgz", + "integrity": "sha512-/7g1QXXgegpF+9GJj4iN7ChGF40sYuGYJ8WZu8DZWnmhQ/G36hfdk3q9LBJmoK+lZ+yzZ5KYpOoxq7LF1BxE8g==", + "dev": true, + "requires": { + "chalk": "^2.4.2", + "source-map": "^0.6.1", + "supports-color": "^6.1.0" + } + }, + "postcss-selector-parser": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-5.0.0.tgz", + "integrity": "sha512-w+zLE5Jhg6Liz8+rQOWEAwtwkyqpfnmsinXjXg6cY7YIONZZtgvE0v2O0uhQBs0peNomOJwWRKt6JBfTdTd3OQ==", + "dev": true, + "requires": { + "cssesc": "^2.0.0", + "indexes-of": "^1.0.1", + "uniq": "^1.0.1" + } + }, + "prettier": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.16.3.tgz", + "integrity": "sha512-kn/GU6SMRYPxUakNXhpP0EedT/KmaPzr0H5lIsDogrykbaxOpOfAFfk5XA7DZrJyMAv1wlMV3CPcZruGXVVUZw==", + "dev": true + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, + "readdirp": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.1.2.tgz", + "integrity": "sha512-8rhl0xs2cxfVsqzreYCvs8EwBfn/DhVdqtoLmw19uI3SC5avYX9teCurlErfpPXGmYtMHReGaP2RsLnFvz/lnw==", + "dev": true, + "requires": { + "picomatch": "^2.0.4" + } + }, + "sass": { + "version": "1.22.12", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.22.12.tgz", + "integrity": "sha512-u5Rxn+dKTPCW5/11kMNxtmqKsxCjcpnqj9CaJoru1NqeJ0DOa9rOM00e0HqmseTAatGkKoLY+jaNecMYevu1gg==", + "dev": true, + "requires": { + "chokidar": ">=2.0.0 <4.0.0" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "supports-color": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", + "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "sweetalert2": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-8.17.1.tgz", + "integrity": "sha512-aCPXmK1YyVUfsw36iDETzUnYj1fxwXSY/dkt8cnqViv7f5sOS5i37LXIf9LLiDCd99EbY4d4kvZkyWYlJZ79Xw==" + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "uniq": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", + "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", + "dev": true + }, + "vue": { + "version": "2.6.10", + "resolved": "https://registry.npmjs.org/vue/-/vue-2.6.10.tgz", + "integrity": "sha512-ImThpeNU9HbdZL3utgMCq0oiMzAkt1mcgy3/E6zWC/G6AaQoeuFdsl9nDhTDU3X1R6FK7nsIUuRACVcjI+A2GQ==" + }, + "vue-google-signin-button": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/vue-google-signin-button/-/vue-google-signin-button-1.0.4.tgz", + "integrity": "sha512-spmf+qPQQ1zAEndDxybYsf22U47eYPuvU9cb1N9YETmPQ4+UBG9ALLxgID1mHkusvBVclRyxmvJc3zc7hD56wg==" + }, + "vue-hot-reload-api": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz", + "integrity": "sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog==" + }, + "vue-template-compiler": { + "version": "2.6.10", + "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.10.tgz", + "integrity": "sha512-jVZkw4/I/HT5ZMvRnhv78okGusqe0+qH2A0Em0Cp8aq78+NK9TII263CDVz2QXZsIT+yyV/gZc/j/vlwa+Epyg==", + "dev": true, + "requires": { + "de-indent": "^1.0.2", + "he": "^1.1.0" + } + }, + "vue-template-es2015-compiler": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz", + "integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==", + "dev": true + }, + "vuesax": { + "version": "3.10.2", + "resolved": "https://registry.npmjs.org/vuesax/-/vuesax-3.10.2.tgz", + "integrity": "sha512-OfHBdRNvY9DEHsIMrGjhWQtI456+opbXARRYP+xtmwiYObP84RUpT1F7JqetLmmRxNpj/n1WK1XxMo8SSpR4Xg==", + "requires": { + "chalk": "^2.4.2", + "vue": "^2.6.9" + } + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true + } + } +} diff --git a/client/package.json b/client/package.json new file mode 100644 index 00000000..3c0a46c9 --- /dev/null +++ b/client/package.json @@ -0,0 +1,26 @@ +{ + "name": "client", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "axios": "^0.19.0", + "material-icons": "^0.3.1", + "sweetalert2": "^8.17.1", + "vue": "^2.6.10", + "vue-google-signin-button": "^1.0.4", + "vue-hot-reload-api": "^2.3.4", + "vuesax": "^3.10.2" + }, + "devDependencies": { + "@vue/component-compiler-utils": "^3.0.0", + "sass": "^1.22.12", + "vue-template-compiler": "^2.6.10" + } +} diff --git a/client/script/article.js b/client/script/article.js deleted file mode 100644 index e69de29b..00000000 diff --git a/client/script/index.js b/client/script/index.js deleted file mode 100644 index 6223f849..00000000 --- a/client/script/index.js +++ /dev/null @@ -1,3 +0,0 @@ -$('.navbar-toggler').click(function(){ - $('.collapse').toggleClass('show') -}) \ No newline at end of file diff --git a/client/src/App.vue b/client/src/App.vue new file mode 100644 index 00000000..560d62db --- /dev/null +++ b/client/src/App.vue @@ -0,0 +1,85 @@ + + + + + \ No newline at end of file diff --git a/client/src/components/article.vue b/client/src/components/article.vue new file mode 100644 index 00000000..657181ee --- /dev/null +++ b/client/src/components/article.vue @@ -0,0 +1,86 @@ + + + + + \ No newline at end of file diff --git a/client/src/components/firstPage.vue b/client/src/components/firstPage.vue new file mode 100644 index 00000000..062e05b7 --- /dev/null +++ b/client/src/components/firstPage.vue @@ -0,0 +1,37 @@ + + + + + \ No newline at end of file diff --git a/client/src/components/landingPgae.vue b/client/src/components/landingPgae.vue new file mode 100644 index 00000000..f67c3515 --- /dev/null +++ b/client/src/components/landingPgae.vue @@ -0,0 +1,49 @@ + + + + + \ No newline at end of file diff --git a/client/src/components/login.vue b/client/src/components/login.vue new file mode 100644 index 00000000..0042c7b7 --- /dev/null +++ b/client/src/components/login.vue @@ -0,0 +1,196 @@ + + + + + \ No newline at end of file diff --git a/client/src/components/navContent.vue b/client/src/components/navContent.vue new file mode 100644 index 00000000..13a0813b --- /dev/null +++ b/client/src/components/navContent.vue @@ -0,0 +1,66 @@ + + + + + \ No newline at end of file diff --git a/client/src/components/navbar.vue b/client/src/components/navbar.vue new file mode 100644 index 00000000..8abb5e1a --- /dev/null +++ b/client/src/components/navbar.vue @@ -0,0 +1,123 @@ + + + + + \ No newline at end of file diff --git a/client/src/components/register.vue b/client/src/components/register.vue new file mode 100644 index 00000000..8b33829e --- /dev/null +++ b/client/src/components/register.vue @@ -0,0 +1,145 @@ + + + + + \ No newline at end of file diff --git a/client/src/components/secondPage.vue b/client/src/components/secondPage.vue new file mode 100644 index 00000000..87dddc49 --- /dev/null +++ b/client/src/components/secondPage.vue @@ -0,0 +1,78 @@ + + + + \ No newline at end of file diff --git a/client/src/components/title.vue b/client/src/components/title.vue new file mode 100644 index 00000000..4c3ea86d --- /dev/null +++ b/client/src/components/title.vue @@ -0,0 +1,102 @@ + + + + + \ No newline at end of file diff --git a/client/src/components/wygiwys.vue b/client/src/components/wygiwys.vue new file mode 100644 index 00000000..79b54c7e --- /dev/null +++ b/client/src/components/wygiwys.vue @@ -0,0 +1,705 @@ + + + + + \ No newline at end of file diff --git a/client/src/main.js b/client/src/main.js new file mode 100644 index 00000000..005a692f --- /dev/null +++ b/client/src/main.js @@ -0,0 +1,14 @@ +import Vue from 'vue'; +import App from './App.vue'; +import Vuesax from 'vuesax' +import 'material-icons/iconfont/material-icons.css'; +import 'vuesax/dist/vuesax.css' +import GSignInButton from 'vue-google-signin-button' + +Vue.use(GSignInButton) +Vue.use(Vuesax) +window.Univers = new Vue() + +new Vue({ + render: createElement => createElement(App) +}).$mount('#App'); \ No newline at end of file diff --git a/client/src/vueWysiwyg.js b/client/src/vueWysiwyg.js new file mode 100644 index 00000000..4ac6da8d --- /dev/null +++ b/client/src/vueWysiwyg.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("vueWysiwyg",[],t):"object"==typeof exports?exports.vueWysiwyg=t():e.vueWysiwyg=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/vue-wysiwyg/",n(n.s=18)}([function(e,t,n){"use strict";t.a=function(e,t,n,i,o,r,s,a){var l=typeof(e=e||{}).default;"object"!==l&&"function"!==l||(e=e.default);var u,c="function"==typeof e?e.options:e;t&&(c.render=t,c.staticRenderFns=n,c._compiled=!0);i&&(c.functional=!0);r&&(c._scopeId=r);s?(u=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},c._ssrRegister=u):o&&(u=a?function(){o.call(this,this.$root.$options.shadowRoot)}:o);if(u)if(c.functional){c._injectStyles=u;var d=c.render;c.render=function(e,t){return u.call(t),d(e,t)}}else{var p=c.beforeCreate;c.beforeCreate=p?[].concat(p,u):[u]}return{exports:e,options:c}}},function(e,t,n){"use strict";var i=new function(){var e={listeners:{},on:function(t,n){void 0===e.listeners[t]&&(e.listeners[t]=[]),e.listeners[t].push(n)},emit:function(t){for(var n=arguments.length,i=Array(10?i:n)(e)}},function(e,t,n){"use strict";var i=n(2),o=n.n(i),r=n(1),s=n(50),a=n.n(s),l=n(51),u=n(53),c=n.n(u),d=n(54),p=n.n(d),h=n(55),f=n.n(h),v=n(56),m=n.n(v),g=n(57),b=n.n(g),w=n(58),y=n.n(w),q=n(59),k=n(61),z=n(63),x=n.n(z),F=n(64),E=n.n(F),_=n(65),C=n.n(_),S=n(66),L=n(72),M=n(75),T=n.n(M),A=n(76),O=n.n(A),D=[c.a,p.a,f.a,O.a,m.a,b.a,y.a,O.a,q.a,k.a,x.a,E.a,C.a,O.a,S.a,L.a,O.a,T.a];t.a={model:{prop:"html",event:"html"},props:{html:{type:String,default:""},placeholder:{type:String,default:"Enter text..."},options:Object},components:{Btn:l.a},data:function(){return{selection:""}},computed:{mergedOptions:function(){return o()({},r.a.options,this.options)},modules:function(){var e=this,t=this.mergedOptions.iconOverrides;return D.filter(function(t){return void 0===e.mergedOptions.hideModules||!e.mergedOptions.hideModules[t.title]}).map(function(e){return void 0!==t&&void 0!==t[e.title]&&(e.icon=t[e.title]),e}).concat(this.mergedOptions.customModules)},btnsWithDashboards:function(){return this.modules?this.modules.filter(function(e){return e.render}):[]},innerHTML:{get:function(){return this.$refs.content.innerHTML},set:function(e){this.$refs.content.innerHTML!==e&&(this.$refs.content.innerHTML=e)}}},methods:{saveSelection:function(){if(void 0!==window.getSelection){if(this.selection=window.getSelection(),this.selection.getRangeAt&&this.selection.rangeCount)return this.selection.getRangeAt(0)}else if(document.selection&&document.selection.createRange)return document.selection.createRange();return null},restoreSelection:function(e){e&&(void 0===window.getSelection?document.selection&&e.select&&e.select():(this.selection=window.getSelection(),this.selection.removeAllRanges(),this.selection.addRange(e)))},clearSelection:function(){this.selection=null;var e=window.getSelection();e&&(void 0!==e.empty&&e.empty(),void 0!==e.removeAllRanges&&e.removeAllRanges())},exec:function(e,t,n){!1!==n&&this.selection&&this.restoreSelection(this.selection),document.execCommand(e,!1,t||""),this.clearSelection(),this.$nextTick(this.emit)},onDocumentClick:function(e){for(var t,n=0;n',methods:{insertHeading:function(e){this.$parent.closeDashboard(),this.$emit("exec","formatBlock",e.target.textContent)}}}},function(e,t,n){"use strict";var i=n(1);t.a={title:"link",icon:'',description:"Hyperlink",props:{uid:null},data:function(){return{url:"",title:""}},methods:{insertLink:function(){this.$emit("exec","insertHTML",""+this.title+""),this.$parent.closeDashboard(),this.url="",this.title=""}},created:function(){var e=this;i.a.on(this.uid+"_show_dashboard_link",function(){e.$nextTick(function(){e.$refs.url.focus()})})}}},function(e,t,n){"use strict";var i=n(2),o=n.n(i),r=n(67),s=n.n(r),a=(n(1),n(70));n.n(a);t.a={title:"image",icon:'',description:"Insert Image",props:["options"],components:{Dropzone:s.a},computed:{uploadURL:function(){return this.options.image.uploadURL},dropzoneOptions:function(){return o()({},this.options.image.dropzoneOptions,{id:this._uid+"vwdropzone",url:this.uploadURL,autoProcessQueue:"None"!==this.uploadURL,dictDefaultMessage:'
Click here to upload...'})}},methods:{fileUploaded:function(e,t){t&&this.$emit("exec","insertHTML","")},fileAdded:function(e){var t=this;if(!e||"None"===this.uploadURL){var n=new FileReader;n.addEventListener("load",function(){t.$emit("exec","insertHTML","")},!1),n.readAsDataURL(e)}}}}},function(e,t,n){"use strict";t.a={title:"table",description:"Insert Table",icon:'',data:function(){return{rows:2,cols:2}},methods:{insertTable:function(){var e=(""+"".repeat(this.cols)+"").repeat(this.rows);this.$emit("exec","insertHTML",""+e+"
"),this.$parent.closeDashboard()}}}},function(e,t,n){e.exports=n(19)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),o=n.n(i),r=n(48),s=n(1);t.default={install:function(e){var t=1u;)for(var p,h=a(arguments[u++]),f=c?i(h).concat(c(h)):i(h),v=f.length,m=0;v>m;)d.call(h,p=f[m++])&&(n[p]=h[p]);return n}:l},function(e,t,n){var i=n(35),o=n(44);e.exports=Object.keys||function(e){return i(e,o)}},function(e,t,n){var i=n(36),o=n(8),r=n(38)(!1),s=n(41)("IE_PROTO");e.exports=function(e,t){var n,a=o(e),l=0,u=[];for(n in a)n!=s&&i(a,n)&&u.push(n);for(;t.length>l;)i(a,n=t[l++])&&(~r(u,n)||u.push(n));return u}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var i=n(8),o=n(39),r=n(40);e.exports=function(e){return function(t,n,s){var a,l=i(t),u=o(l.length),c=r(s,u);if(e&&n!=n){for(;u>c;)if((a=l[c++])!=a)return!0}else for(;u>c;c++)if((e||c in l)&&l[c]===n)return e||c||0;return!e&&-1}}},function(e,t,n){var i=n(11),o=Math.min;e.exports=function(e){return e>0?o(i(e),9007199254740991):0}},function(e,t,n){var i=n(11),o=Math.max,r=Math.min;e.exports=function(e,t){return(e=i(e))<0?o(e+t,0):r(e,t)}},function(e,t,n){var i=n(42)("keys"),o=n(43);e.exports=function(e){return i[e]||(i[e]=o(e))}},function(e,t,n){var i=n(3),o=i["__core-js_shared__"]||(i["__core-js_shared__"]={});e.exports=function(e){return o[e]||(o[e]={})}},function(e,t){var n=0,i=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++n+i).toString(36))}},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t){t.f=Object.getOwnPropertySymbols},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){var i=n(10);e.exports=function(e){return Object(i(e))}},function(e,t,n){"use strict";var i=n(12),o=n(77),r=n(0);var s=function(e){n(49)},a=Object(r.a)(i.a,o.a,o.b,!1,s,null,null);t.a=a.exports},function(e,t){},function(e,t){e.exports=function(e,t,n){var i,o,r,s,a;function l(){var u=Date.now()-s;u=0?i=setTimeout(l,t-u):(i=null,n||(a=e.apply(r,o),r=o=null))}null==t&&(t=100);var u=function(){r=this,o=arguments,s=Date.now();var u=n&&!i;return i||(i=setTimeout(l,t)),u&&(a=e.apply(r,o),r=o=null),a};return u.clear=function(){i&&(clearTimeout(i),i=null)},u.flush=function(){i&&(a=e.apply(r,o),r=o=null,clearTimeout(i),i=null)},u}},function(e,t,n){"use strict";var i=n(13),o=n(52),r=n(0),s=Object(r.a)(i.a,o.a,o.b,!1,null,null,null);t.a=s.exports},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return o});var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{on:{mousedown:e.onBtnClick}},[n("a",{class:"vw-btn-"+e.module.title,domProps:{innerHTML:e._s(e.module.icon)}}),n("div",{directives:[{name:"show",rawName:"v-show",value:e.showDashboard,expression:"showDashboard"}],ref:"dashboard",staticClass:"dashboard"},[e.module.render?e._m(0):e._e()],1)])},o=[function(){var e=this.$createElement;return(this._self._c||e)(this.module,{ref:"moduleDashboard",tag:"component",attrs:{uid:this.uid,options:this.options},on:{exec:this.exec}})}]},function(e,t){e.exports={title:"bold",action:["bold"],description:"Bold",icon:''}},function(e,t){e.exports={title:"italic",description:"Italic",action:["italic"],icon:''}},function(e,t){e.exports={title:"underline",action:["underline"],description:"Underline",icon:''}},function(e,t){e.exports={title:"justifyLeft",action:["justifyLeft"],description:"Justify Left",icon:''}},function(e,t){e.exports={title:"justifyCenter",action:["justifyCenter"],description:"Center",icon:''}},function(e,t){e.exports={title:"justifyRight",action:["justifyRight"],description:"Justify Right",icon:''}},function(e,t,n){"use strict";var i=n(14),o=n(60),r=n(0),s=Object(r.a)(i.a,o.a,o.b,!1,null,null,null);t.a=s.exports},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return o});var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("button",{attrs:{type:"button"},on:{click:e.insertHeading}},[e._v("H1")]),e._v(" "),n("button",{attrs:{type:"button"},on:{click:e.insertHeading}},[e._v("H2")]),e._v(" "),n("button",{attrs:{type:"button"},on:{click:e.insertHeading}},[e._v("H3")]),e._v(" "),n("button",{attrs:{type:"button"},on:{click:e.insertHeading}},[e._v("H4")]),e._v(" "),n("button",{attrs:{type:"button"},on:{click:e.insertHeading}},[e._v("H5")]),e._v(" "),n("button",{attrs:{type:"button"},on:{click:e.insertHeading}},[e._v("H6")])])},o=[]},function(e,t,n){"use strict";var i=n(15),o=n(62),r=n(0),s=Object(r.a)(i.a,o.a,o.b,!1,null,null,null);t.a=s.exports},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return o});var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("form",{on:{submit:function(t){t.preventDefault(),e.insertLink(t)}}},[n("label",[e._v("\n URL\n "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.url,expression:"url"}],ref:"url",staticStyle:{width:"40%"},attrs:{type:"text"},domProps:{value:e.url},on:{input:function(t){t.target.composing||(e.url=t.target.value)}}})]),e._v(" "),n("label",[e._v("\n Link Title\n "),n("input",{directives:[{name:"model",rawName:"v-model",value:e.title,expression:"title"}],staticStyle:{width:"40%"},attrs:{type:"text"},domProps:{value:e.title},on:{input:function(t){t.target.composing||(e.title=t.target.value)}}})]),e._v(" "),n("button",{attrs:{type:"submit"}},[e._v("Insert")])])},o=[]},function(e,t){e.exports={title:"code",icon:'',description:"Code",action:["formatBlock","pre"]}},function(e,t){e.exports={title:"orderedList",action:["insertOrderedList"],description:"Ordered List (1, 2, 3)",icon:''}},function(e,t){e.exports={title:"unorderedList",action:["insertUnorderedList"],description:"Bullet List",icon:''}},function(e,t,n){"use strict";var i=n(16),o=n(71),r=n(0),s=Object(r.a)(i.a,o.a,o.b,!1,null,null,null);t.a=s.exports},function(e,t,n){var i;i=function(){"use strict";var e={getSignedURL:function(e,t){var n={filePath:e.name,contentType:e.type};return new Promise(function(i,o){var r=new FormData,s=new XMLHttpRequest,a="function"==typeof t.signingURL?t.signingURL(e):t.signingURL;s.open("POST",a),s.onload=function(){200==s.status?i(JSON.parse(s.response)):o(s.statusText)},s.onerror=function(e){console.error("Network Error : Could not send request to AWS (Maybe CORS errors)"),o(e)},Object.entries(t.headers||{}).forEach(function(e){var t=e[0],n=e[1];s.setRequestHeader(t,n)}),n=Object.assign(n,t.params||{}),Object.entries(n).forEach(function(e){var t=e[0],n=e[1];r.append(t,n)}),s.send(r)})},sendFile:function(e,t){var n=new FormData;return this.getSignedURL(e,t).then(function(t){var i=t.signature;return Object.keys(i).forEach(function(e){n.append(e,i[e])}),n.append("file",e),new Promise(function(e,i){var o=new XMLHttpRequest;o.open("POST",t.postEndpoint),o.onload=function(){if(201==o.status){var t=(new window.DOMParser).parseFromString(o.response,"text/xml").firstChild.children[0].innerHTML;e({success:!0,message:t})}else{var n=(new window.DOMParser).parseFromString(o.response,"text/xml").firstChild.children[0].innerHTML;i({success:!1,message:n+". Request is marked as resolved when returns as status 201"})}},o.onerror=function(e){var t=(new window.DOMParser).parseFromString(o.response,"text/xml").firstChild.children[1].innerHTML;i({success:!1,message:t})},o.send(n)})}).catch(function(e){return e})}};return{render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{ref:"dropzoneElement",class:{"vue-dropzone dropzone":e.includeStyling},attrs:{id:e.id}})},staticRenderFns:[],props:{id:{type:String,required:!0},options:{type:Object,required:!0},includeStyling:{type:Boolean,default:!0,required:!1},awss3:{type:Object,required:!1,default:null},destroyDropzone:{type:Boolean,default:!0,required:!1}},data:function(){return{isS3:!1,wasQueueAutoProcess:!0}},computed:{dropzoneSettings:function(){var e={thumbnailWidth:200,thumbnailHeight:200};return Object.keys(this.options).forEach(function(t){e[t]=this.options[t]},this),null!==this.awss3&&(e.autoProcessQueue=!1,this.isS3=!0,void 0!==this.options.autoProcessQueue&&(this.wasQueueAutoProcess=this.options.autoProcessQueue)),e}},methods:{manuallyAddFile:function(e,t){e.manuallyAdded=!0,this.dropzone.emit("addedfile",e),t&&this.dropzone.emit("thumbnail",e,t);for(var n=e.previewElement.querySelectorAll("[data-dz-thumbnail]"),i=0;i1?n-1:0),o=1;o=s.length)break;s[r++].apply(this,i)}}return this}},{key:"off",value:function(e,t){if(!this._callbacks||0===arguments.length)return this._callbacks={},this;var n=this._callbacks[e];if(!n)return this;if(1===arguments.length)return delete this._callbacks[e],this;for(var i=0;i=n.length)break;var i=n[t++];if(/(^| )dz-message($| )/.test(i.className)){e=i,i.className="dz-message";break}}e||(e=r.createElement('
'),this.element.appendChild(e));var o=e.getElementsByTagName("span")[0];return o&&(null!=o.textContent?o.textContent=this.options.dictFallbackMessage:null!=o.innerText&&(o.innerText=this.options.dictFallbackMessage)),this.element.appendChild(this.getFallbackForm())},resize:function(e,t,n,i){var o={srcX:0,srcY:0,srcWidth:e.width,srcHeight:e.height},r=e.width/e.height;null==t&&null==n?(t=o.srcWidth,n=o.srcHeight):null==t?t=n*r:null==n&&(n=t/r);var s=(t=Math.min(t,o.srcWidth))/(n=Math.min(n,o.srcHeight));if(o.srcWidth>t||o.srcHeight>n)if("crop"===i)r>s?(o.srcHeight=e.height,o.srcWidth=o.srcHeight*s):(o.srcWidth=e.width,o.srcHeight=o.srcWidth/s);else{if("contain"!==i)throw new Error("Unknown resizeMethod '"+i+"'");r>s?n=t/r:t=n*r}return o.srcX=(e.width-o.srcWidth)/2,o.srcY=(e.height-o.srcHeight)/2,o.trgWidth=t,o.trgHeight=n,o},transformFile:function(e,t){return(this.options.resizeWidth||this.options.resizeHeight)&&e.type.match(/image.*/)?this.resizeImage(e,this.options.resizeWidth,this.options.resizeHeight,this.options.resizeMethod,t):t(e)},previewTemplate:'
\n
\n
\n
\n
\n
\n
\n
\n
\n \n Check\n \n \n \n \n \n
\n
\n \n Error\n \n \n \n \n \n \n \n
\n
',drop:function(e){return this.element.classList.remove("dz-drag-hover")},dragstart:function(e){},dragend:function(e){return this.element.classList.remove("dz-drag-hover")},dragenter:function(e){return this.element.classList.add("dz-drag-hover")},dragover:function(e){return this.element.classList.add("dz-drag-hover")},dragleave:function(e){return this.element.classList.remove("dz-drag-hover")},paste:function(e){},reset:function(){return this.element.classList.remove("dz-started")},addedfile:function(e){var t=this;if(this.element===this.previewsContainer&&this.element.classList.add("dz-started"),this.previewsContainer){e.previewElement=r.createElement(this.options.previewTemplate.trim()),e.previewTemplate=e.previewElement,this.previewsContainer.appendChild(e.previewElement);for(var n=0,i=i=e.previewElement.querySelectorAll("[data-dz-name]");;){if(n>=i.length)break;var o=i[n++];o.textContent=e.name}for(var s=0,a=a=e.previewElement.querySelectorAll("[data-dz-size]");!(s>=a.length);)(o=a[s++]).innerHTML=this.filesize(e.size);this.options.addRemoveLinks&&(e._removeLink=r.createElement(''+this.options.dictRemoveFile+""),e.previewElement.appendChild(e._removeLink));for(var l=function(n){return n.preventDefault(),n.stopPropagation(),e.status===r.UPLOADING?r.confirm(t.options.dictCancelUploadConfirmation,function(){return t.removeFile(e)}):t.options.dictRemoveFileConfirmation?r.confirm(t.options.dictRemoveFileConfirmation,function(){return t.removeFile(e)}):t.removeFile(e)},u=0,c=c=e.previewElement.querySelectorAll("[data-dz-remove]");;){if(u>=c.length)break;c[u++].addEventListener("click",l)}}},removedfile:function(e){return null!=e.previewElement&&null!=e.previewElement.parentNode&&e.previewElement.parentNode.removeChild(e.previewElement),this._updateMaxFilesReachedClass()},thumbnail:function(e,t){if(e.previewElement){e.previewElement.classList.remove("dz-file-preview");for(var n=0,i=i=e.previewElement.querySelectorAll("[data-dz-thumbnail]");;){if(n>=i.length)break;var o=i[n++];o.alt=e.name,o.src=t}return setTimeout(function(){return e.previewElement.classList.add("dz-image-preview")},1)}},error:function(e,t){if(e.previewElement){e.previewElement.classList.add("dz-error"),"String"!=typeof t&&t.error&&(t=t.error);for(var n=0,i=i=e.previewElement.querySelectorAll("[data-dz-errormessage]");;){if(n>=i.length)break;i[n++].textContent=t}}},errormultiple:function(){},processing:function(e){if(e.previewElement&&(e.previewElement.classList.add("dz-processing"),e._removeLink))return e._removeLink.textContent=this.options.dictCancelUpload},processingmultiple:function(){},uploadprogress:function(e,t,n){if(e.previewElement)for(var i=0,o=o=e.previewElement.querySelectorAll("[data-dz-uploadprogress]");;){if(i>=o.length)break;var r=o[i++];"PROGRESS"===r.nodeName?r.value=t:r.style.width=t+"%"}},totaluploadprogress:function(){},sending:function(){},sendingmultiple:function(){},success:function(e){if(e.previewElement)return e.previewElement.classList.add("dz-success")},successmultiple:function(){},canceled:function(e){return this.emit("error",e,"Upload canceled.")},canceledmultiple:function(){},complete:function(e){if(e._removeLink&&(e._removeLink.textContent=this.options.dictRemoveFile),e.previewElement)return e.previewElement.classList.add("dz-complete")},completemultiple:function(){},maxfilesexceeded:function(){},maxfilesreached:function(){},queuecomplete:function(){},addedfiles:function(){}},this.prototype._thumbnailQueue=[],this.prototype._processingThumbnail=!1}},{key:"extend",value:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i=r.length)break;var s=r[o++];for(var a in s){var l=s[a];e[a]=l}}return e}}]),t(r,[{key:"getAcceptedFiles",value:function(){return this.files.filter(function(e){return e.accepted}).map(function(e){return e})}},{key:"getRejectedFiles",value:function(){return this.files.filter(function(e){return!e.accepted}).map(function(e){return e})}},{key:"getFilesWithStatus",value:function(e){return this.files.filter(function(t){return t.status===e}).map(function(e){return e})}},{key:"getQueuedFiles",value:function(){return this.getFilesWithStatus(r.QUEUED)}},{key:"getUploadingFiles",value:function(){return this.getFilesWithStatus(r.UPLOADING)}},{key:"getAddedFiles",value:function(){return this.getFilesWithStatus(r.ADDED)}},{key:"getActiveFiles",value:function(){return this.files.filter(function(e){return e.status===r.UPLOADING||e.status===r.QUEUED}).map(function(e){return e})}},{key:"init",value:function(){var e=this;if("form"===this.element.tagName&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector(".dz-message")&&this.element.appendChild(r.createElement('
'+this.options.dictDefaultMessage+"
")),this.clickableElements.length){!function t(){return e.hiddenFileInput&&e.hiddenFileInput.parentNode.removeChild(e.hiddenFileInput),e.hiddenFileInput=document.createElement("input"),e.hiddenFileInput.setAttribute("type","file"),(null===e.options.maxFiles||e.options.maxFiles>1)&&e.hiddenFileInput.setAttribute("multiple","multiple"),e.hiddenFileInput.className="dz-hidden-input",null!==e.options.acceptedFiles&&e.hiddenFileInput.setAttribute("accept",e.options.acceptedFiles),null!==e.options.capture&&e.hiddenFileInput.setAttribute("capture",e.options.capture),e.hiddenFileInput.style.visibility="hidden",e.hiddenFileInput.style.position="absolute",e.hiddenFileInput.style.top="0",e.hiddenFileInput.style.left="0",e.hiddenFileInput.style.height="0",e.hiddenFileInput.style.width="0",document.querySelector(e.options.hiddenInputContainer).appendChild(e.hiddenFileInput),e.hiddenFileInput.addEventListener("change",function(){var n=e.hiddenFileInput.files;if(n.length)for(var i=0,o=o=n;!(i>=o.length);){var r=o[i++];e.addFile(r)}return e.emit("addedfiles",n),t()})}()}this.URL=null!==window.URL?window.URL:window.webkitURL;for(var t=0,n=n=this.events;;){if(t>=n.length)break;var i=n[t++];this.on(i,this.options[i])}this.on("uploadprogress",function(){return e.updateTotalUploadProgress()}),this.on("removedfile",function(){return e.updateTotalUploadProgress()}),this.on("canceled",function(t){return e.emit("complete",t)}),this.on("complete",function(t){if(0===e.getAddedFiles().length&&0===e.getUploadingFiles().length&&0===e.getQueuedFiles().length)return setTimeout(function(){return e.emit("queuecomplete")},0)});var o=function(e){return e.stopPropagation(),e.preventDefault?e.preventDefault():e.returnValue=!1};return this.listeners=[{element:this.element,events:{dragstart:function(t){return e.emit("dragstart",t)},dragenter:function(t){return o(t),e.emit("dragenter",t)},dragover:function(t){var n=void 0;try{n=t.dataTransfer.effectAllowed}catch(e){}return t.dataTransfer.dropEffect="move"===n||"linkMove"===n?"move":"copy",o(t),e.emit("dragover",t)},dragleave:function(t){return e.emit("dragleave",t)},drop:function(t){return o(t),e.drop(t)},dragend:function(t){return e.emit("dragend",t)}}}],this.clickableElements.forEach(function(t){return e.listeners.push({element:t,events:{click:function(n){return(t!==e.element||n.target===e.element||r.elementInside(n.target,e.element.querySelector(".dz-message")))&&e.hiddenFileInput.click(),!0}}})}),this.enable(),this.options.init.call(this)}},{key:"destroy",value:function(){return this.disable(),this.removeAllFiles(!0),(null!=this.hiddenFileInput?this.hiddenFileInput.parentNode:void 0)&&(this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput),this.hiddenFileInput=null),delete this.element.dropzone,r.instances.splice(r.instances.indexOf(this),1)}},{key:"updateTotalUploadProgress",value:function(){var e=void 0,t=0,n=0;if(this.getActiveFiles().length){for(var i=0,o=o=this.getActiveFiles();;){if(i>=o.length)break;var r=o[i++];t+=r.upload.bytesSent,n+=r.upload.total}e=100*t/n}else e=100;return this.emit("totaluploadprogress",e,n,t)}},{key:"_getParamName",value:function(e){return"function"==typeof this.options.paramName?this.options.paramName(e):this.options.paramName+(this.options.uploadMultiple?"["+e+"]":"")}},{key:"_renameFile",value:function(e){return"function"!=typeof this.options.renameFile?e.name:this.options.renameFile(e)}},{key:"getFallbackForm",value:function(){var e,t=void 0;if(e=this.getExistingFallback())return e;var n='
';this.options.dictFallbackText&&(n+="

"+this.options.dictFallbackText+"

"),n+='
';var i=r.createElement(n);return"FORM"!==this.element.tagName?(t=r.createElement('
')).appendChild(i):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=t?t:i}},{key:"getExistingFallback",value:function(){for(var e=function(e){for(var t=0,n=n=e;;){if(t>=n.length)break;var i=n[t++];if(/(^| )fallback($| )/.test(i.className))return i}},t=["div","form"],n=0;n0){for(var i=["tb","gb","mb","kb","b"],o=0;o=Math.pow(this.options.filesizeBase,4-o)/10){t=e/Math.pow(this.options.filesizeBase,4-o),n=r;break}}t=Math.round(10*t)/10}return""+t+" "+this.options.dictFileSizeUnits[n]}},{key:"_updateMaxFilesReachedClass",value:function(){return null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(this.getAcceptedFiles().length===this.options.maxFiles&&this.emit("maxfilesreached",this.files),this.element.classList.add("dz-max-files-reached")):this.element.classList.remove("dz-max-files-reached")}},{key:"drop",value:function(e){if(e.dataTransfer){this.emit("drop",e);var t=e.dataTransfer.files;if(this.emit("addedfiles",t),t.length){var n=e.dataTransfer.items;n&&n.length&&null!=n[0].webkitGetAsEntry?this._addFilesFromItems(n):this.handleFiles(t)}}}},{key:"paste",value:function(e){if(null!=(void 0!==(t=null!=e?e.clipboardData:void 0)&&null!==t?function(e){return e.items}(t):void 0)){var t;this.emit("paste",e);var n=e.clipboardData.items;return n.length?this._addFilesFromItems(n):void 0}}},{key:"handleFiles",value:function(e){var t=this;return e.map(function(e){return t.addFile(e)})}},{key:"_addFilesFromItems",value:function(e){var t=this;return function(){for(var n=[],i=0,o=o=e;;){if(i>=o.length)break;var r,s=o[i++];null!=s.webkitGetAsEntry&&(r=s.webkitGetAsEntry())?r.isFile?n.push(t.addFile(s.getAsFile())):r.isDirectory?n.push(t._addFilesFromDirectory(r,r.name)):n.push(void 0):null!=s.getAsFile&&(null==s.kind||"file"===s.kind)?n.push(t.addFile(s.getAsFile())):n.push(void 0)}return n}()}},{key:"_addFilesFromDirectory",value:function(e,t){var n=this,i=e.createReader(),o=function(e){return t=console,n="log",i=function(t){return t.log(e)},void 0!==t&&null!==t&&"function"==typeof t[n]?i(t,n):void 0;var t,n,i};return function e(){return i.readEntries(function(i){if(i.length>0){for(var o=0,r=r=i;!(o>=r.length);){var s=r[o++];s.isFile?s.file(function(e){if(!n.options.ignoreHiddenFiles||"."!==e.name.substring(0,1))return e.fullPath=t+"/"+e.name,n.addFile(e)}):s.isDirectory&&n._addFilesFromDirectory(s,t+"/"+s.name)}e()}return null},o)}()}},{key:"accept",value:function(e,t){return e.size>1024*this.options.maxFilesize*1024?t(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(e.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):r.isValidFile(e,this.options.acceptedFiles)?null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(t(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}",this.options.maxFiles)),this.emit("maxfilesexceeded",e)):this.options.accept.call(this,e,t):t(this.options.dictInvalidFileType)}},{key:"addFile",value:function(e){var t=this;return e.upload={uuid:r.uuidv4(),progress:0,total:e.size,bytesSent:0,filename:this._renameFile(e),chunked:this.options.chunking&&(this.options.forceChunking||e.size>this.options.chunkSize),totalChunkCount:Math.ceil(e.size/this.options.chunkSize)},this.files.push(e),e.status=r.ADDED,this.emit("addedfile",e),this._enqueueThumbnail(e),this.accept(e,function(n){return n?(e.accepted=!1,t._errorProcessing([e],n)):(e.accepted=!0,t.options.autoQueue&&t.enqueueFile(e)),t._updateMaxFilesReachedClass()})}},{key:"enqueueFiles",value:function(e){for(var t=0,n=n=e;;){if(t>=n.length)break;var i=n[t++];this.enqueueFile(i)}return null}},{key:"enqueueFile",value:function(e){var t=this;if(e.status!==r.ADDED||!0!==e.accepted)throw new Error("This file can't be queued because it has already been processed or was rejected.");if(e.status=r.QUEUED,this.options.autoProcessQueue)return setTimeout(function(){return t.processQueue()},0)}},{key:"_enqueueThumbnail",value:function(e){var t=this;if(this.options.createImageThumbnails&&e.type.match(/image.*/)&&e.size<=1024*this.options.maxThumbnailFilesize*1024)return this._thumbnailQueue.push(e),setTimeout(function(){return t._processThumbnailQueue()},0)}},{key:"_processThumbnailQueue",value:function(){var e=this;if(!this._processingThumbnail&&0!==this._thumbnailQueue.length){this._processingThumbnail=!0;var t=this._thumbnailQueue.shift();return this.createThumbnail(t,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.thumbnailMethod,!0,function(n){return e.emit("thumbnail",t,n),e._processingThumbnail=!1,e._processThumbnailQueue()})}}},{key:"removeFile",value:function(e){if(e.status===r.UPLOADING&&this.cancelUpload(e),this.files=s(this.files,e),this.emit("removedfile",e),0===this.files.length)return this.emit("reset")}},{key:"removeAllFiles",value:function(e){null==e&&(e=!1);for(var t=0,n=n=this.files.slice();;){if(t>=n.length)break;var i=n[t++];(i.status!==r.UPLOADING||e)&&this.removeFile(i)}return null}},{key:"resizeImage",value:function(e,t,n,i,o){var s=this;return this.createThumbnail(e,t,n,i,!1,function(t,n){if(null===n)return o(e);var i=s.options.resizeMimeType;null==i&&(i=e.type);var a=n.toDataURL(i,s.options.resizeQuality);return"image/jpeg"!==i&&"image/jpg"!==i||(a=u.restore(e.dataURL,a)),o(r.dataURItoBlob(a))})}},{key:"createThumbnail",value:function(e,t,n,i,o,r){var s=this,a=new FileReader;return a.onload=function(){if(e.dataURL=a.result,"image/svg+xml"!==e.type)return s.createThumbnailFromUrl(e,t,n,i,o,r);null!=r&&r(a.result)},a.readAsDataURL(e)}},{key:"createThumbnailFromUrl",value:function(e,t,n,i,o,r,s){var a=this,u=document.createElement("img");return s&&(u.crossOrigin=s),u.onload=function(){var s=function(e){return e(1)};return"undefined"!=typeof EXIF&&null!==EXIF&&o&&(s=function(e){return EXIF.getData(u,function(){return e(EXIF.getTag(this,"Orientation"))})}),s(function(o){e.width=u.width,e.height=u.height;var s=a.options.resize.call(a,e,t,n,i),c=document.createElement("canvas"),d=c.getContext("2d");switch(c.width=s.trgWidth,c.height=s.trgHeight,o>4&&(c.width=s.trgHeight,c.height=s.trgWidth),o){case 2:d.translate(c.width,0),d.scale(-1,1);break;case 3:d.translate(c.width,c.height),d.rotate(Math.PI);break;case 4:d.translate(0,c.height),d.scale(1,-1);break;case 5:d.rotate(.5*Math.PI),d.scale(1,-1);break;case 6:d.rotate(.5*Math.PI),d.translate(0,-c.height);break;case 7:d.rotate(.5*Math.PI),d.translate(c.width,-c.height),d.scale(-1,1);break;case 8:d.rotate(-.5*Math.PI),d.translate(-c.width,0)}l(d,u,null!=s.srcX?s.srcX:0,null!=s.srcY?s.srcY:0,s.srcWidth,s.srcHeight,null!=s.trgX?s.trgX:0,null!=s.trgY?s.trgY:0,s.trgWidth,s.trgHeight);var p=c.toDataURL("image/png");if(null!=r)return r(p,c)})},null!=r&&(u.onerror=r),u.src=e.dataURL}},{key:"processQueue",value:function(){var e=this.options.parallelUploads,t=this.getUploadingFiles().length,n=t;if(!(t>=e)){var i=this.getQueuedFiles();if(i.length>0){if(this.options.uploadMultiple)return this.processFiles(i.slice(0,e-t));for(;n=n.length)break;var i=n[t++];i.processing=!0,i.status=r.UPLOADING,this.emit("processing",i)}return this.options.uploadMultiple&&this.emit("processingmultiple",e),this.uploadFiles(e)}},{key:"_getFilesWithXhr",value:function(e){return this.files.filter(function(t){return t.xhr===e}).map(function(e){return e})}},{key:"cancelUpload",value:function(e){if(e.status===r.UPLOADING){for(var t=this._getFilesWithXhr(e.xhr),n=0,i=i=t;;){if(n>=i.length)break;i[n++].status=r.CANCELED}void 0!==e.xhr&&e.xhr.abort();for(var o=0,s=s=t;;){if(o>=s.length)break;var a=s[o++];this.emit("canceled",a)}this.options.uploadMultiple&&this.emit("canceledmultiple",t)}else e.status!==r.ADDED&&e.status!==r.QUEUED||(e.status=r.CANCELED,this.emit("canceled",e),this.options.uploadMultiple&&this.emit("canceledmultiple",[e]));if(this.options.autoProcessQueue)return this.processQueue()}},{key:"resolveOption",value:function(e){if("function"==typeof e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i=i.upload.totalChunkCount)){0;var s=n*t.options.chunkSize,a=Math.min(s+t.options.chunkSize,i.size),l={name:t._getParamName(0),data:o.webkitSlice?o.webkitSlice(s,a):o.slice(s,a),filename:i.upload.filename,chunkIndex:n};i.upload.chunks[n]={file:i,index:n,dataBlock:l,status:r.UPLOADING,progress:0,retries:0},t._uploadData(e,[l])}};if(i.upload.finishedChunkUpload=function(n){var o=!0;n.status=r.SUCCESS,n.dataBlock=null;for(var a=0;a=s.length)break;s[o++].xhr=i}e[0].upload.chunked&&(e[0].upload.chunks[t[0].chunkIndex].xhr=i);var a=this.resolveOption(this.options.method,e),l=this.resolveOption(this.options.url,e);i.open(a,l,!0),i.timeout=this.resolveOption(this.options.timeout,e),i.withCredentials=!!this.options.withCredentials,i.onload=function(t){n._finishedUploading(e,i,t)},i.onerror=function(){n._handleUploadError(e,i)},(null!=i.upload?i.upload:i).onprogress=function(t){return n._updateFilesUploadProgress(e,i,t)};var u={Accept:"application/json","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"};for(var c in this.options.headers&&r.extend(u,this.options.headers),u){var d=u[c];d&&i.setRequestHeader(c,d)}var p=new FormData;if(this.options.params){var h=this.options.params;for(var f in"function"==typeof h&&(h=h.call(this,e,i,e[0].upload.chunked?this._getChunk(e[0],i):null)),h){var v=h[f];p.append(f,v)}}for(var m=0,g=g=e;;){if(m>=g.length)break;var b=g[m++];this.emit("sending",b,i,p)}this.options.uploadMultiple&&this.emit("sendingmultiple",e,i,p),this._addFormElementData(p);for(var w=0;w=n.length)break;var i=n[t++],o=i.getAttribute("name"),r=i.getAttribute("type");if(r&&(r=r.toLowerCase()),void 0!==o&&null!==o)if("SELECT"===i.tagName&&i.hasAttribute("multiple"))for(var s=0,a=a=i.options;;){if(s>=a.length)break;var l=a[s++];l.selected&&e.append(o,l.value)}else(!r||"checkbox"!==r&&"radio"!==r||i.checked)&&e.append(o,i.value)}}},{key:"_updateFilesUploadProgress",value:function(e,t,n){var i=void 0;if(void 0!==n){if(i=100*n.loaded/n.total,e[0].upload.chunked){var o=e[0],r=this._getChunk(o,t);r.progress=i,r.total=n.total,r.bytesSent=n.loaded;o.upload.progress=0,o.upload.total=0,o.upload.bytesSent=0;for(var s=0;s=l.length)break;var u=l[a++];u.upload.progress=i,u.upload.total=n.total,u.upload.bytesSent=n.loaded}for(var c=0,d=d=e;;){if(c>=d.length)break;var p=d[c++];this.emit("uploadprogress",p,p.upload.progress,p.upload.bytesSent)}}else{var h=!0;i=100;for(var f=0,v=v=e;;){if(f>=v.length)break;var m=v[f++];100===m.upload.progress&&m.upload.bytesSent===m.upload.total||(h=!1),m.upload.progress=i,m.upload.bytesSent=m.upload.total}if(h)return;for(var g=0,b=b=e;;){if(g>=b.length)break;var w=b[g++];this.emit("uploadprogress",w,i,w.upload.bytesSent)}}}},{key:"_finishedUploading",value:function(e,t,n){var i=void 0;if(e[0].status!==r.CANCELED&&4===t.readyState){if("arraybuffer"!==t.responseType&&"blob"!==t.responseType&&(i=t.responseText,t.getResponseHeader("content-type")&&~t.getResponseHeader("content-type").indexOf("application/json")))try{i=JSON.parse(i)}catch(e){n=e,i="Invalid JSON response from server."}this._updateFilesUploadProgress(e),200<=t.status&&t.status<300?e[0].upload.chunked?e[0].upload.finishedChunkUpload(this._getChunk(e[0],t)):this._finished(e,i,n):this._handleUploadError(e,t,i)}}},{key:"_handleUploadError",value:function(e,t,n){if(e[0].status!==r.CANCELED){if(e[0].upload.chunked&&this.options.retryChunks){var i=this._getChunk(e[0],t);if(i.retries++=s.length)break;s[o++];this._errorProcessing(e,n||this.options.dictResponseError.replace("{{statusCode}}",t.status),t)}}}},{key:"submitRequest",value:function(e,t,n){e.send(t)}},{key:"_finished",value:function(e,t,n){for(var i=0,o=o=e;;){if(i>=o.length)break;var s=o[i++];s.status=r.SUCCESS,this.emit("success",s,t,n),this.emit("complete",s)}if(this.options.uploadMultiple&&(this.emit("successmultiple",e,t,n),this.emit("completemultiple",e)),this.options.autoProcessQueue)return this.processQueue()}},{key:"_errorProcessing",value:function(e,t,n){for(var i=0,o=o=e;;){if(i>=o.length)break;var s=o[i++];s.status=r.ERROR,this.emit("error",s,t,n),this.emit("complete",s)}if(this.options.uploadMultiple&&(this.emit("errormultiple",e,t,n),this.emit("completemultiple",e)),this.options.autoProcessQueue)return this.processQueue()}}],[{key:"uuidv4",value:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}}]),r}();r.initClass(),r.version="5.3.0",r.options={},r.optionsForElement=function(e){return e.getAttribute("id")?r.options[a(e.getAttribute("id"))]:void 0},r.instances=[],r.forElement=function(e){if("string"==typeof e&&(e=document.querySelector(e)),null==(null!=e?e.dropzone:void 0))throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");return e.dropzone},r.autoDiscover=!0,r.discover=function(){var e=void 0;if(document.querySelectorAll)e=document.querySelectorAll(".dropzone");else{e=[];var t=function(t){return function(){for(var n=[],i=0,o=o=t;;){if(i>=o.length)break;var r=o[i++];/(^| )dropzone($| )/.test(r.className)?n.push(e.push(r)):n.push(void 0)}return n}()};t(document.getElementsByTagName("div")),t(document.getElementsByTagName("form"))}return function(){for(var t=[],n=0,i=i=e;;){if(n>=i.length)break;var o=i[n++];!1!==r.optionsForElement(o)?t.push(new r(o)):t.push(void 0)}return t}()},r.blacklistedBrowsers=[/opera.*(Macintosh|Windows Phone).*version\/12/i],r.isBrowserSupported=function(){var e=!0;if(window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData&&document.querySelector)if("classList"in document.createElement("a"))for(var t=0,n=n=r.blacklistedBrowsers;;){if(t>=n.length)break;n[t++].test(navigator.userAgent)&&(e=!1)}else e=!1;else e=!1;return e},r.dataURItoBlob=function(e){for(var t=atob(e.split(",")[1]),n=e.split(",")[0].split(":")[1].split(";")[0],i=new ArrayBuffer(t.length),o=new Uint8Array(i),r=0,s=t.length,a=0<=s;a?r<=s:r>=s;a?r++:r--)o[r]=t.charCodeAt(r);return new Blob([i],{type:n})};var s=function(e,t){return e.filter(function(e){return e!==t}).map(function(e){return e})},a=function(e){return e.replace(/[\-_](\w)/g,function(e){return e.charAt(1).toUpperCase()})};r.createElement=function(e){var t=document.createElement("div");return t.innerHTML=e,t.childNodes[0]},r.elementInside=function(e,t){if(e===t)return!0;for(;e=e.parentNode;)if(e===t)return!0;return!1},r.getElement=function(e,t){var n=void 0;if("string"==typeof e?n=document.querySelector(e):null!=e.nodeType&&(n=e),null==n)throw new Error("Invalid `"+t+"` option provided. Please provide a CSS selector or a plain HTML element.");return n},r.getElements=function(e,t){var n=void 0,i=void 0;if(e instanceof Array){i=[];try{for(var o=0,r=r=e;!(o>=r.length);)n=r[o++],i.push(this.getElement(n,t))}catch(e){i=null}}else if("string"==typeof e){i=[];for(var s=0,a=a=document.querySelectorAll(e);!(s>=a.length);)n=a[s++],i.push(n)}else null!=e.nodeType&&(i=[e]);if(null==i||!i.length)throw new Error("Invalid `"+t+"` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");return i},r.confirm=function(e,t,n){return window.confirm(e)?t():null!=n?n():void 0},r.isValidFile=function(e,t){if(!t)return!0;t=t.split(",");for(var n=e.type,i=n.replace(/\/.*$/,""),o=0,r=r=t;;){if(o>=r.length)break;var s=r[o++];if("."===(s=s.trim()).charAt(0)){if(-1!==e.name.toLowerCase().indexOf(s.toLowerCase(),e.name.length-s.length))return!0}else if(/\/\*$/.test(s)){if(i===s.replace(/\/.*$/,""))return!0}else if(n===s)return!0}return!1},"undefined"!=typeof jQuery&&null!==jQuery&&(jQuery.fn.dropzone=function(e){return this.each(function(){return new r(this,e)})}),void 0!==e&&null!==e?e.exports=r:window.Dropzone=r,r.ADDED="added",r.QUEUED="queued",r.ACCEPTED=r.QUEUED,r.UPLOADING="uploading",r.PROCESSING=r.UPLOADING,r.CANCELED="canceled",r.ERROR="error",r.SUCCESS="success";var l=function(e,t,n,i,o,r,s,a,l,u){var c=function(e){e.naturalWidth;var t=e.naturalHeight,n=document.createElement("canvas");n.width=1,n.height=t;var i=n.getContext("2d");i.drawImage(e,0,0);for(var o=i.getImageData(1,0,1,t).data,r=0,s=t,a=t;a>r;)0===o[4*(a-1)+3]?s=a:r=a,a=s+r>>1;var l=a/t;return 0===l?1:l}(t);return e.drawImage(t,n,i,o,r,s,a,l,u/c)},u=function(){function e(){i(this,e)}return t(e,null,[{key:"initClass",value:function(){this.KEY_STR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}},{key:"encode64",value:function(e){for(var t="",n=void 0,i=void 0,o="",r=void 0,s=void 0,a=void 0,l="",u=0;r=(n=e[u++])>>2,s=(3&n)<<4|(i=e[u++])>>4,a=(15&i)<<2|(o=e[u++])>>6,l=63&o,isNaN(i)?a=l=64:isNaN(o)&&(l=64),t=t+this.KEY_STR.charAt(r)+this.KEY_STR.charAt(s)+this.KEY_STR.charAt(a)+this.KEY_STR.charAt(l),n=i=o="",r=s=a=l="",ue.length)break}return n}},{key:"decode64",value:function(e){var t=void 0,n=void 0,i="",o=void 0,r=void 0,s="",a=0,l=[];for(/[^A-Za-z0-9\+\/\=]/g.exec(e)&&console.warn("There were invalid base64 characters in the input text.\nValid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\nExpect errors in decoding."),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");t=this.KEY_STR.indexOf(e.charAt(a++))<<2|(o=this.KEY_STR.indexOf(e.charAt(a++)))>>4,n=(15&o)<<4|(r=this.KEY_STR.indexOf(e.charAt(a++)))>>2,i=(3&r)<<6|(s=this.KEY_STR.indexOf(e.charAt(a++))),l.push(t),64!==r&&l.push(n),64!==s&&l.push(i),t=n=i="",o=r=s="",a'}},function(e,t){e.exports={title:"separator",icon:""}},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return o});var i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"editr"},[n("div",{staticClass:"editr--toolbar"},e._l(e.modules,function(t,i){return n("Btn",{key:t.title+i,ref:"btn-"+t.title,refInFor:!0,attrs:{module:t,options:e.mergedOptions,title:t.description||""}})})),n("div",{ref:"content",staticClass:"editr--content",attrs:{contenteditable:"true",tabindex:"1",placeholder:e.placeholder}})])},o=[]}])}); \ No newline at end of file diff --git a/client/style.css b/client/style.css deleted file mode 100644 index 50ee2ad4..00000000 --- a/client/style.css +++ /dev/null @@ -1,108 +0,0 @@ -*{ - margin: 0; - padding: 0; - box-sizing: border-box -} -header{ - height: 100vh; - background: url('https://images.unsplash.com/photo-1516641396056-0ce60a85d49f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80'); - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - background-size: cover; - color: #6C757D; -} - -nav{ - margin-bottom: 0; -} - -.show{ - display: block -} - -.navbar-logo img{ - width: 50px; -} - -.btn-write{ - margin-right: 10px; -} - - .type-search{ - width: 0px; - display: none; -} - -.menu{ - position: absolute; - transition: 1s; - z-index: 2; - left: -250px; - width: 250px; - height: 100vh; - background-color: #F8F9FA ; - margin-top: 0; - padding: 2px 5px -} - -.menu ul li{ - list-style: none; - margin: 5px 5px; - display: flex; - justify-content: space-between; -} - -.menu ul li a{ - - color: #6C757D; -} - -.menu button{ - box-sizing: border-box; - padding: 1px 1px; - height: 20px; - font-size: 10px; -} - -.menu-show{ - left: 0; -} - -article{ - z-index: 0; - width: 100%; - display: flex; - justify-content: space-evenly; - margin-top: 10px; -} - -.col-headline{ - border: 1px solid #6C757D; - border-radius: 10px; - width: 56.33%; - padding: 30px; -} - -.col-article{ - border: 1px solid #6C757D; - border-radius: 10px; - width: 20%; - display: flex; - align-items: center; - flex-direction: column -} - -.article-list{ - margin-top: 30px; -} - -.article-list li{ - list-style: none; - margin: 10px 20px; -} - -.author p{ - margin: 0 10px; -} \ No newline at end of file diff --git a/server/.env b/server/.env index 1a1fbe7a..5fe38efe 100644 --- a/server/.env +++ b/server/.env @@ -1,3 +1,6 @@ PORT=3000 -BASE_URL=mongodb://localhost:27017/miniwpDB -JWT_SECRET=TANGOBUBBLEGUM \ No newline at end of file +BASE_URL=mongodb+srv://admin:admin@cluster0-noup9.gcp.mongodb.net/miniwpDB?retryWrites=true&w=majority +JWT_SECRET=TANGOBUBBLEGUM +CLIENT_ID_GOOGLE=1076346870616-m6m8v27e0drlov6q0ds53v103kgphmcn.apps.googleusercontent.com +CLIENT_SECRET_GOOGLE=fGVH8pTI9iusBQ4f9kYQ6ykw +PASSWORD_USER=hidupsehat \ No newline at end of file diff --git a/server/controllers/article.js b/server/controllers/article.js index 0cb3efc1..0ca2d45a 100644 --- a/server/controllers/article.js +++ b/server/controllers/article.js @@ -1,42 +1,83 @@ const Article = require('../models/article') +const User = require('../models/user') -class ArticleController{ - static findAll(req, res, next){ - Article.find().sort([['createdAt', -1]]) +class ArticleController { + static findAll(req, res, next) { + Article.find().sort([ + ['createdAt', -1] + ]) .then(articles => { res.status(200).json(articles) }) .catch(next) } - static write(req, res, next){ - const { title, author, content } = req.body + static findUserId(req, res, next) { + let Author = null + User.findById(req.decode.id) + .then(user => { + Author = user.name + return Article.find({ + author: req.decode.id + }).sort([ + ['createdAt', -1] + ]) + }) + .then(articles => { + res.status(200).json({ + articles, + Author + }) + }) + .catch(next) + } + + static write(req, res, next) { + const { + title, + author, + content, + tags, + published, + photo + } = req.body Article.create({ - title, author, content - }) - .then(article => { - res.status(201).json(article) - }) - .catch(next) + title, + author, + content, + tags, + published, + photo + }) + .then(article => { + res.status(201).json(article) + }) + .catch(next) } - static update(req, res, next){ - const { title, content } = req.body + static update(req, res, next) { + const { + title, + content + } = req.body Article.findByIdAndUpdate({ - _id : req.params.id - }, { - title, content - }) + _id: req.params.id + }, { + title, + content + }) .then(() => { - res.status(201).json({message : `Update Success`}) + res.status(201).json({ + message: `Update Success` + }) }) .catch(next) } - static remove( req, res, next){ + static remove(req, res, next) { Article.findByIdAndDelete({ - _id : req.params.id - }) + _id: req.params.id + }) .then(() => { res.status(200).json(`Delete Success`) }) diff --git a/server/controllers/user.js b/server/controllers/user.js index 0937ad7a..049b39d3 100644 --- a/server/controllers/user.js +++ b/server/controllers/user.js @@ -1,88 +1,153 @@ const User = require('../models/user') -const { tokenGenerate } = require('../helpers/jwt') -const { comparePassword } = require('../helpers/bcryptjs') +const { + OAuth2Client +} = require('google-auth-library') +const Article = require('../models/article') +const { + tokenGenerate +} = require('../helpers/jwt') +const { + comparePassword +} = require('../helpers/bcryptjs') -class UserController{ +class UserController { - static findOne(req, res, next){ - + static findOne(req, res, next) { + const dataUser = null + const { + email + } = req.body + User.findOne({ + email + }) + .then(user => { + dataUser = user + return Article.find({ + author: user._id + }) + }) + .then(articles => { + res.status(200).json({ + user: dataUser, + articles + }) + }) + .catch(next) } - static register(req, res, next){ - const { name, email, password } = req.body + static register(req, res, next) { + const { + name, + email, + password + } = req.body User.create({ - name, password, email - }) - .then(user => { - res.status(201).json(user) - }) - .catch(next) + name, + password, + email + }) + .then(user => { + res.status(201).json(user) + }) + .catch(next) } - static login(req, res, next){ - const { email, password } = req.body + static login(req, res, next) { + const { + email, + password + } = req.body User.findOne({ - email - }) + email + }) .then(user => { let payload = { - id : user._id, - email : user.email + id: user._id, + email: user.email } - - if(user && comparePassword(password, user.password)){ - let token = tokenGenerate(payload) - res.status(201).json({ - message : `Login Success`, - token - }) + + if (user && comparePassword(password, user.password)) { + let token = tokenGenerate(payload) + res.status(201).json({ + message: `Login Success`, + id: user._id, + token + }) } else { next({ - status : 400, - message : `Email/Password not valid` + status: 400, + message: `Email/Password not valid` }) } }) .catch(err => { next({ - status : 400, - message : `Email/Password not valid` + status: 400, + message: `Email/Password not valid` }) }) } - static signin(req, res, next){ + static signin(req, res, next) { + const client = new OAuth2Client(process.env.CLIENT_ID_GOOGLE); + let payload = null; + client.verifyIdToken({ + idToken: req.body.token, + audience: process.env.CLIENT_ID_GOOGLE + }) + .then(ticket => { + payload = ticket.getPayload() + return User.findOne({ + email: payload.email + }) + }) + .then(user => { + if (user) { + return user + } else { + return User.create({ + name: payload.name, + password: process.env.PASSWORD_USER, + email: payload.email + }) + } + }) + .then(user => { + const token = tokenGenerate({ + id: user._id, + email: user.email + }) + res.status(201).json({ + mesage: `Logged In Success`, + token, + id: user._id + }) + }) + .catch(next) } - static update(req, res, next){ - - } - - static changePassword(req, res, next){ + static changePassword(req, res, next) { let password = req.body.password User.findOne({ - _id : req.params.id - }) - .then(user => { - if(!user) { - next({ - status : 204, - message : `User not found` - }) - } else { - user.password = password - user.save() - } - }) - .catch(next) - - } - - static remove(req, res, next){ + _id: req.params.id + }) + .then(user => { + if (!user) { + next({ + status: 204, + message: `User not found` + }) + } else { + user.password = password + user.save() + } + }) + .catch(next) } + } module.exports = UserController \ No newline at end of file diff --git a/server/helpers/jwt.js b/server/helpers/jwt.js index 38b28f93..b62a71a6 100644 --- a/server/helpers/jwt.js +++ b/server/helpers/jwt.js @@ -1,5 +1,5 @@ const jwt = require('jsonwebtoken') -const JWT_SECRET = `sdjaskdjjsakdsad` //process.env.JWT_SECRET +const JWT_SECRET = process.env.JWT_SECRET module.exports = { tokenGenerate : (payload) => { diff --git a/server/middlewares/authorization.js b/server/middlewares/authorization.js index e69de29b..cec82a68 100644 --- a/server/middlewares/authorization.js +++ b/server/middlewares/authorization.js @@ -0,0 +1,16 @@ +const Article = require('../models/article') + +module.exports = (req, res, next) => { + Article.findById(req.params.id) + .then(article => { + if (article.author == req.decode.id) { + next() + } else { + next({ + status: 403, + message: `you don't have the authority to do this action` + }) + } + }) + .catch(next) +} \ No newline at end of file diff --git a/server/models/article.js b/server/models/article.js index c73e538a..fa5187ce 100644 --- a/server/models/article.js +++ b/server/models/article.js @@ -2,10 +2,22 @@ const mongoose = require('mongoose') const Schema = mongoose.Schema const articleSchema = new Schema({ - title : String, - author : String, - content : String -}, {timestamps : true}) + title: { + type: String, + required: [true, 'Title must be filled'] + }, + content: String, + photo: String, + author: { + type: Schema.Types.ObjectId, + ref: 'User' + }, + tags: [String], + published: Boolean +}, { + timestamps: true, + versionKey: false +}) const Article = mongoose.model('Article', articleSchema) module.exports = Article \ No newline at end of file diff --git a/server/models/user.js b/server/models/user.js index 60edefee..7095cd01 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -1,25 +1,29 @@ const mongoose = require('mongoose') const uniqueValidator = require('mongoose-unique-validator') -const { hashPassword } = require('../helpers/bcryptjs') +const { + hashPassword +} = require('../helpers/bcryptjs') const Schema = mongoose.Schema const userSchema = new Schema({ - name : String, - email : { - type : String, - unique : [true, `Email has been registered`], - validate : { - validator : function(value){ - let re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + name: String, + email: { + type: String, + unique: [true, `Email has been registered`], + validate: { + validator: function (value) { + let re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(value) }, - message :`Email format is not a valid!` + message: `Email format is not a valid!` } }, - password : String + password: String +}, { + timestamps: true }) -userSchema.pre('save', function(next){ +userSchema.pre('save', function (next) { this.password = hashPassword(this.password) next() }) diff --git a/server/package-lock.json b/server/package-lock.json index b8800a49..bed12b98 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -4,6 +4,14 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "requires": { + "event-target-shim": "^5.0.0" + } + }, "accepts": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", @@ -13,11 +21,24 @@ "negotiator": "0.6.2" } }, + "agent-base": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", + "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", + "requires": { + "es6-promisify": "^5.0.0" + } + }, "array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, + "arrify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", + "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==" + }, "async": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", @@ -35,6 +56,11 @@ "is-buffer": "^2.0.2" } }, + "base64-js": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", + "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" + }, "basic-auth": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", @@ -48,6 +74,11 @@ "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", "integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=" }, + "bignumber.js": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz", + "integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ==" + }, "bluebird": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", @@ -168,6 +199,19 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, + "es6-promise": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" + }, + "es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", + "requires": { + "es6-promise": "^4.0.3" + } + }, "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -178,6 +222,11 @@ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" }, + "event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" + }, "express": { "version": "4.17.1", "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", @@ -225,6 +274,16 @@ } } }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "fast-text-encoding": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.0.tgz", + "integrity": "sha512-R9bHCvweUxxwkDwhjav5vxpFvdPGlVngtqmx4pIZfSUhM/Q4NiIUHB456BAf+Q1Nwu3HEZYONtu+Rya+af4jiQ==" + }, "finalhandler": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", @@ -267,6 +326,67 @@ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" }, + "gaxios": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-2.0.1.tgz", + "integrity": "sha512-c1NXovTxkgRJTIgB2FrFmOFg4YIV6N/bAa4f/FZ4jIw13Ql9ya/82x69CswvotJhbV3DiGnlTZwoq2NVXk2Irg==", + "requires": { + "abort-controller": "^3.0.0", + "extend": "^3.0.2", + "https-proxy-agent": "^2.2.1", + "node-fetch": "^2.3.0" + } + }, + "gcp-metadata": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-2.0.4.tgz", + "integrity": "sha512-p1lXhJvcKvJHWfQXhkd4Za1kyXRsGZA0JH7Cjs07W9hrg84d/j5tqQhbGewlSLx9gNyuQUid69uLux48YbggLg==", + "requires": { + "gaxios": "^2.0.1", + "json-bigint": "^0.3.0" + } + }, + "google-auth-library": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-5.2.1.tgz", + "integrity": "sha512-p9vO6UcRIK/zD3PxoMijaUfFYu6tvzaQwvag1K/82O42NBeAnmllyQUgqaBhcAh9FzFAVlN4bQIaO8+prpE7Vg==", + "requires": { + "arrify": "^2.0.0", + "base64-js": "^1.3.0", + "fast-text-encoding": "^1.0.0", + "gaxios": "^2.0.0", + "gcp-metadata": "^2.0.0", + "gtoken": "^4.0.0", + "jws": "^3.1.5", + "lru-cache": "^5.0.0" + } + }, + "google-p12-pem": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-2.0.2.tgz", + "integrity": "sha512-UfnEARfJKI6pbmC1hfFFm+UAcZxeIwTiEcHfqKe/drMsXD/ilnVjF7zgOGpHXyhuvX6jNJK3S8A0hOQjwtFxEw==", + "requires": { + "node-forge": "^0.9.0" + } + }, + "gtoken": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-4.0.0.tgz", + "integrity": "sha512-XaRCfHJxhj06LmnWNBzVTAr85NfAErq0W1oabkdqwbq3uL/QTB1kyvGog361Uu2FMG/8e3115sIy/97Rnd4GjQ==", + "requires": { + "gaxios": "^2.0.0", + "google-p12-pem": "^2.0.0", + "jws": "^3.1.5", + "mime": "^2.2.0" + }, + "dependencies": { + "mime": { + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz", + "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==" + } + } + }, "http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", @@ -279,6 +399,15 @@ "toidentifier": "1.0.0" } }, + "https-proxy-agent": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz", + "integrity": "sha512-c8Ndjc9Bkpfx/vCJueCPy0jlP4ccCCSNDp8xwCZzPjKJUm+B+u9WX2x98Qx4n1PiMNTWo3D7KK5ifNV/yJyRzg==", + "requires": { + "agent-base": "^4.3.0", + "debug": "^3.1.0" + } + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -302,6 +431,14 @@ "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" }, + "json-bigint": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-0.3.0.tgz", + "integrity": "sha1-DM2RLEuCcNBfBW+9E4FLU9OCWx4=", + "requires": { + "bignumber.js": "^7.0.0" + } + }, "jsonwebtoken": { "version": "8.5.1", "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz", @@ -400,6 +537,14 @@ "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=" }, + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "requires": { + "yallist": "^3.0.2" + } + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -532,6 +677,16 @@ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" }, + "node-fetch": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + }, + "node-forge": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.9.0.tgz", + "integrity": "sha512-7ASaDa3pD+lJ3WvXFsxekJQelBKRpne+GOVbLbtHYdd7pFspyeuJHnWfLplGf3SwKGbfs/aYl5V/JCIaHVUKKQ==" + }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -725,6 +880,11 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" } } } diff --git a/server/package.json b/server/package.json index 84d3e543..d3a6164b 100644 --- a/server/package.json +++ b/server/package.json @@ -17,6 +17,7 @@ "cors": "^2.8.5", "dotenv": "^8.1.0", "express": "^4.17.1", + "google-auth-library": "^5.2.1", "jsonwebtoken": "^8.5.1", "mongoose": "^5.7.0", "mongoose-unique-validator": "^2.0.3", diff --git a/server/routes/article.js b/server/routes/article.js index f7c8416a..30b0eeef 100644 --- a/server/routes/article.js +++ b/server/routes/article.js @@ -2,11 +2,13 @@ const express = require('express') const router = express.Router() const articleController = require('../controllers/article') const authenticaton = require('../middlewares/authentication') +const authotization = require('../middlewares/authorization') router.use(authenticaton) router.get('/', articleController.findAll) +router.get('/userId', articleController.findUserId) router.post('/', articleController.write) -router.put('/:id', articleController.update) -router.delete('/:id', articleController.remove) +router.put('/:id', authotization, articleController.update) +router.delete('/:id', authotization, articleController.remove) module.exports = router \ No newline at end of file diff --git a/server/routes/user.js b/server/routes/user.js index a4684588..f4ce8f8d 100644 --- a/server/routes/user.js +++ b/server/routes/user.js @@ -6,8 +6,6 @@ router.get('/:id', userController.findOne) router.post('/', userController.register) router.post('/login', userController.login) router.post('/signin', userController.signin) -router.put('/:id', userController.update) router.patch('/:id', userController.changePassword) -router.delete(':id', userController.remove) module.exports = router \ No newline at end of file From cdaf154fb3527abf494f7a7cb2e9c8ed0ed20438 Mon Sep 17 00:00:00 2001 From: maulanaghozii Date: Mon, 16 Sep 2019 12:38:09 +0700 Subject: [PATCH 08/14] server done --- README.md | 125 ++++++++++++++++++++++++++- client/src/components/article.vue | 3 - client/src/components/login.vue | 2 +- client/src/components/register.vue | 2 +- client/src/components/secondPage.vue | 2 +- 5 files changed, 127 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e955e80c..a9887cf5 100644 --- a/README.md +++ b/README.md @@ -1 +1,124 @@ -# mini-wp \ No newline at end of file +# Hackticle + +# **WHATS MY AGE?** + +``` +Client : +http://winiwp-ghz.maulanaghozi.web.id + +BaseURL / Server : +http://35.187.228.79 +``` + +## **List of User Routes** : + +| HTTP | Routes | Headers | Body | Description | +| --- | ----- | --- | --- | --- | +| POST | /users | none | name,email, password | Register new user | +| POST | /users/login | none | email,password | Login user | +| POST | /users/signin | none | token | Login 3rd API (google) | + +--- + +## **List of Article Routes** + +| HTTP | Routes | Headers | Body | Description | +| --- | ----- | --- | --- | --- | +| GET | /articles/userId | token | none | read all article where author is user id | +| POST | /articles | token | {title, content, tags, published, photo} | Create new Article (authentication) | +| PUT | /articles/:id | token | {title, content, tags, published, photo} | Update article (authentication, authoriation) | +| DELETE | /articles/:id | token | none | Delete image (authentication, authorization) | + +--- + +## **Response** + +1. Routes : /users +- Method : POST +``` +Response : +{ + "data": { + "_id": "5d7eedb4e0824c0c4dxxxxx", + "name": "admin", + "password": "xxxxxxxxxxxxxxxxxxx", + "email": "xxxxx@gmail.com", + "createdAt": "2019-09-16T02:04:36.901Z", + "updatedAt": "2019-09-16T02:04:36.901Z", + "__v": 0 + + } +} +``` + +2. Routes : /users/login +- Method : POST +``` +Response : +{ + "message": "Login Success", + "id": "5d7eedb4e0xxxxxxxxxxxx", + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVkN2VlZGI0ZTA4MjRjMGM0ZGE1ZWFjYiIsImVtYWlsIjoiYWRtaW5AZ21haWwuY29tIiwiaWF0IjoxNTY4NTk5NTkzfQ.Lxxxxxxxxxxxxxxxxxxxxxxx" +} +``` + +3. Routes : /users/signin +- Method : POST +``` +Response : +{ + "message": "Login Success", + "id": "5d7eedb4e0xxxxxxxxxxxx", + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVkN2VlZGI0ZTA4MjRjMGM0ZGE1ZWFjYiIsImVtYWlsIjoiYWRtaW5AZ21haWwuY29tIiwiaWF0IjoxNTY4NTk5NTkzfQ.Lxxxxxxxxxxxxxxxxxxxxxxx" +} +``` + +4. Routes : /articles +- Method : POST +``` +Response : +{ + "tags": [ + "makan", + "minum", + "hacktiv8", + "tidur" + ], + "_id": "5d7f16ffe0824xxxxxxx", + "title": "Siswa kelas 9 berhasil menembus security google", + "author": "5d7eedb4e0824c0c4dxxxxxx", + "content": "kita harus bangga pada siswa kelas 9 ini karena kecerdasannya dia dapat masuk ke dalam security google", + "published": true, + "photo": "https://images.unsplash.com/photo-1498050108023-c5249f4df085?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60", + "createdAt": "2019-09-16T05:00:47.303Z", + "updatedAt": "2019-09-16T05:00:47.303Z" +} +``` + + +4. Routes : /articles/userId +- Method : GET +``` +Response : +{ + "articles": [ + { + "tags": [ + "makan", + "minum", + "hacktiv8", + "tidur" + ], + "_id": "5d7f16ffe0824c0c4xxxxxxx", + "title": "Siswa kelas 9 berhasil menembus security google", + "author": "5d7eedb4e0824c0c4dxxxxx", + "content": "kita harus bangga pada siswa kelas 9 ini karena kecerdasannya dia dapat masuk ke dalam security google", + "published": true, + "photo": "https://images.unsplash.com/photo-1498050108023-c5249f4df085?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60", + "createdAt": "2019-09-16T05:00:47.303Z", + "updatedAt": "2019-09-16T05:00:47.303Z" + }, ........ + ], + "Author": "admin" +} +``` \ No newline at end of file diff --git a/client/src/components/article.vue b/client/src/components/article.vue index 657181ee..25916d19 100644 --- a/client/src/components/article.vue +++ b/client/src/components/article.vue @@ -25,9 +25,6 @@ export default { data: function() { return { - tags: ["makan", "minum", "ngoding", "tidur", "makan bakso"], - imgheadline: `https://images.unsplash.com/photo-1534972195531-d756b9bfa9f2?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60`, - articles: [1, 3, 4, 5] }; }, props: ["passingarticle", "passingauthor"] diff --git a/client/src/components/login.vue b/client/src/components/login.vue index 0042c7b7..a42b6dbc 100644 --- a/client/src/components/login.vue +++ b/client/src/components/login.vue @@ -34,7 +34,7 @@ @@ -57,12 +71,12 @@ article { .card { width: 800px; display: flex; - background-color: #444; justify-content: space-between; margin: 10px 0; } .content { + font-size: 14px; display: flex; flex-wrap: wrap; word-wrap: break-word; diff --git a/client/src/components/firstPage.vue b/client/src/components/firstPage.vue index 062e05b7..5b2ebec5 100644 --- a/client/src/components/firstPage.vue +++ b/client/src/components/firstPage.vue @@ -1,7 +1,7 @@ @@ -22,6 +22,9 @@ export default { }, getLandingPage() { this.$emit("landingPageShow"); + }, + getThirdPage(article) { + this.$emit("ThirdPageShow", article); } }, props: ["getarticle", "getauthor"] diff --git a/client/src/components/secondPage.vue b/client/src/components/secondPage.vue index 7ef22bc2..9b8b7a30 100644 --- a/client/src/components/secondPage.vue +++ b/client/src/components/secondPage.vue @@ -3,6 +3,11 @@ +
+
+ +
+
+ + \ No newline at end of file diff --git a/server/.env b/server/.env index 5fe38efe..fdad2f43 100644 --- a/server/.env +++ b/server/.env @@ -3,4 +3,7 @@ BASE_URL=mongodb+srv://admin:admin@cluster0-noup9.gcp.mongodb.net/miniwpDB?retry JWT_SECRET=TANGOBUBBLEGUM CLIENT_ID_GOOGLE=1076346870616-m6m8v27e0drlov6q0ds53v103kgphmcn.apps.googleusercontent.com CLIENT_SECRET_GOOGLE=fGVH8pTI9iusBQ4f9kYQ6ykw -PASSWORD_USER=hidupsehat \ No newline at end of file +PASSWORD_USER=hidupsehat +GOOGLE_CLOUD_KEYFILE='./hackticle-a7d705f8bafb.json' +GOOGLE_CLOUD_BUCKET=winiwp-ghz.maulanaghozi.web.id +GOOGLE_CLOUD_PROJECT_ID=hackticle \ No newline at end of file diff --git a/server/controllers/article.js b/server/controllers/article.js index 0ca2d45a..cee18f06 100644 --- a/server/controllers/article.js +++ b/server/controllers/article.js @@ -1,5 +1,13 @@ const Article = require('../models/article') const User = require('../models/user') +const { + Storage +} = require('@google-cloud/storage') + +const storage = new Storage({ + projectId: process.env.GOOGLE_CLOUD_PROJECT_ID, + keyFilename: process.env.GOOGLE_CLOUD_KEYFILE +}) class ArticleController { static findAll(req, res, next) { @@ -12,6 +20,14 @@ class ArticleController { .catch(next) } + static findById(req, res, next) { + Article.findById(req.params.id) + .then(user => { + res.status(200).json(user) + }) + .catch(next) + } + static findUserId(req, res, next) { let Author = null User.findById(req.decode.id) @@ -38,16 +54,19 @@ class ArticleController { author, content, tags, - published, - photo + published } = req.body + let featuredImage = null + if (req.file) { + featuredImage = req.file.cloudStoragePublicUrl + } Article.create({ title, author, content, tags, published, - photo + featured_image: featuredImage }) .then(article => { res.status(201).json(article) @@ -75,10 +94,16 @@ class ArticleController { } static remove(req, res, next) { + const { + _id + } = req.params Article.findByIdAndDelete({ - _id: req.params.id + _id }) - .then(() => { + .then(response => { + let filename = response.featured_image.replace(/(https:\/\/storage.googleapis.com\/miniwp_images\/)/, '') + storage.bucket(process.env.GOOGLE_CLOUD_BUCKET) + .file(filename).delete() res.status(200).json(`Delete Success`) }) .catch(next) diff --git a/server/hackticle-a7d705f8bafb.json b/server/hackticle-a7d705f8bafb.json new file mode 100644 index 00000000..ef9cc7b3 --- /dev/null +++ b/server/hackticle-a7d705f8bafb.json @@ -0,0 +1,12 @@ +{ + "type": "service_account", + "project_id": "hackticle", + "private_key_id": "a7d705f8bafb0d0d9f71bb753bca7840d8a60bf4", + "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDorw2PRWmAXEa5\nyq71EqW5nZ1lDV73z2v3Z2siF92LkI6quC1LUFytOp5LKmTy6jt36vgarFZqraA0\nur/M57EYgQzJPmRAqjC2jdp5OhbTa+dBBAUAaZnF6oP6qUy3tY+zTuUWuK1awcyW\nRmZh1CB8n7aNstpHfvETZWCL2Bp039iy4RJ48VvV6Vg4zqV8kpbTjgzvGI5cf1Zc\nxAAUbXDy99zw9ffGeH8PzIDsH+Vj3iupwTqqkQUzeL51YUVPf8WhpNW6YiZV52GD\nsmCT60VWyuxqW0uj7FOjgh8NmMszhPguwm7KjWwgBxZRlnyg9l0olxkhylfCn355\nx4YcAdLLAgMBAAECggEATV/QsYDSeWW1+xhEH6ioxVV9Plo450zpSSbxwC+Rc1SJ\nrIl8PlwlxVEFzFb3pLNxPQo8oJoITocYDBDBsQCmqlBXkSAXNE2jz0DSkpdXecya\n5MrSYvW6tc6rPpJHuZs9gtHMakbVFqX1Q097wjJI70go62u7HCVBQ0Ll3PrqqUwY\nAn8GZyapXYf6h4iYUHuL1b/7tyheYQriWwhMefkE/zVZw1bBnYZSjs+qs2Vx3Ywn\n5oe6BBIMD3C2SuklprVCZ9guVAwN0lnt+G20S+H2/Ek19TM95OR0kO1SLm+WjWRb\nX5Jr1dnd9lUyxHUIc+CAC43n+xn1cgIEs5a4e3h1mQKBgQD/0hxSit4np0IAf33d\n3QuWhpSlMdwWoLwpRc28mTyuqAEmd/uSauEwcFhPerN2ppj27KBRRtGf9LcQYcat\ns8hw6rR7r5szfeyR4P9x6mNmav1ogBddrZw+z/RXqaV0UKcvAzGiouGMlvic1Qif\nYOxvcx/X1qVKXiYK1ol/E50wfwKBgQDo2MrA6iaah9gCY3G+S5LuqkUqznHEz8ys\nuHxcMYgY8mxetxbt/otuF1oM386xNw/VqcMnQEt2wQhCKY28CX3sKoJ4IoxhUYQX\n3OudP9dFAqjxwWVEH8ByXMVFGMXtEgf7wMzv0LlxauyDW6RHRFOzL2kwD42v7EBU\nek+ooez3tQKBgCyQ1OBIUuVDjQr7KtkwvekOLu0MX5QNkln6UBoP8/NVT0X9VvUt\n62b921SVQphj83foxxEBrlkYT5/p+KugC0YojSKS+A2jXUgYk0esFn7sGpNO5UMr\nkHGc1qtC4ZD+z/EvtEDp8TMFxe/EaQki4G2V97EpMohfGG+A6lkZ+KNPAoGAGncx\nrHWwx5WzJqpY7lE2tSvjSrdGVSFtWSBq+iujFXrQeH+E+q4Y+P1sfdQecSQaB6YR\nCXAUY74TCzof4wSNLH+0bqU2oYUbZ37zxN7RwAVKYJgjw3d8b0M+JNlo/cYz5BiI\n8qUdvtdxZIjRBkys2swDv7O03g8TTMbOMROelJUCgYBV36I1CIZtU+NPyHp0z5xE\n80yW4JKaKZ+3mD/AkdWW/UNuBB7IZwCvuRdVI+FQIgquIa2U1cZIxgcdmK9f3/ND\ndhDrYyUjzeQozlfNbBcOEFMMLQHY4J0DJq56WC3cAhIyCz+zQN/GZWVcHZSXyYhV\nerggaqyFBEdSzZR6sEKu4w==\n-----END PRIVATE KEY-----\n", + "client_email": "miniwp-ghz@hackticle.iam.gserviceaccount.com", + "client_id": "106586838594507012127", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://oauth2.googleapis.com/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/miniwp-ghz%40hackticle.iam.gserviceaccount.com" +} diff --git a/server/middlewares/multer.js b/server/middlewares/multer.js new file mode 100644 index 00000000..95d004d7 --- /dev/null +++ b/server/middlewares/multer.js @@ -0,0 +1,77 @@ +'use strict' + +const { + Storage +} = require('@google-cloud/storage') +const path = require('path') + +const GOOGLE_CLOUD_BUCKET = process.env.GOOGLE_CLOUD_BUCKET + +const storage = new Storage({ + projectId: process.env.GOOGLE_CLOUD_PROJECT_ID, + keyFilename: process.env.GOOGLE_CLOUD_KEYFILE +}) +const bucket = storage.bucket(GOOGLE_CLOUD_BUCKET) + +const getPublicUrl = (filename) => { + return `https://storage.googleapis.com/${GOOGLE_CLOUD_BUCKET}/${filename}` +} + +const getGsUri = (filename) => { + return `gs://${GOOGLE_CLOUD_BUCKET}/${filename}` +} + +const sendUploadToGCS = (req, res, next) => { + + if (!req.file) { + return next() + } else { + const gcsname = Date.now() + req.file.originalname + const file = bucket.file(gcsname) + + const stream = file.createWriteStream({ + metadata: { + contentType: req.file.mimetype + } + }) + + stream.on('error', (err) => { + req.file.cloudStorageError = err + next(err) + }) + stream.on('finish', () => { + req.file.cloudStorageObject = gcsname + file.makePublic().then(() => { + + req.file.cloudStoragePublicUrl = getPublicUrl(gcsname) + req.file.cloudStorageGsUri = getGsUri(gcsname) + next() + }) + }) + + stream.end(req.file.buffer) + } +} + +const Multer = require('multer') +const multer = Multer({ + storage: Multer.MemoryStorage, + limits: { + fileSize: 5 * 1024 * 1024 + }, + fileFilter: function (req, file, next) { + if (!file.mimetype.includes("image")) { + next({ + status: 400, + message: 'File is not an images' + }) + } + next(null, true) + } +}) + +module.exports = { + getPublicUrl, + sendUploadToGCS, + multer +} \ No newline at end of file diff --git a/server/models/article.js b/server/models/article.js index fa5187ce..97a7bc1d 100644 --- a/server/models/article.js +++ b/server/models/article.js @@ -7,7 +7,7 @@ const articleSchema = new Schema({ required: [true, 'Title must be filled'] }, content: String, - photo: String, + featured_image: String, author: { type: Schema.Types.ObjectId, ref: 'User' diff --git a/server/package-lock.json b/server/package-lock.json index bed12b98..586e67fa 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -4,6 +4,110 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@google-cloud/common": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@google-cloud/common/-/common-2.2.1.tgz", + "integrity": "sha512-U8hNZZvs67dYQsBRYqZhyPwOEC135KEDzc4z169PF3FqBbkocHINdf410MmfrWg3Xvu82baXuZu0fq2WsHbG1A==", + "requires": { + "@google-cloud/projectify": "^1.0.0", + "@google-cloud/promisify": "^1.0.0", + "arrify": "^2.0.0", + "duplexify": "^3.6.0", + "ent": "^2.2.0", + "extend": "^3.0.2", + "google-auth-library": "^5.0.0", + "retry-request": "^4.0.0", + "teeny-request": "^5.2.1" + } + }, + "@google-cloud/paginator": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@google-cloud/paginator/-/paginator-2.0.1.tgz", + "integrity": "sha512-HZ6UTGY/gHGNriD7OCikYWL/Eu0sTEur2qqse2w6OVsz+57se3nTkqH14JIPxtf0vlEJ8IJN5w3BdZ22pjCB8g==", + "requires": { + "arrify": "^2.0.0", + "extend": "^3.0.2" + } + }, + "@google-cloud/projectify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@google-cloud/projectify/-/projectify-1.0.1.tgz", + "integrity": "sha512-xknDOmsMgOYHksKc1GPbwDLsdej8aRNIA17SlSZgQdyrcC0lx0OGo4VZgYfwoEU1YS8oUxF9Y+6EzDOb0eB7Xg==" + }, + "@google-cloud/promisify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@google-cloud/promisify/-/promisify-1.0.2.tgz", + "integrity": "sha512-7WfV4R/3YV5T30WRZW0lqmvZy9hE2/p9MvpI34WuKa2Wz62mLu5XplGTFEMK6uTbJCLWUxTcZ4J4IyClKucE5g==" + }, + "@google-cloud/storage": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-3.2.1.tgz", + "integrity": "sha512-129EwPGej6bXzY1u5nja2aeMDew6DIHaJn7ZV6nteQ74LQQSNv2jKrqTlyhndBsAwpuwQAxeghPTCoFT/H8Frg==", + "requires": { + "@google-cloud/common": "^2.1.1", + "@google-cloud/paginator": "^2.0.0", + "@google-cloud/promisify": "^1.0.0", + "arrify": "^2.0.0", + "compressible": "^2.0.12", + "concat-stream": "^2.0.0", + "date-and-time": "^0.9.0", + "duplexify": "^3.5.0", + "extend": "^3.0.2", + "gaxios": "^2.0.1", + "gcs-resumable-upload": "^2.0.0", + "hash-stream-validation": "^0.2.1", + "mime": "^2.2.0", + "mime-types": "^2.0.8", + "onetime": "^5.1.0", + "p-limit": "^2.2.0", + "pumpify": "^2.0.0", + "snakeize": "^0.1.0", + "stream-events": "^1.0.1", + "through2": "^3.0.0", + "xdg-basedir": "^4.0.0" + }, + "dependencies": { + "concat-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.0.2", + "typedarray": "^0.0.6" + } + }, + "mime": { + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz", + "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==" + }, + "readable-stream": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", + "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "safe-buffer": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" + }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "requires": { + "safe-buffer": "~5.2.0" + } + } + } + }, "abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -29,6 +133,11 @@ "es6-promisify": "^5.0.0" } }, + "append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY=" + }, "array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", @@ -121,11 +230,86 @@ "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=" }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, + "busboy": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz", + "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=", + "requires": { + "dicer": "0.2.5", + "readable-stream": "1.1.x" + } + }, "bytes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" }, + "compressible": { + "version": "2.0.17", + "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.17.tgz", + "integrity": "sha512-BGHeLCK1GV7j1bSmQQAi26X+GgWcTjLr/0tzSvMCl3LH1w1IJ4PFSPoV5316b30cneTziC+B1a+3OjoSUcQYmw==", + "requires": { + "mime-db": ">= 1.40.0 < 2" + } + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "configstore": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/configstore/-/configstore-5.0.0.tgz", + "integrity": "sha512-eE/hvMs7qw7DlcB5JPRnthmrITuHMmACUJAp89v6PT6iOqzoLS7HRWhBtuHMlhNHo2AhUSA/3Dh1bKNJHcublQ==", + "requires": { + "dot-prop": "^5.1.0", + "graceful-fs": "^4.1.2", + "make-dir": "^3.0.0", + "unique-string": "^2.0.0", + "write-file-atomic": "^3.0.0", + "xdg-basedir": "^4.0.0" + } + }, "content-disposition": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", @@ -149,6 +333,11 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, "cors": { "version": "2.8.5", "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", @@ -158,6 +347,16 @@ "vary": "^1" } }, + "crypto-random-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", + "integrity": "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==" + }, + "date-and-time": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/date-and-time/-/date-and-time-0.9.0.tgz", + "integrity": "sha512-4JybB6PbR+EebpFx/KyR5Ybl+TcdXMLIJkyYsCx3P4M4CWGMuDyFF19yh6TyasMAIF5lrsgIxiSHBXh2FFc7Fg==" + }, "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", @@ -176,11 +375,68 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "dicer": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz", + "integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=", + "requires": { + "readable-stream": "1.1.x", + "streamsearch": "0.1.2" + } + }, + "dot-prop": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.1.0.tgz", + "integrity": "sha512-n1oC6NBF+KM9oVXtjmen4Yo7HyAVWV2UUl50dCYJdw2924K6dX9bf9TTTWaKtYlRn0FEtxG27KS80ayVLixxJA==", + "requires": { + "is-obj": "^2.0.0" + } + }, "dotenv": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.1.0.tgz", "integrity": "sha512-GUE3gqcDCaMltj2++g6bRQ5rBJWtkWTmqmD0fo1RnnMuUqHNCt2oTPeDnS9n6fKYvlhn7AeBkb38lymBtWBQdA==" }, + "duplexify": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", + "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==", + "requires": { + "end-of-stream": "^1.0.0", + "inherits": "^2.0.1", + "readable-stream": "^2.0.0", + "stream-shift": "^1.0.0" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, "ecdsa-sig-formatter": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", @@ -199,6 +455,19 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, + "end-of-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "requires": { + "once": "^1.4.0" + } + }, + "ent": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", + "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=" + }, "es6-promise": { "version": "4.2.8", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", @@ -346,6 +615,19 @@ "json-bigint": "^0.3.0" } }, + "gcs-resumable-upload": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/gcs-resumable-upload/-/gcs-resumable-upload-2.2.5.tgz", + "integrity": "sha512-r98Hnxza8oYT21MzpziAB2thz3AURGz54+osWtczxGNxH7Fodb0HVUEtfqTwBS5vcf9RnKwR7c0EMaI8R39feg==", + "requires": { + "abort-controller": "^3.0.0", + "configstore": "^5.0.0", + "gaxios": "^2.0.0", + "google-auth-library": "^5.0.0", + "pumpify": "^2.0.0", + "stream-events": "^1.0.4" + } + }, "google-auth-library": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-5.2.1.tgz", @@ -369,6 +651,11 @@ "node-forge": "^0.9.0" } }, + "graceful-fs": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz", + "integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==" + }, "gtoken": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-4.0.0.tgz", @@ -387,6 +674,52 @@ } } }, + "hash-stream-validation": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/hash-stream-validation/-/hash-stream-validation-0.2.1.tgz", + "integrity": "sha1-7Mm5l7IYvluzEphii7gHhptz3NE=", + "requires": { + "through2": "^2.0.0" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "requires": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + } + } + }, "http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", @@ -399,6 +732,15 @@ "toidentifier": "1.0.0" } }, + "http-proxy-agent": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz", + "integrity": "sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==", + "requires": { + "agent-base": "4", + "debug": "3.1.0" + } + }, "https-proxy-agent": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz", @@ -416,6 +758,11 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=" + }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", @@ -431,6 +778,21 @@ "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" }, + "is-obj": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", + "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==" + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, "json-bigint": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-0.3.0.tgz", @@ -545,6 +907,21 @@ "yallist": "^3.0.2" } }, + "make-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.0.0.tgz", + "integrity": "sha512-grNJDhb8b1Jm1qeqW5R/O63wUo4UXo2v2HMic6YT9i/HBlF93S8jkMgH7yugvY9ABDShH4VZMn8I+U8+fCNegw==", + "requires": { + "semver": "^6.0.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + } + } + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -578,6 +955,24 @@ "mime-db": "1.40.0" } }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, "mongodb": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.3.2.tgz", @@ -672,6 +1067,21 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "multer": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.2.tgz", + "integrity": "sha512-xY8pX7V+ybyUpbYMxtjM9KAiD9ixtg5/JkeKUTD6xilfDv0vzzOFcCp4Ljb1UU3tSOM3VTZtKo63OmzOrGi3Cg==", + "requires": { + "append-field": "^1.0.0", + "busboy": "^0.2.11", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.1", + "object-assign": "^4.1.1", + "on-finished": "^2.3.0", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + } + }, "negotiator": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", @@ -705,6 +1115,35 @@ "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==" }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", + "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "p-limit": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "requires": { + "p-try": "^2.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -715,6 +1154,11 @@ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, "proxy-addr": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", @@ -724,6 +1168,61 @@ "ipaddr.js": "1.9.0" } }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "pumpify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-2.0.0.tgz", + "integrity": "sha512-ieN9HmpFPt4J4U4qnjN4BxrnqpPPXJyp3qFErxfwBtFOec6ewpIHdS2eu3TkmGW6S+RzFGEOGpm5ih/X/onRPQ==", + "requires": { + "duplexify": "^4.1.1", + "inherits": "^2.0.3", + "pump": "^3.0.0" + }, + "dependencies": { + "duplexify": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.1.tgz", + "integrity": "sha512-DY3xVEmVHTv1wSzKNbwoU6nVjzI369Y6sPoqfYr0/xlx3IdX2n94xIszTcjPO8W8ZIv0Wb0PXNcjuZyT4wiICA==", + "requires": { + "end-of-stream": "^1.4.1", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1", + "stream-shift": "^1.0.0" + } + }, + "readable-stream": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", + "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "safe-buffer": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" + }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "requires": { + "safe-buffer": "~5.2.0" + } + } + } + }, "qs": { "version": "6.7.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", @@ -745,6 +1244,17 @@ "unpipe": "1.0.0" } }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, "regexp-clone": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz", @@ -764,6 +1274,30 @@ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" }, + "retry-request": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/retry-request/-/retry-request-4.1.1.tgz", + "integrity": "sha512-BINDzVtLI2BDukjWmjAIRZ0oglnCAkpP2vQjM3jdLhmT62h0xnQgciPwBRDAvHqpkPT2Wo1XuUyLyn6nbGrZQQ==", + "requires": { + "debug": "^4.1.1", + "through2": "^3.0.1" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -842,16 +1376,99 @@ "resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz", "integrity": "sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g==" }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, "sliced": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" }, + "snakeize": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/snakeize/-/snakeize-0.1.0.tgz", + "integrity": "sha1-EMCI2LWOsHazIpu1oE4jLOEmQi0=" + }, "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" }, + "stream-events": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/stream-events/-/stream-events-1.0.5.tgz", + "integrity": "sha512-E1GUzBSgvct8Jsb3v2X15pjzN1tYebtbLaMg+eBOUOAxgbLoSbT2NS91ckc5lJD1KfLjId+jXJRgo0qnV5Nerg==", + "requires": { + "stubs": "^3.0.0" + } + }, + "stream-shift": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", + "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=" + }, + "streamsearch": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", + "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + }, + "stubs": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/stubs/-/stubs-3.0.0.tgz", + "integrity": "sha1-6NK6H6nJBXAwPAMLaQD31fiavls=" + }, + "teeny-request": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-5.2.1.tgz", + "integrity": "sha512-gCVm5EV3z0p/yZOKyeBOFOpSXuxdIs3foeWDWb/foKMBejK18w40L0k0UMd/ZrGkOH+gxodjqpL8KK6x3haYCQ==", + "requires": { + "http-proxy-agent": "^2.1.0", + "https-proxy-agent": "^2.2.1", + "node-fetch": "^2.2.0", + "stream-events": "^1.0.5", + "uuid": "^3.3.2" + } + }, + "through2": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-3.0.1.tgz", + "integrity": "sha512-M96dvTalPT3YbYLaKaCuwu+j06D/8Jfib0o/PxbVt6Amhv3dUAtW6rTV1jPgJSBG83I/e04Y6xkVdVhSRhi0ww==", + "requires": { + "readable-stream": "2 || 3" + }, + "dependencies": { + "readable-stream": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", + "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "safe-buffer": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" + }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "requires": { + "safe-buffer": "~5.2.0" + } + } + } + }, "toidentifier": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", @@ -866,21 +1483,78 @@ "mime-types": "~2.1.24" } }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, + "typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "requires": { + "is-typedarray": "^1.0.0" + } + }, + "unique-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz", + "integrity": "sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==", + "requires": { + "crypto-random-string": "^2.0.0" + } + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" }, + "uuid": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", + "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==" + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "write-file-atomic": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.0.tgz", + "integrity": "sha512-EIgkf60l2oWsffja2Sf2AL384dx328c0B+cIYPTQq5q2rOYuDV00/iPFBOUiDKKwKMOhkymH8AidPaRvzfxY+Q==", + "requires": { + "imurmurhash": "^0.1.4", + "is-typedarray": "^1.0.0", + "signal-exit": "^3.0.2", + "typedarray-to-buffer": "^3.1.5" + } + }, + "xdg-basedir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", + "integrity": "sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==" + }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" + }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", diff --git a/server/package.json b/server/package.json index d3a6164b..9bc0b75c 100644 --- a/server/package.json +++ b/server/package.json @@ -12,6 +12,7 @@ "author": "", "license": "ISC", "dependencies": { + "@google-cloud/storage": "^3.2.1", "axios": "^0.19.0", "bcryptjs": "^2.4.3", "cors": "^2.8.5", @@ -21,6 +22,7 @@ "jsonwebtoken": "^8.5.1", "mongoose": "^5.7.0", "mongoose-unique-validator": "^2.0.3", - "morgan": "^1.9.1" + "morgan": "^1.9.1", + "multer": "^1.4.2" } } diff --git a/server/routes/article.js b/server/routes/article.js index 30b0eeef..1e838876 100644 --- a/server/routes/article.js +++ b/server/routes/article.js @@ -3,11 +3,16 @@ const router = express.Router() const articleController = require('../controllers/article') const authenticaton = require('../middlewares/authentication') const authotization = require('../middlewares/authorization') +const { + multer, + sendUploadToGCS +} = require('../middlewares/multer') router.use(authenticaton) router.get('/', articleController.findAll) router.get('/userId', articleController.findUserId) -router.post('/', articleController.write) +router.get('/:id', articleController.findById) +router.post('/', multer.single('image'), sendUploadToGCS, articleController.write) router.put('/:id', authotization, articleController.update) router.delete('/:id', authotization, articleController.remove) From e68e518f5ce10e4f81943dd83ad3d86dfda8e1fb Mon Sep 17 00:00:00 2001 From: maulanaghozii Date: Tue, 17 Sep 2019 09:10:48 +0700 Subject: [PATCH 13/14] debug tags fix --- client/src/App.vue | 1 + client/src/components/article.vue | 4 +++- client/src/components/login.vue | 1 + client/src/components/register.vue | 2 ++ client/src/components/secondPage.vue | 6 +++--- server/controllers/article.js | 3 ++- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/client/src/App.vue b/client/src/App.vue index 198aa13a..ca7d608a 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -32,6 +32,7 @@ import SecondPage from "./components/secondPage"; import ThirdPage from "./components/thirdPage"; import Axios from "axios"; const baseUrl = `http://35.187.228.79`; +// const baseUrl = `http://localhost:3000`; export default { data: function() { return { diff --git a/client/src/components/article.vue b/client/src/components/article.vue index aa6fdbbb..47ed1c40 100644 --- a/client/src/components/article.vue +++ b/client/src/components/article.vue @@ -33,7 +33,9 @@