Skip to content

Commit a40c355

Browse files
committed
removed husky and did some cleanups
1 parent 3413fb9 commit a40c355

File tree

7 files changed

+16
-29
lines changed

7 files changed

+16
-29
lines changed

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
This file was deleted.

package-lock.json

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
},
99
"scripts": {
1010
"start": "node src/index.js",
11-
"deno": "deno run --allow-net --allow-read src/server/local.js",
11+
"deno": "deno run --allow-env --allow-net --allow-read src/server/local.js",
1212
"serve": "http-server -p 443 -S -o -c-1 -C static/http-cert.pem -K static/http-key.pem",
1313
"test": "if [ -z \"$CI\" ]; then vitest run --changed $*; else vitest run $*; fi",
14-
"lint": "eslint src",
15-
"prepare": "husky"
14+
"lint": "eslint src"
1615
},
1716
"dependencies": {
1817
"@datastructures-js/priority-queue": "^6.3.5",
@@ -32,7 +31,6 @@
3231
"eslint-config-prettier": "^10.1.8",
3332
"eslint-plugin-prettier": "^5.5.5",
3433
"http-server": "^14.1.1",
35-
"husky": "^9.1.7",
3634
"playwright": "^1.58.2",
3735
"prettier": "^3.8.1",
3836
"typescript": "^5.9.3",

src/server/local.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,16 @@ let options = {
1111

1212
Deno.serve(options, async function (req) {
1313
let response = await worker.fetch(req);
14-
return response.status === 404 ? serveDir(req) : response;
14+
if (response.status === 404) response = await serveDir(req);
15+
let session = Deno.env.get("ADVENT_SESSION");
16+
if (
17+
session &&
18+
response.status === 200 &&
19+
new URL(req.url).pathname.endsWith("/solver.html")
20+
) {
21+
let html = await response.text();
22+
html = html.replace('id="session"', `id="session" value="${session}"`);
23+
response = new Response(html, response);
24+
}
25+
return response;
1526
});

src/server/worker.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ async function respond(promise) {
7171

7272
export default {
7373
async fetch(req) {
74-
let match;
7574
let session = new URL(req.url).searchParams.get("session");
76-
match = new URLPattern({ pathname: "/input/:year/:day" }).exec(req.url);
75+
let match = new URLPattern({ pathname: "/input/:year/:day" }).exec(req.url);
7776
if (req.method === "GET" && match) {
7877
let { year, day } = match.pathname.groups;
7978
return respond(getDayInput(year, day, session));

src/utils/urls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pkg from "../../static/package-lock.js";
1+
import pkg from "../../package-lock.json" with { type: "json" };
22

33
function v(p) {
44
return pkg.packages[`node_modules/${p}`].version;

static/package-lock.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)