Skip to content

Commit

Permalink
formated files
Browse files Browse the repository at this point in the history
  • Loading branch information
colodenn committed Sep 30, 2024
1 parent 93cbc47 commit ddcdac6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createMiddleware } from "hono/factory";
import createFactory from "ronin";
import { createMiddleware } from 'hono/factory';
import createFactory from 'ronin';

type Factory = ReturnType<typeof createFactory>;

Expand Down Expand Up @@ -46,12 +46,12 @@ type QueryHandlerOptions = Parameters<typeof createFactory>[0];
export const ronin = (options: QueryHandlerOptions = {}) =>
createMiddleware<Env>(async (c, next) => {
if (!c.env.RONIN_TOKEN)
throw new Error("Missing `RONIN_TOKEN` in environment variables");
throw new Error('Missing `RONIN_TOKEN` in environment variables');

const userOptions = typeof options === "function" ? options() : options;
const userOptions = typeof options === 'function' ? options() : options;
if (userOptions.token) {
console.warn(
"The `token` option is ignored in favor of `c.env.RONIN_TOKEN` when using the `ronin` middleware.",
'The `token` option is ignored in favor of `c.env.RONIN_TOKEN` when using the `ronin` middleware.',
);

// biome-ignore lint/performance/noDelete: We're only deleting the property if it exists
Expand All @@ -63,7 +63,7 @@ export const ronin = (options: QueryHandlerOptions = {}) =>
...userOptions,
});

c.set("ronin", client);
c.set('ronin', client);

await next();
});
6 changes: 2 additions & 4 deletions tests/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { RONIN } from "ronin";

interface ImportMetaEnv {
RONIN_TOKEN: string;
}
Expand All @@ -8,9 +6,9 @@ interface ImportMeta {
readonly env: ImportMetaEnv;
}

declare module "ronin" {
declare module 'ronin' {
interface UsersGetter
extends RONIN.IGetterPlural<unknown, Array<unknown>, "users", never> {}
extends RONIN.IGetterPlural<unknown, Array<unknown>, 'users', never> {}

export namespace RONIN {
export interface Getter {
Expand Down
10 changes: 5 additions & 5 deletions tests/preload.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { afterAll, afterEach, beforeAll } from "bun:test";
import { setupServer } from "msw/node";
import { http, HttpResponse } from "msw";
import { afterAll, afterEach, beforeAll } from 'bun:test';
import { setupServer } from 'msw/node';
import { http, HttpResponse } from 'msw';

import.meta.env.RONIN_TOKEN = "secret-token";
import.meta.env.RONIN_TOKEN = 'secret-token';

const mockHttpServer = setupServer(
http.post("https://data.ronin.co/", async ({ request }) => {
http.post('https://data.ronin.co/', async ({ request }) => {
const queries = (await request.json()) as {
queries: Array<{
get: {
Expand Down

0 comments on commit ddcdac6

Please sign in to comment.