-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.js
52 lines (45 loc) · 1.26 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
const express = require("express");
const bodyParser = require("body-parser");
var search = require("./lib/search");
var detail = require("./lib/detail");
var content = require("./lib/content");
var type = require("./lib/type");
var review = require("./lib/review");
var config = require("./config");
var app = express();
app.use(
bodyParser.urlencoded({
extended: false
})
);
app.use(bodyParser.json());
app.listen(config.port);
app.get("/book/search", async function(req, res) {
var keyword = req.query.keyword;
var page = req.query.page;
res.json(await search(keyword, page));
res.end();
});
app.get(/^\/book\/(\d+)\/index\.htm$/, async function(req, res) {
var bid = req.url.split("/")[2];
res.json(await detail(bid));
res.end();
});
app.get(/^\/book\/(\d+)\/(\d+)\.htm$/, async function(req, res) {
var bid = req.url.split("/")[2];
var cid = req.url.split("/")[3];
res.json(await content(bid, cid));
res.end();
});
app.get("/book/index.php", async function(req, res) {
var type = req.query.type;
var page = req.query.page;
res.json(await type(type, page));
res.end();
});
app.get("/review/index.php", async function(req, res) {
var sort = req.query.type;
var page = req.query.page;
res.json(await review(sort, page));
res.end();
});