This repository has been archived by the owner on Apr 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
/
app.js
59 lines (46 loc) · 1.8 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
53
54
55
56
57
58
59
const express = require("express");
const app = express()
const path = require("path");
const axios = require("axios");
const db = require("quick.db");
const config = require("./config.js");
let apifunction = require("./functions/check_api_url.js");
let checkport = require("./functions/check_port.js");
module.exports = async function () {
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "ejs");
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
let secs = config.time_update + "000";
global.secs = secs
let port = await checkport(config.port);
let api_url = await apifunction(config.api_url, secs);
global.api_url = api_url;
;
if(!secs.includes("disable")) {
setInterval(async() => {
try {
let res = await axios.get(api_url +"api/recentlyadded/1");
db.set(`recentlyadded`, res.data.results);
let resx = await axios.get(api_url +"api/popular/1");
db.set(`popular`, resx.data.results);
} catch(e) {
let res = await axios.get(api_url +"api/recentlyadded/1");
db.set(`recentlyadded`, res.data.results);
let resx = await axios.get(api_url +"api/popular/1");
db.set(`popular`, resx.data.results);
return console.log(e);
}
},Number(secs))
}
app.use(express.static(path.join(__dirname, "assets")));
app.listen(port, () => { console.log("Website running on " + port + " port. Go to http://localhost:" + port + " to vist your website")});
console.log("Connected to " + port + " PORT");
//1200000
app.use("/search", require('./routers/search/index.js'))
app.use("/movies", require('./routers/movies/index.js'))
app.use("/tv-shows", require('./routers/tvshows/index.js'))
app.use("/details", require("./routers/anime/details.js"));
app.use("/watch", require("./routers/anime/watch.js"));
app.use("/", require("./routers/index.js"));
}