Cleaned up index.js and added redirects
/u/ -> /profile/ /p/ -> /profile/ /a/ -> /analyze/ /c/ -> /comments/ /l/ -> /leaderboard/ ...and a few more
This commit is contained in:
parent
60da852534
commit
ec9cf9b371
1 changed files with 53 additions and 114 deletions
167
index.js
167
index.js
|
@ -42,144 +42,83 @@ app.clean = function(text) {if (!text || typeof text != "string") return text; e
|
|||
|
||||
console.log("Site online!")
|
||||
|
||||
app.use('/assets', express.static(__dirname + '/assets', {maxAge: "7d"}));
|
||||
|
||||
// ASSETS
|
||||
|
||||
app.use('/css', express.static(__dirname + '/assets/css'));
|
||||
app.use('/objects', express.static(__dirname + '/assets/objects', {maxAge: "7d"}));
|
||||
app.use('/assets', express.static(__dirname + '/assets', {maxAge: "7d"}));
|
||||
app.use('/blocks', express.static(__dirname + '/assets/blocks', {maxAge: "7d"}));
|
||||
app.use('/levelstyle', express.static(__dirname + '/assets/initial', {maxAge: "7d"}));
|
||||
app.use('/gauntlets', express.static(__dirname + '/assets/gauntlets', {maxAge: "7d"}));
|
||||
app.use('/difficulty', express.static(__dirname + '/assets/gdfaces', {maxAge: "7d"}));
|
||||
app.use('/iconkitbuttons', express.static(__dirname + '/assets/iconkitbuttons', {maxAge: "7d"}));
|
||||
app.use('/gauntlets', express.static(__dirname + '/assets/gauntlets', {maxAge: "7d"}));
|
||||
app.use('/gdicon', express.static(__dirname + '/icons/iconkit', {maxAge: "7d"}));
|
||||
app.use('/iconkitbuttons', express.static(__dirname + '/assets/iconkitbuttons', {maxAge: "7d"}));
|
||||
app.use('/levelstyle', express.static(__dirname + '/assets/initial', {maxAge: "7d"}));
|
||||
app.use('/objects', express.static(__dirname + '/assets/objects', {maxAge: "7d"}));
|
||||
|
||||
app.post("/postComment", function(req, res) {
|
||||
app.modules.postComment(app, req, res)
|
||||
})
|
||||
|
||||
app.post("/postProfileComment", function(req, res) {
|
||||
app.modules.postProfileComment(app, req, res)
|
||||
})
|
||||
// POST REQUESTS
|
||||
|
||||
app.post("/like", function(req, res) {
|
||||
app.modules.like(app, req, res)
|
||||
})
|
||||
app.post("/like", function(req, res) { app.modules.like(app, req, res) })
|
||||
app.post("/postComment", function(req, res) { app.modules.postComment(app, req, res) })
|
||||
app.post("/postProfileComment", function(req, res) { app.modules.postProfileComment(app, req, res) })
|
||||
|
||||
app.get("/api", function(req, res) {
|
||||
res.sendFile(__dirname + "/html/api.html")
|
||||
})
|
||||
|
||||
app.get("/gauntlets", function(req, res) {
|
||||
res.sendFile(__dirname + "/html/gauntlets.html")
|
||||
})
|
||||
// HTML
|
||||
|
||||
app.get("/mappacks", function(req, res) {
|
||||
res.sendFile(__dirname + "/html/mappacks.html")
|
||||
})
|
||||
app.get("/", function(req, res) { res.sendFile(__dirname + "/html/home.html") })
|
||||
app.get("/analyze/:id", async function(req, res) { res.sendFile(__dirname + "/html/analyze.html") })
|
||||
app.get("/api", function(req, res) { res.sendFile(__dirname + "/html/api.html") })
|
||||
app.get("/comments/:id", function(req, res) { res.sendFile(__dirname + "/html/comments.html") })
|
||||
app.get("/gauntlets", function(req, res) { res.sendFile(__dirname + "/html/gauntlets.html") })
|
||||
app.get("/leaderboard", function(req, res) { res.sendFile(__dirname + "/html/leaderboard.html") })
|
||||
app.get("/leaderboard/:text", function(req, res) { res.sendFile(__dirname + "/html/levelboard.html") })
|
||||
app.get("/mappacks", function(req, res) { res.sendFile(__dirname + "/html/mappacks.html") })
|
||||
app.get("/search", function(req, res) { res.sendFile(__dirname + "/html/filters.html") })
|
||||
app.get("/search/:text", function(req, res) { res.sendFile(__dirname + "/html/search.html") })
|
||||
|
||||
app.get("/search", function(req, res) {
|
||||
res.sendFile(__dirname + "/html/filters.html")
|
||||
})
|
||||
|
||||
app.get("/leaderboard", function(req, res) {
|
||||
res.sendFile(__dirname + "/html/leaderboard.html")
|
||||
})
|
||||
// API AND HTML
|
||||
|
||||
app.get("/leaderboard/:text", function(req, res) {
|
||||
res.sendFile(__dirname + "/html/levelboard.html")
|
||||
})
|
||||
app.get("/:id", function(req, res) { app.modules.level(app, req, res) })
|
||||
app.get("/profile/:id", function(req, res) { app.modules.profile(app, req, res) })
|
||||
app.get("/iconkit", function(req, res) { res.sendFile(__dirname + "/html/iconkit.html") })
|
||||
|
||||
app.get("/profile/:id", function(req, res) {
|
||||
app.modules.profile(app, req, res)
|
||||
})
|
||||
|
||||
app.get("/comments/:id", function(req, res) {
|
||||
res.sendFile(__dirname + "/html/comments.html")
|
||||
})
|
||||
// API
|
||||
|
||||
app.get("/search/:text", function(req, res) {
|
||||
res.sendFile(__dirname + "/html/search.html")
|
||||
})
|
||||
app.get("/api/analyze/:id", async function(req, res) { app.modules.level(app, req, res, api, true) })
|
||||
app.get("/api/comments/:id", function(req, res) { app.modules.comments(app, req, res, api) })
|
||||
app.get("/api/credits", function(req, res) { res.send(require('./misc/credits.json')) })
|
||||
app.get("/api/leaderboard", function(req, res, api) { app.modules[req.query.hasOwnProperty("accurate") ? "accurateLeaderboard" : "leaderboard"](app, req, res) })
|
||||
app.get("/api/leaderboardLevel/:id", function(req, res) { app.modules.leaderboardLevel(app, req, res, api) })
|
||||
app.get("/api/level/:id", async function(req, res) { app.modules.level(app, req, res, api) })
|
||||
app.get("/api/mappacks", async function(req, res) { res.send(require('./misc/mapPacks.json')) })
|
||||
app.get("/api/profile/:id", function(req, res) { app.modules.profile(app, req, res, api) })
|
||||
app.get("/api/search/:text", function(req, res) { app.modules.search(app, req, res, api) })
|
||||
|
||||
|
||||
app.get("/analyze/:id", async function(req, res) {
|
||||
res.sendFile(__dirname + "/html/analyze.html")
|
||||
})
|
||||
// REDIRECTS
|
||||
|
||||
app.get("/icon/:text", function(req, res) {
|
||||
app.modules.icon(app, req, res)
|
||||
})
|
||||
app.get("/icon", function(req, res) { res.redirect('/iconkit') })
|
||||
app.get("/iconkit/:text", function(req, res) { res.redirect('/icon/' + req.params.text) })
|
||||
app.get("/leaderboards/:id", function(req, res) { res.redirect('/leaderboard/' + req.params.id) })
|
||||
app.get("/l/:id", function(req, res) { res.redirect('/leaderboard/' + req.params.id) })
|
||||
app.get("/a/:id", function(req, res) { res.redirect('/analyze/' + req.params.id) })
|
||||
app.get("/c/:id", function(req, res) { res.redirect('/comments/' + req.params.id) })
|
||||
app.get("/u/:id", function(req, res) { res.redirect('/profile/' + req.params.id) })
|
||||
app.get("/p/:id", function(req, res) { res.redirect('/profile/' + req.params.id) })
|
||||
|
||||
app.get("/iconkit/:text", function(req, res) {
|
||||
app.modules.icon(app, req, res)
|
||||
})
|
||||
|
||||
app.get("/api/level/:id", async function(req, res) {
|
||||
app.modules.level(app, req, res, api)
|
||||
})
|
||||
// MISC
|
||||
|
||||
app.get("/api/analyze/:id", async function(req, res) {
|
||||
app.modules.level(app, req, res, api, true)
|
||||
})
|
||||
|
||||
app.get("/api/profile/:id", function(req, res) {
|
||||
app.modules.profile(app, req, res, api)
|
||||
})
|
||||
|
||||
app.get("/api/comments/:id", function(req, res) {
|
||||
app.modules.comments(app, req, res, api)
|
||||
})
|
||||
|
||||
app.get("/api/search/:text", function(req, res) {
|
||||
app.modules.search(app, req, res, api)
|
||||
})
|
||||
|
||||
app.get("/api/leaderboardLevel/:id", function(req, res) {
|
||||
app.modules.leaderboardLevel(app, req, res, api)
|
||||
})
|
||||
|
||||
app.get("/api/leaderboard", function(req, res, api) {
|
||||
if (req.query.hasOwnProperty("accurate")) app.modules.accurateLeaderboard(app, req, res)
|
||||
else return app.modules.leaderboard(app, req, res)
|
||||
})
|
||||
|
||||
app.get("/api/mappacks", async function(req, res) {
|
||||
res.send(require('./misc/mapPacks.json'))
|
||||
})
|
||||
|
||||
app.get("/api/credits", function(req, res) {
|
||||
res.send(require('./misc/credits.json'))
|
||||
})
|
||||
|
||||
app.get("/assets/sizecheck.js", function(req, res) {
|
||||
res.sendFile(__dirname + "/misc/sizecheck.js")
|
||||
})
|
||||
|
||||
app.get("/iconkit", function(req, res) {
|
||||
res.sendFile(__dirname + "/html/iconkit.html")
|
||||
})
|
||||
|
||||
app.get("/icon", function(req, res) {
|
||||
res.redirect('/iconkit')
|
||||
})
|
||||
|
||||
app.get('/api/icons', function(req, res) {
|
||||
res.send(gdicons);
|
||||
});
|
||||
|
||||
app.get("/api/:anythingelse", async function(req, res) {
|
||||
res.send('-1')
|
||||
})
|
||||
|
||||
app.get("/:id", function(req, res) {
|
||||
app.modules.level(app, req, res)
|
||||
})
|
||||
|
||||
app.get("/", function(req, res) {
|
||||
res.sendFile(__dirname + "/html/home.html")
|
||||
})
|
||||
app.get("/assets/sizecheck.js", function(req, res) { res.sendFile(__dirname + "/misc/sizecheck.js") })
|
||||
app.get('/api/icons', function(req, res) { res.send(gdicons); });
|
||||
app.get("/icon/:text", function(req, res) { app.modules.icon(app, req, res) })
|
||||
|
||||
app.get('*', function(req, res) {
|
||||
if (req.path.startsWith('/api')) res.send('-1')
|
||||
if (req.path.startsWith('/assets')) res.send("Looks like this file doesn't exist ¯\\_(ツ)_/¯<br>You can check out all of the assets <a href='https://github.com/GDColon/GDBrowser/tree/master/assets'>here</a>")
|
||||
else res.redirect('/search/404%20')
|
||||
});
|
||||
|
||||
app.listen(2000);
|
||||
app.listen(2000);
|
Loading…
Add table
Reference in a new issue