mirror of
https://git.haroon.hackclub.app/haroon/Battler-Generator.git
synced 2025-06-25 06:14:20 +00:00
improve logging
This commit is contained in:
parent
5978551014
commit
70cc204d85
2 changed files with 664 additions and 3 deletions
20
index.ts
20
index.ts
|
@ -153,9 +153,8 @@ const server = createServer(async (req, res) => {
|
|||
|
||||
const url = new URL(req.url!, "https://loc.al");
|
||||
|
||||
console.log(req.method, url.pathname)
|
||||
|
||||
if (req.method == "GET" && url.pathname == "/battler.png") {
|
||||
console.log(`Generating battler`)
|
||||
const opts = Object.fromEntries(
|
||||
Array.from(url.searchParams.entries())
|
||||
.map(([key, value]) => [key, value.replaceAll('+', ' ')]),
|
||||
|
@ -174,6 +173,8 @@ const server = createServer(async (req, res) => {
|
|||
.map(([key, value]) => [key, value.replaceAll('+', ' ')]),
|
||||
) as GenerateBattlerOptions & { username: string };
|
||||
|
||||
console.log(`Generating profile battler for ${opts.username}`)
|
||||
|
||||
const canvas = createCanvas(1280, 1280);
|
||||
const ctx = canvas.getContext("2d");
|
||||
|
||||
|
@ -210,6 +211,8 @@ const server = createServer(async (req, res) => {
|
|||
);
|
||||
}
|
||||
|
||||
console.log(`Generating battle start for ${opts.username} and ${opts.opponent}`)
|
||||
|
||||
// Image dimensions
|
||||
const canvas = createCanvas(1920, 1080);
|
||||
const context = canvas.getContext("2d");
|
||||
|
@ -271,6 +274,8 @@ const server = createServer(async (req, res) => {
|
|||
);
|
||||
}
|
||||
|
||||
console.log(`Generating ${opts.action} for ${opts.username}`)
|
||||
|
||||
// Image dimensions
|
||||
const canvas = createCanvas(1920, 1080);
|
||||
const context = canvas.getContext("2d");
|
||||
|
@ -322,6 +327,8 @@ const server = createServer(async (req, res) => {
|
|||
);
|
||||
}
|
||||
|
||||
console.log(`Generating custom action (${opts.background})`)
|
||||
|
||||
// Image dimensions
|
||||
const canvas = createCanvas(1920, 1080);
|
||||
const context = canvas.getContext("2d");
|
||||
|
@ -371,6 +378,8 @@ const server = createServer(async (req, res) => {
|
|||
);
|
||||
}
|
||||
|
||||
console.log(`Generating player map (${opts.map})`)
|
||||
|
||||
const p1URL = new URL(encodeURI(opts.player1))
|
||||
const p2URL = new URL(encodeURI(opts.player2))
|
||||
|
||||
|
@ -423,6 +432,8 @@ const server = createServer(async (req, res) => {
|
|||
);
|
||||
}
|
||||
|
||||
console.log(`Generating map (${opts.map})`)
|
||||
|
||||
const p1URL = new URL(encodeURI(opts.player))
|
||||
|
||||
const p1Opts = Object.fromEntries(
|
||||
|
@ -468,6 +479,8 @@ const server = createServer(async (req, res) => {
|
|||
);
|
||||
}
|
||||
|
||||
console.log(`Generating PvP image for ${opts.username1} and ${opts.username2}`)
|
||||
|
||||
const p1URL = new URL(encodeURI(opts.player1))
|
||||
const p2URL = new URL(encodeURI(opts.player2))
|
||||
|
||||
|
@ -511,10 +524,11 @@ const server = createServer(async (req, res) => {
|
|||
return res.end(canvas.toBuffer("image/png"), 'binary')
|
||||
}
|
||||
|
||||
console.log(`Failed request (${req.method}, ${url.pathname})`)
|
||||
res.writeHead(404)
|
||||
return res.end("404 Not Found")
|
||||
})
|
||||
|
||||
server.listen(60125, () => {
|
||||
console.log(`Listening on localhost:60125`)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue