Spaces:
Running
Running
T1ckbase
commited on
Commit
·
c58b31c
1
Parent(s):
8b94c2a
add logger
Browse files
main.ts
CHANGED
@@ -1,10 +1,8 @@
|
|
1 |
import { Hono } from 'hono';
|
2 |
-
|
3 |
import { Minesweeper } from './minesweeper.ts';
|
4 |
import { isGithubUserPath } from './utils.ts';
|
5 |
|
6 |
-
// https://t1ckbase-minesweeper.hf.space
|
7 |
-
|
8 |
const USER = 'T1ckbase';
|
9 |
|
10 |
const MINE_COUNT = 10;
|
@@ -12,8 +10,6 @@ const minesweeper = new Minesweeper(8, 8, MINE_COUNT, './images');
|
|
12 |
|
13 |
const app = new Hono();
|
14 |
|
15 |
-
// app.use(logger());
|
16 |
-
|
17 |
app.get('/', (c) => c.text(`Play minesweeper:\nhttps://github.com/${USER}`));
|
18 |
|
19 |
app.get('/headers', (c) => c.text(Array.from(c.req.raw.headers).join('\n')));
|
@@ -36,7 +32,7 @@ app.get('/cell/:row/:col/image', (c) => {
|
|
36 |
return c.body(cellImage);
|
37 |
});
|
38 |
|
39 |
-
app.get('/cell/:row/:col/click', (c) => {
|
40 |
const row = Number(c.req.param('row'));
|
41 |
const col = Number(c.req.param('col'));
|
42 |
if (Number.isNaN(row) || Number.isNaN(col)) return c.text('Invalid coordinates', 400);
|
@@ -69,7 +65,7 @@ app.get('/game/status', (c) => {
|
|
69 |
return c.body(image);
|
70 |
});
|
71 |
|
72 |
-
app.get('/game/reset', (c) => {
|
73 |
const referer = c.req.header('Referer');
|
74 |
let redirectUrl = `https://github.com/${USER}`;
|
75 |
if (referer) {
|
|
|
1 |
import { Hono } from 'hono';
|
2 |
+
import { logger } from 'hono/logger';
|
3 |
import { Minesweeper } from './minesweeper.ts';
|
4 |
import { isGithubUserPath } from './utils.ts';
|
5 |
|
|
|
|
|
6 |
const USER = 'T1ckbase';
|
7 |
|
8 |
const MINE_COUNT = 10;
|
|
|
10 |
|
11 |
const app = new Hono();
|
12 |
|
|
|
|
|
13 |
app.get('/', (c) => c.text(`Play minesweeper:\nhttps://github.com/${USER}`));
|
14 |
|
15 |
app.get('/headers', (c) => c.text(Array.from(c.req.raw.headers).join('\n')));
|
|
|
32 |
return c.body(cellImage);
|
33 |
});
|
34 |
|
35 |
+
app.get('/cell/:row/:col/click', logger(), (c) => {
|
36 |
const row = Number(c.req.param('row'));
|
37 |
const col = Number(c.req.param('col'));
|
38 |
if (Number.isNaN(row) || Number.isNaN(col)) return c.text('Invalid coordinates', 400);
|
|
|
65 |
return c.body(image);
|
66 |
});
|
67 |
|
68 |
+
app.get('/game/reset', logger(), (c) => {
|
69 |
const referer = c.req.header('Referer');
|
70 |
let redirectUrl = `https://github.com/${USER}`;
|
71 |
if (referer) {
|