forked from kurozenzen/r34-json-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (36 loc) · 1.2 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
// r34-json-api
// require packages
const express = require("express");
const cors = require("cors");
const compression = require("compression");
// setup
const app = express();
process.env.PORT = process.env.PORT || 8080;
process.env.HOST = process.env.HOST || "http://localhost:" + process.env.PORT;
app.use(cors());
app.use(compression());
// 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");
const aliasRouter = require("./routing/alias");
// 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("/alias", aliasRouter);
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 + ".");
});