Skip to content

Commit

Permalink
moving to deno server
Browse files Browse the repository at this point in the history
  • Loading branch information
shahata committed Oct 25, 2024
1 parent 9941bcc commit c80107e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/utils/create-worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { imports } from './urls.js';
import { imports, aocSolverServer } from './urls.js';

class WorkerShim {
constructor(url, options) {
Expand Down Expand Up @@ -76,7 +76,7 @@ async function submitAnswer(e) {
const day = form.querySelector('#day').value;
const level = form.querySelector('#level').value;
const answer = form.querySelector('#answer').value;
const url = `https://www.wix.com/_serverless/adventofcode/answer/${year}/${day}?session=${session}`;
const url = `${aocSolverServer}/answer/${year}/${day}?session=${session}`;
const result = await fetch(url, {
headers: { 'content-type': 'application/x-www-form-urlencoded' },
body: `level=${level}&answer=${encodeURIComponent(answer)}`,
Expand Down
3 changes: 3 additions & 0 deletions src/utils/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ export const imports = {
...unpkg('node-forge', '/dist/forge.min.js'),
...unpkg('es-module-shims'),
};

// export const aocSolverServer = 'https://www.wix.com/_serverless/adventofcode';
export const aocSolverServer = 'https://aoc.deno.dev';
5 changes: 3 additions & 2 deletions src/utils/worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { dayName } from './day-name.js';
import { aocSolverServer } from './urls.js';

let duration;
async function timerify(fn) {
Expand All @@ -10,7 +11,7 @@ async function timerify(fn) {
}

async function readInput(session, year, day) {
let url = `https://www.wix.com/_serverless/adventofcode/input/${year}/${day}?session=${session}`;
let url = `${aocSolverServer}/input/${year}/${day}?session=${session}`;
if (!session) {
const fileName = `${year}/${dayName(day)}`;
url = new URL(`../${fileName}.txt`, self['workerShimUrl']).toString();
Expand All @@ -23,7 +24,7 @@ async function readInput(session, year, day) {
}

async function readAnswers(session, year, day) {
const url = `https://www.wix.com/_serverless/adventofcode/question/${year}/${day}?session=${session}`;
const url = `${aocSolverServer}/question/${year}/${day}?session=${session}`;
const result = await fetch(url);
return result.status === 200 ? await result.json() : [];
}
Expand Down

0 comments on commit c80107e

Please sign in to comment.