This repository has been archived by the owner on Dec 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
64 lines (49 loc) · 1.46 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Connect to the database
require('./api/db.js');
// all the requires
//var jsonfile = require('jsonfile');
var path = require('path');
var express = require('express');
var bodyParser = require('body-parser');
//var request = require('request');
// this is the whole app
var app = express();
var routes = require('./api/index.js');
// this server gonna run on this port
app.set('port', 8080);
// logging out all the access
app.use(function(req, res, next){
console.log(req.method, req.url);
next();
});
// Connect to Spotify
app.locals.spotify = require('./api/spot.js')();
// global variables
app.locals.spotifyy = {
id64: 'ZWM1NDQ5ZjEwYTUzNGRmZDgwODkwY2Y5NmEzMmEzNWU6MWM0NmQ0ZjVmMzAxNDZhNzk4Nzc3YTE3MzcyZjYzZmU=',
token: 'nowaythisisgoingtowork',
expire: 0
};
// global variables
//app.locals.spotify = {};
// static directory
app.use(express.static(path.join(__dirname, 'html')));
// node modules
app.use('/node_modules', express.static(path.join(__dirname,'/node_modules')));
// enable parser so it can read POST
app.use(bodyParser.urlencoded({ extended: false }));;
app.use(bodyParser.json());
//var ctrl = require('./api/controllers.js');
// Ad routing
app.use('/api', routes);
// app.
// route('/api/getSpotifyToken').
// get(ctrl.getToken);
// app.
// route('/api/addSong').
// get(ctrl.songsAddOne);
// Listen for requests
var server = app.listen(app.get('port'), function(){
var port = server.address().port;
console.log("Magic happens on port " + port);
});