-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler.js
61 lines (47 loc) · 1.35 KB
/
handler.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
var handler = module.exports = {};
var auth = require('./auth.js');
var fs = require('fs');
var api = require('./githubApi.js');
var index = fs.readFileSync(__dirname + '/public/html/index.html');
var issues = fs.readFileSync(__dirname + '/public/html/issues.html');
var mainjs = fs.readFileSync(__dirname + '/public/js/main.js');
var stylecss = fs.readFileSync(__dirname + '/public/css/custom.css');
var headersHtml = {
'Content-Type' : 'text/html'
};
var headersJs = {
'Content-Type' : 'text/javascript'
};
var headersCss = {
'Content-Type' : 'text/css'
};
handler.home = function(req, res){
res.writeHead(200, headersHtml);
res.end(index);
};
handler.issuesTest = function(req, res) {
res.writeHead(200, headersHtml)
res.end(issues);
}
handler.issues = function(req, res, tokenisedUrl){
res.writeHead(200, headersHtml);
api.getIssues(tokenisedUrl[2].split('=')[1], function(issueData){
console.log(issueData);
});
};
handler.mainjs = function(req, res){
res.writeHead(200, headersJs);
res.end(mainjs);
};
handler.stylecss = function(req, res){
res.writeHead(200, headersCss);
res.end(stylecss);
};
handler.notFound = function(req, res){
res.writeHead(404, headersHtml);
res.end('Resource not found');
};
handler.auth = function(req, res){
res.writeHead(200, headersHtml);
auth.buildPostData(req, res, auth.getAccessToken);
};