Skip to content

Commit 66480ee

Browse files
committed
New Tutorial update
1 parent 788ced6 commit 66480ee

File tree

4 files changed

+22
-73
lines changed

4 files changed

+22
-73
lines changed

app/routes/api.js

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,24 @@
11
var fs = require('fs');
2-
// var S3FS = require('s3fs'),
3-
// s3fsImpl = new S3FS('brenttestbucket123', {
4-
// accessKeyId: 'AKIAIVEDHW57HJ357B2Q',
5-
// secretAccessKey: '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'
6-
// });
7-
// var multiparty = require('connect-multiparty'),
8-
// multipartyMiddleware = multiparty();
9-
10-
// Create our bucket if it doesn't exist
11-
// s3fsImpl.create();
122

133
module.exports = function(router, passport){
14-
// router.use(multipartyMiddleware);
154

16-
router.use(passport.authenticate('bearer', { session: false }));
175
router.use(function(req, res, next){
186
fs.appendFile('logs.txt', req.path + " token: " + req.query.access_token + "\n",
197
function(err){
208
next();
219
});
2210
});
2311

24-
// router.post('/testupload', function (req, res) {
25-
// var file = req.files.file;
26-
// var stream = fs.createReadStream(file.path);
27-
// return s3fsImpl.writeFile(file.originalFilename, stream).then(function () {
28-
// fs.unlink(file.path, function (err) {
29-
// if (err) {
30-
// console.error(err);
31-
// }
32-
// });
33-
// res.redirect('/profile');
34-
// });
35-
// });
36-
12+
router.get('/testAPI', function(req, res, next){
13+
if(req.query.access_token) next();
14+
else next('route');
15+
},passport.authenticate('bearer', { session: false }),
16+
function(req, res){
17+
res.json({ SecretData: 'abc123', Authenticated: true });
18+
});
3719

3820
router.get('/testAPI', function(req, res){
39-
res.json({ SecretData: 'abc123' });
21+
res.json({ SecretData: 'abc123', Authenticated: false });
4022
});
4123

4224
}

logs.txt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
/testAPI token: 552ce7a26cec006883cd986c
2-
/testAPI token: 552ce7a26cec006883cd986c
3-
/testAPI token: 552ce7a26cec006883cd986c
4-
/testAPI token: 552ce7a26cec006883cd986c
5-
/testAPI token: 552ce7a26cec006883cd986c
6-
/testAPI token: 552ce7a26cec006883cd986c
7-
/testAPI token: 552ce7a26cec006883cd986c
8-
/testAPI token: 552ce7a26cec006883cd986c
9-
/testAPI token: oY3lRXql7XGvDcyIjrj73VZFGSvr6Jkx
10-
/testAPI token: LcAqU2iSx6x737Vjj0K3dtn956MVcARZ
11-
/testAPI token: Rs40BDYu9ppZ1OdfduxB85I3ljfCuRXJ
1+
/testAPI token: AowdZfJ3txvO3fyVJ6CIzJIjBVAQrDo4
2+
/testAPI token: Zkbzqvrl4Iio1olXmyPkAlaKQfVqNW7M
3+
/testAPI token: Zkbzqvrl4Iio1olXmyPkAlaKQfVqNW7M
4+
/testAPI token: undefined
5+
/testAPI token: 108
6+
/testAPI token: StRF5B6wsliBYFjqrb3gI54nSSDnRS87

package_backup.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

server.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ io.on('connection', function(socket){
5959
socket.on('disconnect', function(){
6060
console.log('user disconnected');
6161
});
62-
63-
var i = 0;
64-
setInterval(function(){
65-
socket.emit('message', {
66-
message: i
67-
});
68-
i++;
69-
}, 1000);
62+
//Test messages by sending a message every 1 second.
63+
// var i = 0;
64+
// setInterval(function(){
65+
// socket.emit('message', {
66+
// message: i
67+
// });
68+
// i++;
69+
// }, 1000);
7070
});
7171

7272

0 commit comments

Comments
 (0)