Skip to content

Commit

Permalink
fix: export fetch directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucky3028 committed Aug 30, 2023
1 parent ab672a9 commit 5a1b28f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions apps/auto-run-ac/src/handlers/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { serveStatic } from 'hono/cloudflare-workers';
import * as build from 'switchbot-web/build';
import __STATIC_CONTENT_MANIFEST from '__STATIC_CONTENT_MANIFEST';
import { initSentry, isProduction } from 'shared';
import type { RequiredHandlers } from '@/lib/handler';

const assetManifest = JSON.parse(__STATIC_CONTENT_MANIFEST);
let handleRemixRequest: ReturnType<typeof createRequestHandler>;
Expand Down Expand Up @@ -78,4 +77,4 @@ app.get('*', async (ctx) => {
}
});

export const fetch: RequiredHandlers['fetch'] = (req) => app.fetch(req);
export const { fetch } = app;
4 changes: 2 additions & 2 deletions apps/auto-run-ac/src/handlers/scheduled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { notifyAirConditionerOnToDiscord } from '@/lib/discord';
import { filterValidTrigger } from '@/lib/trigger';
import { isHoliday } from '@holiday-jp/holiday_jp';
import { utcToZonedTime } from 'date-fns-tz';
import type { RequiredHandlers } from '@/lib/handler';
import type { Handlers } from '@/lib/handler';

/**
* 与えられた日付において、本プログラムによってエアコンがつけられたかどうかを返す
Expand All @@ -15,7 +15,7 @@ import type { RequiredHandlers } from '@/lib/handler';
*/
const isAlreadyTurnedOnToday = async (date: string, kv: KVNamespace) => kv.get(date).then((v) => !!v);

export const scheduled: RequiredHandlers['scheduled'] = async (_event, env, ctx) => {
export const scheduled: Required<Handlers>['scheduled'] = async (_event, env, ctx) => {
const sentry = initSentry(env.SENTRY_DSN, env.SENTRY_CLIENT_ID, env.SENTRY_CLIENT_SECRET, ctx);

try {
Expand Down
1 change: 0 additions & 1 deletion apps/auto-run-ac/src/lib/handler.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export type Handlers = ExportedHandler<Env>;
export type RequiredHandlers = Required<Handlers>;

0 comments on commit 5a1b28f

Please sign in to comment.