-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.js
46 lines (36 loc) · 1.38 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* This is an example of a basic node.js script that performs
* the Authorization Code oAuth2 flow to authenticate against
* the Spotify Accounts.
*
* For more information, read
* https://developer.spotify.com/web-api/authorization-guide/#authorization_code_flow
*/
var express = require('express'), // Express web server framework
request = require('request'), // "Request" library
querystring = require('querystring'),
cookieParser = require('cookie-parser'),
fs = require('fs');
// libs
var spotifyAuth = require('./lib/spotify_auth'); // for authenticating with spotify
// controllers
var controllers = {};
var controllers_path = './controllers';
fs.readdirSync(controllers_path).forEach(function (file) {
if (file.indexOf('.js') !== -1) {
controllers[file.split('.')[0]] = require(controllers_path + '/' + file);
}
});
var app = express();
app.use(express.static(__dirname + '/public'))
.use(cookieParser());
var config = require('./config').url;
var port = config.port,
my_uri = config.uri,
redirect_uri = config.redirect_uri;
app.get('/login', spotifyAuth.generateLogin(redirect_uri));
app.get('/callback', spotifyAuth.generateCallback(redirect_uri, '/#'));
app.get('/refresh_token', spotifyAuth.refreshToken);
app.get('/api/v1/quizlet/:user/:playlist', controllers.v1.quizlet.get);
console.log('Listening on port ' + port);
app.listen(port);