forked from TacoGuy21/Greatsword-V3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
57 lines (49 loc) · 1.33 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
/*
Copyright © Fog Network
Made by Nebelung
MIT license: https://opensource.org/licenses/MIT
*/
const express = require("express")
const app = express()
const fetch = require("node-fetch")
const config = require("./config.json")
const port = process.env.PORT || config.port
const Corrosion = require("./lib/server")
const proxy = new Corrosion({
prefix: config.prefix,
codec: config.codec,
title: "Greatsword",
forceHttps: true,
requestMiddleware: [
Corrosion.middleware.blacklist([
"accounts.google.com",
], "Page is blocked"),
]
});
proxy.bundleScripts();
app.use(express.static("./public", {
extensions: ["html"]
}));
app.get("/", function(req, res){
res.sendFile("index.html", {root: "./public"});
});
app.get("/suggestions", function(req, res){
async function getsuggestions() {
var term = req.query.q || "";
var response = await fetch("https://duckduckgo.com/ac/?q=" + term + "&type=list");
var result = await response.json();
var suggestions = result[1]
res.send(suggestions)
}
getsuggestions()
});
app.use(function (req, res) {
if (req.url.startsWith(proxy.prefix)) {
proxy.request(req,res);
} else {
res.status(404).sendFile("404.html", {root: "./public"});
}
})
app.listen(port, () => {
console.log(`Greatsword V3 is running at localhost:${port}`)
})