-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.js
40 lines (34 loc) · 1.16 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
// r34-json-api
// require packages
const scraperjs = require('scraperjs');
const express = require('express');
const cors = require('cors');
// setup
const app = express();
const serviceUrl = 'https://rule34.xxx/index.php?page=dapi&q=index';
process.env.PORT = process.env.PORT || 8080;
process.env.HOST = process.env.HOST || 'http://localhost:' + process.env.PORT;
app.use(cors());
// require routers
const defaultRouter = require('./routing/default');
const commentRouter = require('./routing/comments');
const postRouter = require('./routing/posts');
const tagRouter = require("./routing/tags");
const imageRouter = require("./routing/images");
const artistRouter = require("./routing/artists");
// assign routers
app.use('/', defaultRouter);
app.use('/comments', commentRouter);
app.use('/posts', postRouter);
app.use("/tags", tagRouter);
app.use("/images", imageRouter);
app.use("/artists", artistRouter);
app.use('/c', commentRouter);
app.use('/p', postRouter);
app.use('/t', tagRouter);
app.use('/i', imageRouter);
app.use('/a', artistRouter);
// start server
app.listen(process.env.PORT, function () {
console.log('App listening on port ' + process.env.PORT + '.');
});