Skip to content

Commit

Permalink
omg proc deno fmt je jiny s kazdou verzi
Browse files Browse the repository at this point in the history
  • Loading branch information
mvolfik committed Sep 29, 2024
1 parent d433378 commit 27eff55
Show file tree
Hide file tree
Showing 5 changed files with 266 additions and 161 deletions.
3 changes: 2 additions & 1 deletion blog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ možná to funguje

[jednou jsme byli v přírodě](https://geohashing.site/geohashing/2024-01-27_50_14)

párkrát jsme taky byli na šifrovačkách, jednou o tom kubík dokonce i [něco](https://chamik.eu/2023/05/01/civilizace-2023/) napsal
párkrát jsme taky byli na šifrovačkách, jednou o tom kubík dokonce i
[něco](https://chamik.eu/2023/05/01/civilizace-2023/) napsal
4 changes: 2 additions & 2 deletions geohash.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function getDjiaFor(key: string) {

async function hash(seed: string) {
const digest = new Uint8Array(
await crypto.subtle.digest("MD5", new TextEncoder().encode(seed))
await crypto.subtle.digest("MD5", new TextEncoder().encode(seed)),
);
let lat = 0;
for (let i = 0; i < 8; i++) {
Expand All @@ -44,7 +44,7 @@ async function hash(seed: string) {

export async function geohash(
date: Date,
base_loc: { lat: number; lon: number }
base_loc: { lat: number; lon: number },
) {
const seedDatepart = date.toISOString().slice(0, 10);

Expand Down
8 changes: 5 additions & 3 deletions mapycz.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ function coordsToString(coords: { lat: number; lon: number }[]): string {
}

export function getUrlForPoints(points: { lat: number; lon: number }[]) {
return `https://en.mapy.cz/zakladni?vlastni-body&uc=${coordsToString(
points
)}`;
return `https://en.mapy.cz/zakladni?vlastni-body&uc=${
coordsToString(
points,
)
}`;
}

export function getImageForPoints(points: { lat: number; lon: number }[]) {
Expand Down
26 changes: 16 additions & 10 deletions server.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from "./tgbot.deno.ts";

const indexContent = new TextDecoder().decode(
await Deno.readFile("index.html")
await Deno.readFile("index.html"),
);

async function handleHttp(conn: Deno.Conn) {
Expand All @@ -23,9 +23,11 @@ async function handleHttp(conn: Deno.Conn) {
const resp = await r;
const end = performance.now();
console.log(
`${new Date().toISOString()} ${resp.status} ${e.request.method} ${
e.request.url
} ${(end - start).toFixed(1)}ms`
`${
new Date().toISOString()
} ${resp.status} ${e.request.method} ${e.request.url} ${
(end - start).toFixed(1)
}ms`,
);
return await e.respondWith(resp);
},
Expand All @@ -47,31 +49,34 @@ async function handleEvent(e: Deno.RequestEvent): Promise<Response | null> {
await handleTgRequest(e);
return null;
}
if (Math.random() < 0.001)
if (Math.random() < 0.001) {
return new Response("Yo mama so fat she became a teapot", { status: 418 });
}

if (url.pathname === "/" || url.pathname === "/index.html")
if (url.pathname === "/" || url.pathname === "/index.html") {
return new Response(indexContent, {
headers: {
"content-type": "text/html; charset=utf-8",
},
});
}


if (url.pathname === "/postele.html")
if (url.pathname === "/postele.html") {
return new Response(posteleContent, {
headers: {
"content-type": "text/html; charset=utf-8",
},
});
}

if (url.pathname === "/about")
if (url.pathname === "/about") {
return new Response("", {
headers: {
Location: "/lore",
},
status: 301,
});
}

if (url.pathname === "/lore") {
url.pathname = "/lore.jpg";
Expand Down Expand Up @@ -105,5 +110,6 @@ async function handleEvent(e: Deno.RequestEvent): Promise<Response | null> {

await tgBotInit();

for await (const conn of Deno.listen({ port: 8000 }))
for await (const conn of Deno.listen({ port: 8000 })) {
handleHttp(conn).catch((err) => console.error(err));
}
Loading

0 comments on commit 27eff55

Please sign in to comment.