Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snyk] Upgrade axios from 0.19.0 to 0.19.1 #9

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c2bdbd2
github patch
paulosullivan22 Jul 11, 2019
b441d26
thanks montasar
Cule219 Jul 11, 2019
41da8c5
added favicon
paulosullivan22 Jul 11, 2019
acadbf3
checking master
Cule219 Jul 12, 2019
27958f4
profile recent comments added-not styled
Cule219 Jul 12, 2019
fec8d0b
a
Cule219 Jul 12, 2019
f1748a8
added about page and further DB seeding
paulosullivan22 Jul 12, 2019
033a2c7
add about page and further DB seeding
paulosullivan22 Jul 12, 2019
5a2c58f
DB disconnect after seed
paulosullivan22 Jul 12, 2019
d27ab05
reverted changes
paulosullivan22 Jul 12, 2019
cedf1f6
push for restore
Cule219 Jul 12, 2019
bfe4db1
homepage addition
paulosullivan22 Jul 12, 2019
ad7cdc5
Added about page
paulosullivan22 Jul 12, 2019
0229d1c
commit before change to master
Cule219 Jul 12, 2019
d8d8f0c
Merge branch 'master' of https://github.com/Cule219/project2
paulosullivan22 Jul 12, 2019
3e6bbf9
change
paulosullivan22 Jul 12, 2019
677d2b0
updating social strategies
paulosullivan22 Jul 12, 2019
c27d3e4
first article img error resolved
paulosullivan22 Jul 12, 2019
7a7e392
removed comments from profile
paulosullivan22 Jul 12, 2019
8b302cf
resolved first image not appearing
paulosullivan22 Jul 12, 2019
5d8ac53
revert
paulosullivan22 Jul 12, 2019
e9cb8ce
reverting revert
paulosullivan22 Jul 12, 2019
71caa51
fixing frontpage bug
paulosullivan22 Jul 12, 2019
a68c919
Merge branch 'master' of https://github.com/Cule219/project2
Cule219 Jul 12, 2019
39259c5
praise be to hesus
Cule219 Jul 12, 2019
a940863
praise be to hesus
Cule219 Jul 12, 2019
f6d208c
pull
Cule219 Jul 12, 2019
8933139
added some changes
Cule219 Jul 12, 2019
e883a93
work
Cule219 Jul 12, 2019
51cbf76
commit
Cule219 Jul 12, 2019
7d3c51a
fix
Cule219 Jul 12, 2019
67b8d43
build out source seed file
paulosullivan22 Jul 12, 2019
f3647d6
build out seed.js file
paulosullivan22 Jul 12, 2019
5a95306
fixed usa-today logo
paulosullivan22 Jul 12, 2019
fde08cb
fix company logos
paulosullivan22 Jul 12, 2019
27211a6
last commit
Cule219 Jul 12, 2019
ed33e0d
Lana is the greatest
Cule219 Jul 12, 2019
079ac34
Merge branch 'master' of https://github.com/Cule219/project2
Cule219 Jul 12, 2019
4ba758d
Update article.hbs
Cule219 Jul 12, 2019
c2a6704
fix
Cule219 Jul 12, 2019
e12890c
fix
Cule219 Jul 12, 2019
4305cb1
fixed bunch of issues - hopefully correctly
Cule219 Jul 12, 2019
3ac5d3c
commit before merge
Cule219 Jul 12, 2019
de94cb5
fixed some buggs
Cule219 Jul 12, 2019
0bd1854
bug fix
Cule219 Jul 12, 2019
72a23a0
no user bug fix
Cule219 Jul 13, 2019
4c6cd6e
no-user like shown bug fix
Cule219 Jul 13, 2019
5b942b3
check added for brick avoidance
Cule219 Jul 13, 2019
bbf4dc7
fix: upgrade axios from 0.19.0 to 0.19.1
snyk-bot Feb 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions app.js
Expand Up @@ -12,10 +12,9 @@ const path = require('path');
const session = require("express-session");
const MongoStore = require('connect-mongo')(session);
const flash = require("connect-flash");
const axios = require('axios');

mongoose
.connect(process.env.MONGODB_URI || 'mongodb://localhost/project2', {useNewUrlParser: true})
.connect(process.env.MONGO_URI || 'mongodb://localhost/project2', {useNewUrlParser: true})
.then(x => {
console.log(`Connected to Mongo! Database name: "${x.connections[0].name}"`)
})
Expand Down Expand Up @@ -69,21 +68,18 @@ hbs.registerHelper('ifUndefined', (value, options) => {
}
});


