split api routes
This commit is contained in:
@@ -96,27 +96,36 @@ export default new class {
|
||||
const derivedKey = await scrypt(str, salt, 64);
|
||||
return crypto.timingSafeEqual(keyBuffer, derivedKey);
|
||||
};
|
||||
async auth(req, res, next) {
|
||||
if(!req.session) {
|
||||
return res.reply({
|
||||
code: 401,
|
||||
body: "401 - Unauthorized"
|
||||
});
|
||||
}
|
||||
return next();
|
||||
};
|
||||
async getTags(itemid) {
|
||||
const tags = await sql("tags_assign")
|
||||
.select("tags.id", "tags.tag", "tags.normalized", "user.user")
|
||||
.leftJoin("tags", "tags.id", "tags_assign.tag_id")
|
||||
.leftJoin("user", "user.id", "tags_assign.user_id")
|
||||
.where("tags_assign.item_id", itemid)
|
||||
.where("tags_assign.item_id", +itemid)
|
||||
.orderBy("tags.id", "asc");
|
||||
for(let t = 0; t < tags.length; t++) {
|
||||
if(tags[t].tag.startsWith(">"))
|
||||
tags[t].badge = "badge-greentext badge-light";
|
||||
else if(tags[t].tag.match(/ukraine/i))
|
||||
else if(tags[t].normalized === "ukraine")
|
||||
tags[t].badge = "badge-ukraine badge-light";
|
||||
else if(/[а-яА-ЯЁё]/.test(tags[t].tag) || tags[t].tag.match(/russia/))
|
||||
else if(/[а-яё]/.test(tags[t].normalized) || tags[t].normalized === "russia")
|
||||
tags[t].badge = "badge-russia badge-light";
|
||||
else if(tags[t].tag.match(/german/i))
|
||||
else if(tags[t].normalized === "german")
|
||||
tags[t].badge = "badge-german badge-light";
|
||||
else if(tags[t].tag.match(/dutch/i))
|
||||
else if(tags[t].normalized === "dutch")
|
||||
tags[t].badge = "badge-dutch badge-light";
|
||||
else if(tags[t].tag === "sfw")
|
||||
else if(tags[t].normalized === "sfw")
|
||||
tags[t].badge = "badge-success";
|
||||
else if(tags[t].tag === "nsfw")
|
||||
else if(tags[t].normalized === "nsfw")
|
||||
tags[t].badge = "badge-danger";
|
||||
else
|
||||
tags[t].badge = "badge-light";
|
||||
|
Reference in New Issue
Block a user