summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-05-06 20:25:36 +0200
committerTor Andersson <tor@ccxvii.net>2025-05-06 20:25:36 +0200
commit644c287eede443c608eeab0cc6cd41da228947e3 (patch)
tree2bf71850e6afe5c954515edcc110f7c91cf6d7f2
parent2d22fd6f23e2afe24b64e4b8ab09bf1b5404e3e4 (diff)
downloadserver-644c287eede443c608eeab0cc6cd41da228947e3.tar.gz
Remove "api" prefix on many routes.
-rw-r--r--server.js16
-rw-r--r--views/head.pug2
-rw-r--r--views/profile.pug27
-rw-r--r--views/stats_title.pug (renamed from views/game_stats.pug)2
-rw-r--r--views/stats_user.pug (renamed from views/user_stats.pug)0
-rw-r--r--views/tm_seed.pug6
6 files changed, 28 insertions, 25 deletions
diff --git a/server.js b/server.js
index 8c8b52f..cfaced7 100644
--- a/server.js
+++ b/server.js
@@ -446,7 +446,7 @@ function must_pass_altcha(req, res, next) {
return next()
}
-app.get("/api/altcha-challenge", function (_req, res) {
+app.get("/altcha-challenge", function (_req, res) {
return res.json(altcha_create_challenge())
})
@@ -3206,7 +3206,7 @@ app.get("/tm/pool/:pool_name", function (req, res) {
res.render("tm_pool.pug", { seed, pool, roles, players, games, games_by_round })
})
-app.post("/api/tm/register/:seed_id/:level", must_be_logged_in, function (req, res) {
+app.post("/tm/register/:seed_id/:level", must_be_logged_in, function (req, res) {
let seed_id = req.params.seed_id | 0
let level = req.params.level | 0
let user_id = req.user.user_id
@@ -3222,7 +3222,7 @@ app.post("/api/tm/register/:seed_id/:level", must_be_logged_in, function (req, r
return res.redirect(req.headers.referer)
})
-app.post("/api/tm/withdraw/:seed_id/:level", must_be_logged_in, function (req, res) {
+app.post("/tm/withdraw/:seed_id/:level", must_be_logged_in, function (req, res) {
let seed_id = req.params.seed_id | 0
let level = req.params.level | 0
let user_id = req.user.user_id
@@ -3230,7 +3230,7 @@ app.post("/api/tm/withdraw/:seed_id/:level", must_be_logged_in, function (req, r
return res.redirect(req.headers.referer)
})
-app.post("/api/tm/start/:seed_id/:level", must_be_administrator, function (req, res) {
+app.post("/tm/start/:seed_id/:level", must_be_administrator, function (req, res) {
let seed_id = req.params.seed_id | 0
let level = req.params.level | 0
start_tournament_seed(seed_id, level)
@@ -4237,23 +4237,23 @@ const SQL_GAME_RATINGS = SQL(`
limit 50
`)
-app.get("/user-stats/:who_name", must_be_administrator, function (req, res) {
+app.get("/stats/user/:who_name", must_be_administrator, function (req, res) {
let who = SQL_SELECT_USER_BY_NAME.get(req.params.who_name)
if (who) {
let stats = SQL_USER_STATS.all(who.user_id, who.user_id)
let ratings = SQL_USER_RATINGS.all(who.user_id)
- res.render("user_stats.pug", { who, stats, ratings })
+ res.render("stats_user.pug", { who, stats, ratings })
} else {
return res.status(404).send("Invalid user name.")
}
})
-app.get("/game-stats/:title_id", must_be_administrator, function (req, res) {
+app.get("/stats/title/:title_id", must_be_administrator, function (req, res) {
let title_id = req.params.title_id
if (title_id in TITLE_TABLE) {
let title_name = TITLE_NAME[title_id]
let ratings = SQL_GAME_RATINGS.all(title_id)
- res.render("game_stats.pug", { title_name, ratings })
+ res.render("stats_title.pug", { title_name, ratings })
} else {
return res.status(404).send("Invalid title.")
}
diff --git a/views/head.pug b/views/head.pug
index 20fb9aa..da73d4e 100644
--- a/views/head.pug
+++ b/views/head.pug
@@ -14,7 +14,7 @@ mixin altcha_script()
mixin altcha_widget()
if ALTCHA
- altcha-widget(challengeurl="/api/altcha-challenge" hidelogo hidefooter auto="onsubmit" style="--altcha-border-radius:0")
+ altcha-widget(challengeurl="/altcha-challenge" hidelogo hidefooter auto="onsubmit" style="--altcha-border-radius:0")
mixin social(title,description,game)
meta(property="og:title" content=title)
diff --git a/views/profile.pug b/views/profile.pug
index de6e5c4..2f9218d 100644
--- a/views/profile.pug
+++ b/views/profile.pug
@@ -18,7 +18,7 @@ html
+userstats(who, ratings)
- h3 Account
+ h3 Notifications
p Your mail address is #{user.mail}
@@ -32,17 +32,6 @@ html
if mail.notify
p <a href="/account/mail/unsubscribe">Disable mail notifications</a>
- p
- | <a href="/account/change-password">Change password</a>
- br
- | <a href="/account/change-mail">Change mail address</a>
- br
- | <a href="/account/change-name">Change user name</a>
- br
- | <a href="/account/change-about">Change profile text</a>
- p
- | <a href="/account/delete">Delete account</a>
-
if ENABLE_WEBHOOKS
if !webhook
p <a href="/account/webhook">Configure webhook</a>
@@ -55,6 +44,20 @@ html
dt <a href="/account/webhook">Configure webhook</a>
dd= new URL(webhook.url).hostname
+ h3 Account
+
+ p
+ | <a href="/account/change-password">Change password</a>
+ br
+ | <a href="/account/change-mail">Change mail address</a>
+ br
+ | <a href="/account/change-name">Change user name</a>
+ br
+ | <a href="/account/change-about">Change profile text</a>
+
+ p
+ | <a href="/account/delete">Delete account</a>
+
p
form(action="/account/logout" method="post")
button(type="submit") Logout
diff --git a/views/game_stats.pug b/views/stats_title.pug
index 692c30b..2107b93 100644
--- a/views/game_stats.pug
+++ b/views/stats_title.pug
@@ -19,7 +19,7 @@ html
tbody
each row in ratings
tr
- td= row.name
+ td <a class="black" href="user/#{row.name}">#{row.name}</a>
td.r= row.rating
td.r= row.count
td.r= row.last
diff --git a/views/user_stats.pug b/views/stats_user.pug
index 3b201ef..3b201ef 100644
--- a/views/user_stats.pug
+++ b/views/stats_user.pug
diff --git a/views/tm_seed.pug b/views/tm_seed.pug
index 45659c5..abf02c1 100644
--- a/views/tm_seed.pug
+++ b/views/tm_seed.pug
@@ -67,11 +67,11 @@ html
if user
if queue.find(p => p.user_id === user.user_id)
- form(method="post" action="/api/tm/withdraw/" + seed.seed_id + "/" + (ix+1))
+ form(method="post" action="/tm/withdraw/" + seed.seed_id + "/" + (ix+1))
button(disabled) Register
button(type="submit") Withdraw
else if may_register && may_join_seed_level(user.user_id, seed.seed_id, ix+1)
- form(method="post" action="/api/tm/register/" + seed.seed_id + "/" + (ix+1))
+ form(method="post" action="/tm/register/" + seed.seed_id + "/" + (ix+1))
button(type="submit") Register
button(disabled) Withdraw
else
@@ -81,7 +81,7 @@ html
if user.user_id === 1
if queue.length >= seed.pool_size
- form(method="post" action="/api/tm/start/" + seed.seed_id + "/" + (ix+1))
+ form(method="post" action="/tm/start/" + seed.seed_id + "/" + (ix+1))
button(type="submit") Start
else
p <a href="/login">Login</a> or <a href="/signup">sign up</a> to register.