// default value for title local
app.locals.title = 'Express - Generated with IronGenerator';


// Enable authentication using session + passport
app.use(session({
secret: 'irongenerator',
secret: process.env.SESSION_SECRET,
resave: true,
saveUninitialized: true,
store: new MongoStore( { mongooseConnection: mongoose.connection })
}))
app.use(flash());
require('./passport')(app);


app.use('/', require('./routes/index'));
app.use('/', require('./routes/homepages'));
Expand Down
88 changes: 78 additions & 10 deletions bin/seeds.js
Expand Up @@ -57,7 +57,7 @@ let sources = [
category: "general",
language: "en",
country: "gb",
reputation: 4.3,
reputation: 231,
comments: [],
profileImg: `https://liquidcinemavr.com/wp-content/uploads/2019/03/bbc-logo.jpg`,
politicalBias: "The BBC has historically been a centre-right organisation. It's a publically funded, urban organisation with a higher proportion of young people and ethnic minorities. Therefore it tends to hold a liberal bias and, whilst it aligns with the Liberal Party ideals, it also closely allies with the Tories. Writers can often flex their own political opinions and agendas so it's best to be aware.",
Expand All @@ -76,7 +76,7 @@ let sources = [
category: "general",
language: "en",
country: "us",
reputation: 4.2,
reputation: 97,
comments: [],
profileImg: `https://s.abcnews.com/assets/beta/assets/abcn_images/abcnews_pearl_stacked.png`,
politicalBias: "ABC is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, ABC holds a centre left swing with a left leaning and liberal view on many convtroversial topics. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.",
Expand All @@ -93,7 +93,7 @@ let sources = [
category: "business",
language: "en",
country: "us",
reputation: 4.1,
reputation: 211,
comments: [],
profileImg: `https://amp.businessinsider.com/images/597a0306b50ab126008b4b46-750-342.png`,
politicalBias: 'Business Insider is a privately held corporation and, as such, is more susceptible to the political leanings of it\'s leaders. Therefore readers should be aware that the company owners, Brian Anthony and Chris Gunning, are staunchly left-wing and liberal thinkers. This can be conveyed through the leanings of the content that is present in both the print and online editions of Business Insider.',
Expand All @@ -110,7 +110,7 @@ let sources = [
category: "general",
language: "en",
country: "us",
reputation: 4.2,
reputation: 56,
comments: [],
profileImg: `https://www.nlgja.org/wp-content/uploads/2018/01/Reuters-logo-square-2017.png`,
politicalBias: "Reuters is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, Reuters holds a centre political stance with a left leaning and liberal view on many convtroversial topics. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.",
Expand All @@ -127,7 +127,7 @@ let sources = [
category: "general",
language: "en",
country: "us",
reputation: 4.2,
reputation: 52,
comments: [],
profileImg: `https://upload.wikimedia.org/wikipedia/commons/b/b1/CNN.svg`,
politicalBias: "CNN is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.",
Expand All @@ -138,20 +138,84 @@ let sources = [
{
id: "cnbc",
name: "CNBC",
description: "CNBC, the Cable News Network, is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. CNBC is owned by NBC Universal Broadcast which is in turn owned by Comcast.",
url: "www.cnn.com",
description: "CNBC, the Cable News Network, is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. CNBC is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel quam ac odio auctor laoreet sit amet in orci. Duis accumsan sed elit sed dictum. Curabitur convallis semper sapien nec iaculis. ",
url: "www.cnbc.com",
category: "general",
language: "en",
country: "us",
reputation: 4.2,
reputation: 112,
comments: [],
profileImg: `https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/CNBC_logo.svg/701px-CNBC_logo.svg.png`,
politicalBias: "CNN is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.",
fundingSources: [
'Advertising Revenue: $89 million - Source: CNN Income Report 2018',
'Cable Company Subscriptions: $75 million - Source: CNN Income Report 2018'
]},

{
id: "fox-news",
name: "Fox News",
description: "Fox News is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. Fox News is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel quam ac odio auctor laoreet sit amet in orci. Duis accumsan sed elit sed dictum. Curabitur convallis semper sapien nec iaculis. ",
url: "www.fox-news.com",
category: "general",
language: "en",
country: "us",
reputation: 174,
comments: [],
profileImg: `https://upload.wikimedia.org/wikipedia/commons/6/67/Fox_News_Channel_logo.svg`,
politicalBias: "Fox News is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, Fox News holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.",
fundingSources: [
'Advertising Revenue: $89 million - Source: Fox News Income Report 2018',
'Cable Company Subscriptions: $75 million - Source: Fox News Income Report 2018'
]},
{
id: "usa-today",
name: "USA Today",
description: "USA Today is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. USA Today is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel quam ac odio auctor laoreet sit amet in orci. Duis accumsan sed elit sed dictum. Curabitur convallis semper sapien nec iaculis. ",
url: "www.usatoday.com",
category: "general",
language: "en",
country: "us",
reputation: 174,
comments: [],
profileImg: `https://www.american.edu/uploads/standard/large/01_Primary_01_FullColor_USATODAY_Logo_Prm_FullClr_RGB_600copy.png`,
politicalBias: "USA Today is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, USA Today holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.",
fundingSources: [
'Advertising Revenue: $89 million - Source: USA Today Income Report 2018',
'Cable Company Subscriptions: $75 million - Source: USA Today Income Report 2018'
]},
{
id: "nbc-news",
name: "NBC News",
description: "NBC News is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. NBC News is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel quam ac odio auctor laoreet sit amet in orci. Duis accumsan sed elit sed dictum. Curabitur convallis semper sapien nec iaculis. ",
url: "www.nbc-news.com",
category: "general",
language: "en",
country: "us",
reputation: 174,
comments: [],
profileImg: `https://i0.wp.com/www.icingsmiles.org/wp-content/uploads/2015/09/NBC-Logo.png?ssl=1`,
politicalBias: "NBC News is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, NBC News holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.",
fundingSources: [
'Advertising Revenue: $89 million - Source: NBC News Income Report 2018',
'Cable Company Subscriptions: $75 million - Source: NBC News Income Report 2018'
]},
{
id: "politico",
name: "Politico",
description: "Politico is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. Politico is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel quam ac odio auctor laoreet sit amet in orci. Duis accumsan sed elit sed dictum. Curabitur convallis semper sapien nec iaculis. ",
url: "www.politico.com",
category: "general",
language: "en",
country: "us",
reputation: 174,
comments: [],
profileImg: `https://pmcvariety.files.wordpress.com/2016/05/politico-logo.jpg?w=913&h=513&crop=1`,
politicalBias: "Politico is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, Politico holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.",
fundingSources: [
'Advertising Revenue: $89 million - Source: Politico Income Report 2018',
'Cable Company Subscriptions: $75 million - Source: Politico Income Report 2018'
]}

];

User.deleteMany()
Expand Down Expand Up @@ -190,6 +254,7 @@ const seedAPI = () => {
.then(data => console.log(data.length)).catch(err=>console.log(err));
})
.then(() => {
console.log('sources successfully added')
// Close properly the connection to Mongoose
// mongoose.disconnect()
})
Expand All @@ -199,7 +264,10 @@ const seedAPI = () => {
});
}

seedAPI();
seedAPI()
setTimeout(() => {
mongoose.disconnect()
}, 5000)

module.exports;

4 changes: 3 additions & 1 deletion bin/www
Expand Up @@ -41,6 +41,8 @@ server.on('error', error => {
}
});

server.listen(process.env.PORT || 'https://opinion-news.herokuapp.com/', () => {
server.listen(process.env.PORT
// || 'https://opinion-news.herokuapp.com/'
, () => {
console.log(`Listening on http://localhost:${process.env.PORT}`);
});
16 changes: 4 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -8,7 +8,7 @@
"dev-windows": "nodemon ./bin/www"
},
"dependencies": {
"axios": "^0.19.0",
"axios": "^0.19.1",
"bcrypt": "^3.0.0",
"body-parser": "^1.18.3",
"connect-ensure-login": "^0.1.1",
Expand Down
41 changes: 20 additions & 21 deletions passport/facebookStrategy.js
Expand Up @@ -2,24 +2,23 @@ const FacebookStrategy = require("passport-facebook").Strategy;
const passport = require('passport');
const User = require('../models/User');

// passport.use(new FacebookStrategy({
// clientID: process.env.FACEBOOK_USER_ID,
// clientSecret: process.env.FACEBOOK_KEY,
// callbackURL: 'https://opinion-news.herokuapp.com/auth/facebook/callback'
// // "http://localhost:3000/auth/facebook/callback"
// },
// function(accessToken, refreshToken, profile, cb) {
// User.findOne({ facebookId: profile.id }).then(user => {
// if (user) return cb(null, user);
// console.log('FB user: ' + user)
// return User.create({
// facebookId: profile.id,
// fullName: profile.displayName
// }).then(newUser => {
// return cb(null, newUser);
// });
// }).catch(err => {
// cb(err);
// });
// }
// ));
passport.use(new FacebookStrategy({
clientID: process.env.FACEBOOK_USER_ID,
clientSecret: process.env.FACEBOOK_KEY,
callbackURL: "http://opinion-news.herokuapp.com/auth/facebook/callback"
},
function(accessToken, refreshToken, profile, cb) {
User.findOne({ facebookId: profile.id }).then(user => {
if (user) return cb(null, user);
console.log('FB user: ' + user)
return User.create({
facebookId: profile.id,
fullName: profile.displayName
}).then(newUser => {
return cb(null, newUser);
});
}).catch(err => {
cb(err);
});
}
));
4 changes: 1 addition & 3 deletions passport/githubStrategy.js
Expand Up @@ -5,13 +5,11 @@ const User = require('../models/User');
passport.use(new GitHubStrategy({
clientID: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
callbackURL: 'https://opinion-news.herokuapp.com/auth/github/callback'
// "http://localhost:3000/auth/github/callback"
callbackURL: "http://opinion-news.herokuapp.com/auth/github/callback"
},
function(accessToken, refreshToken, profile, cb) {
User.findOne({ githubId: profile.id })
.then(user => {
console.log(profile);
if (user) return cb(null, user);
return User.create(
{
Expand Down
22 changes: 1 addition & 21 deletions passport/googleStrategy.js
Expand Up @@ -5,7 +5,7 @@ const User = require('../models/User');
passport.use(new GoogleStrategy({
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: "http://localhost:3000/auth/google/callback"
callbackURL: "http://opinion-news.herokuapp.com/auth/google/callback"//http://localhost:3000
},
function(accessToken, refreshToken, profile, cb) {
User.findOne({ googleId: profile.id })
Expand All @@ -25,23 +25,3 @@ function(accessToken, refreshToken, profile, cb) {
});
}
));

//Google profile examp:

// { id: '112678934251205388903',
// displayName: 'Stefan Culafic',
// name: { familyName: 'Culafic', givenName: 'Stefan' },
// photos:
// [ { value:
// 'https://lh3.googleusercontent.com/-vN2r6OL7IHg/AAAAAAAAAAI/AAAAAAAAHcs/e27OZ_SW810/photo.jpg' } ],
// provider: 'google',
// _raw:
// '{\n "sub": "112678934251205388903",\n "name": "Stefan Culafic",\n "given_name": "Stefan",\n "family_name": "Culafic",\n "picture": "https://lh3.googleusercontent.com/-vN2r6OL7IHg/AAAAAAAAAAI/AAAAAAAAHcs/e27OZ_SW810/photo.jpg",\n "locale": "en"\n}',
// _json:
// { sub: '112678934251205388903',
// name: 'Stefan Culafic',
// given_name: 'Stefan',
// family_name: 'Culafic',
// picture:
// 'https://lh3.googleusercontent.com/-vN2r6OL7IHg/AAAAAAAAAAI/AAAAAAAAHcs/e27OZ_SW810/photo.jpg',
// locale: 'en' } }
Binary file modified public/images/favicon.ico
Binary file not shown.
11 changes: 8 additions & 3 deletions public/javascripts/script.js
Expand Up @@ -44,6 +44,7 @@ const newComment = (data) => {
let descriptionUser = document.createElement('p');
descriptionUser.innerHTML = data.data.data.content;
let ratingUser = document.createElement('p');
ratingUser.classList = data.data.user[0].username;
ratingUser.innerHTML = `<em>Rating: </em>${data.data.data.rating || 0}`;
let likeButton = document.createElement('button');
likeButton.innerHTML = 'Like';
Expand Down Expand Up @@ -74,11 +75,15 @@ if(commentBox != undefined){
commentBox.addEventListener('click', (e)=>{
if(e.target.className == 'like-button'){
let username = e.target.parentNode.getElementsByTagName('h3')[0].innerHTML;
let ratingElement = e.target.parentNode.getElementsByTagName('p')[1];
let commentId = e.target.value;
axios.patch(`${baseUrl}/comment`, {data: username, commentId: commentId}).then(data => {
document.getElementById('comment-rating').innerHTML = `<em>Rating: </em>${data.data.rating}`;
if(data.data.liked)e.target.innerHTML="unlike";
else{e.target.innerHTML="like"}
// document.getElementsByClassName('username').forEach(element => {
// element.innerHTML = `<em>Rating: </em>${data.data.rating}`;
// });
ratingElement.innerHTML = `<em>Rating: </em>${data.data.rating}`;
if(data.data.liked)e.target.innerHTML="Unlike";
else{e.target.innerHTML="Like"}
})
}
});
Expand Down