Skip to content

Commit 90ec6d8

Browse files
Merge pull request #4 from codeuino/development
Development
2 parents 3ca2f26 + 419347c commit 90ec6d8

File tree

16 files changed

+122
-72
lines changed

16 files changed

+122
-72
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,6 @@ typings/
7979

8080
# Config files
8181
credential.js
82-
secret.js
82+
secret.js
83+
84+
views/images/uploads

config/credential.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
module.exports = {
2-
oauth: {
3-
clientID: "192695093229-kf95jtdv1jge25d86ak99e68dkrpu33o.apps.googleusercontent.com",
4-
clientSecret: "rXvfxBahDlJF1ORk7y660XM8"
5-
},
6-
database: 'mongodb://localhost:27017',
7-
github: {
8-
clientID: 'c9afdb238ed98b213912',
9-
clientSecret: '3031efea8badea1381da682fd5f21e88e5a15d2f'
10-
},
11-
facebook: {
12-
clientID: '383717979035587',
13-
clientSecret: '82bd80d286ef6e45606da6d53a97efbc'
14-
}
15-
}
1+
module.exports = {
2+
oauth: {
3+
clientID: "192695093229-kf95jtdv1jge25d86ak99e68dkrpu33o.apps.googleusercontent.com",
4+
clientSecret: "rXvfxBahDlJF1ORk7y660XM8"
5+
},
6+
database: 'mongodb://localhost:27017/donut1',
7+
github: {
8+
clientID: 'c9afdb238ed98b213912',
9+
clientSecret: '3031efea8badea1381da682fd5f21e88e5a15d2f'
10+
},
11+
facebook: {
12+
clientID: '383717979035587',
13+
clientSecret: '82bd80d286ef6e45606da6d53a97efbc'
14+
}
15+
}

controller/profile.controller.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@ const user = require('../schema/user.js');
22
const proj = require('../schema/project.js');
33
const expressValidator = require('express-validator');
44
const { check, validationResult } = require('express-validator/check');
5-
5+
// var multer = require('multer');
6+
// var storage = multer.diskStorage({
7+
// destination: (req, file, cb) => {
8+
// cb(null, 'public/images/uploads')
9+
// },
10+
// filename: (req, file, cb) => {
11+
// cb(null, file.fieldname + '-' + Date.now())
12+
// }
13+
// });
14+
// var upload = multer({storage: storage});
615
module.exports = {
716
SubmitprojectForm:function(req,res){
817
res.render('projectForm')
@@ -35,6 +44,7 @@ module.exports = {
3544
]).sort({createdAt:-1}).then((da)=>{
3645
console.log(req.user);
3746
user.findOne({ Eid: req.params.sd }).then(function (use) {
47+
console.log(da)
3848
res.render('other-landing', { use: use, ques: da, sign: req.user});
3949
})
4050
})
@@ -62,7 +72,8 @@ module.exports = {
6272
content: req.body.cont,
6373
upvote: '',
6474
downvote: '',
65-
proid: Math.floor(Math.random() * 100000)
75+
proid: Math.floor(Math.random() * 100000),
76+
image:'/images/uploads/'+req.file.filename
6677
})
6778
.save()
6879
.then(function() {

package-lock.json

Lines changed: 69 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
"method-override": "^3.0.0",
2222
"mongo": "^0.1.0",
2323
"mongodb": "^3.1.0",
24-
"mongoose": "^5.1.7",
25-
"multer": "^1.4.1",
24+
"mongoose": "^5.4.19",
2625
"node": "^10.5.0",
2726
"node-memwatch": "^1.0.1",
2827
"nodemon": "^1.18.8",

routes/profile.routes.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@ const auth = function(req, res, next) {
1313
next();
1414
}
1515
};
16-
16+
var multer = require('multer');
17+
var storage = multer.diskStorage({
18+
destination: (req, file, cb) => {
19+
cb(null, 'views/images/uploads')
20+
},
21+
filename: (req, file, cb) => {
22+
cb(null, file.fieldname + '-' + Date.now())
23+
}
24+
});
25+
var upload = multer({storage: storage});
1726
route.get('/submitProject',auth,profileController.SubmitprojectForm)
1827
route.get('/search', url, jsonParser, profileController.search);
1928

@@ -23,7 +32,7 @@ route.get('/profile/:id', auth, profileController.profileId);
2332

2433
route.get('/profileview/:sd', auth, url, profileController.profileViewSd);
2534

26-
route.post('/publish', auth, url, profileController.publish);
35+
route.post('/publish', auth, url,upload.single('image'), profileController.publish);
2736

2837
route.post('/upDownVote', auth,url, jsonParser,profileController.upDownVote);
2938

schema/project.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ createdAt:{
4141
endAt:{
4242
type:Date
4343
},
44-
44+
image:{
45+
type:String
46+
}
4547
});
4648

4749
const proj=mongoose.model('project',project);

views/.DS_Store

8 KB
Binary file not shown.
26.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)