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

Start the project #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Release profile
  • Loading branch information
eksant committed Mar 7, 2018
commit f16d4687d6515e4ce444c1c682497bee3e26c8b3
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

app.use('/twatts', require('./routes/twatts'));
app.use('/api/twatts', require('./routes/twatts'));


module.exports = app;
13 changes: 11 additions & 2 deletions controllers/twatts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
const twatts = require('../models/twatts')
const Twitter = require('../models/twatts')

module.exports = {

twattProfile: (req, res) => {
Twitter.get(
'https://api.twitter.com/1.1/account/verify_credentials.json',
process.env.TOKEN_USERKEY, process.env.TOKEN_USERSECRET,
(err, data, result) => {
if (err) { res.status(400).json(err) }
else { res.status(200).send(JSON.parse(data)) }
}
)
}
}
3 changes: 1 addition & 2 deletions models/twatts.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const oauth = require('oauth').OAuth

// console.log(process.env);
var Twitter = new oauth(
'https://twitter.com/oauth/request_token', 'https://twitter.com/oauth/access_token',
process.env.TOKEN_APPKEY, process.env.TOKEN_APPSECRET, '1.0A',
'http://localhost:3000/api/twitter/sessions/callback', 'HMAC-SHA1'
null, 'HMAC-SHA1'
)

module.exports = Twitter
6 changes: 2 additions & 4 deletions routes/twatts.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
var express = require('express');
var router = express.Router();
var { twattProfile } = require('../controllers/twatts')

/* GET users listing. */
router.get('/', function(req, res, next) {
res.send('respond with a resource');
});
router.get('/profile', twattProfile)

module.exports = router;