-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (40 loc) · 1.01 KB
/
index.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
'use strict';
var express = require('express');
var request = require('request');
var app = express();
var maru = require('./marumaru');
app.set('view engine', 'jade')
app.use(require('serve-static')('public'));
app.get('/', function (req, res) {
res.render('index');
});
app.get('/manga', function (req, res) {
res.render('manga', {title: req.query.title, link: req.query.link});
});
app.get('/image-proxy', function (req, res) {
req
.pipe(request(req.query.src))
.on('error', function (err) {
res.sendStatus(404);
})
.pipe(res)
});
app.get('/maru/:method', function (req, res) {
switch(req.param('method')) {
case 'list':
maru.list(res.json.bind(res));
break;
case 'manga':
maru.manga(req.query.link, res.json.bind(res));
break;
case 'episode':
maru.episode(req.query.link, res.json.bind(res));
break;
default:
res.sendStatus(404);
}
});
var server = app.listen(2000, function () {
var port = server.address().port;
console.log('listening at %s...', port);
});