Skip to content

Commit

Permalink
move-genre-handling-to-rai (#49)
Browse files Browse the repository at this point in the history
move genre handling to rai
  • Loading branch information
wydengyre authored Jan 29, 2024
1 parent 9e61e17 commit 6383805
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions server/genres.test.ts → rai/genres.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { strict as assert } from "node:assert";
import test from "node:test";
import { json } from "itty-router";
import { FetchWithErr, NotOk, OkResponse } from "../rai/fetch.js";
import genresJson from "../rai/test/generi.json" with { type: "json" };
import { FetchWithErr, NotOk, OkResponse } from "./fetch.js";
import { genresHtml } from "./genres.js";
import genresJson from "./test/generi.json" with { type: "json" };

test("genres", async (t) => {
await t.test(genresHtmlSuccess);
Expand Down
4 changes: 2 additions & 2 deletions server/genres.ts → rai/genres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ async function genresHtml(c: Conf): Promise<string> {
return renderGenres(c.baseUrl, json);
}

const fetchGenres = async (c: Conf) => {
async function fetchGenres(c: Conf) {
const url = new URL("generi.json", c.raiBaseUrl);
const res = await c.fetchWithErr(url.toString());
return res.json();
};
}

async function renderGenres(baseUrl: URL, json: unknown): Promise<string> {
const parseResult = await schema.safeParseAsync(json);
Expand Down
2 changes: 1 addition & 1 deletion server/handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Router, createResponse, error, html, text } from "itty-router";
import { mkFetchWithErr } from "../rai/fetch.js";
import { genresHtml } from "../rai/genres.js";
import { feedHandler } from "./feed-handler.js";
import { genresHtml } from "./genres.js";
import { Logger } from "./logger.js";

export { Config, FetchHandler, mkFetchHandler };
Expand Down

0 comments on commit 6383805

Please sign in to comment.