diff --git a/src/index.ts b/src/index.ts index bc42ab9..7dfd9de 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,7 @@ import { Hono } from 'hono'; import { providers } from './providers'; -import { Bindings } from './types'; -const app = new Hono<{ Bindings: Bindings }>(); +const app = new Hono<{ Bindings: Env }>(); app.get('/', (c) => c.text('Welcome to Malacca!')); diff --git a/src/middlewares/buffer.ts b/src/middlewares/buffer.ts index 5f8b8bc..d3f5daa 100644 --- a/src/middlewares/buffer.ts +++ b/src/middlewares/buffer.ts @@ -1,7 +1,7 @@ import { Context, MiddlewareHandler, Next } from 'hono' import { AppContext } from './index'; -export const bufferMiddleware: MiddlewareHandler = async (c: Context, next: Next) => { +export const bufferMiddleware: MiddlewareHandler = async (c: Context, next: Next) => { let buffer = '' let resolveBuffer!: () => void const bufferPromise = new Promise((resolve) => { diff --git a/src/middlewares/cache.ts b/src/middlewares/cache.ts index 3ef787f..daa897c 100644 --- a/src/middlewares/cache.ts +++ b/src/middlewares/cache.ts @@ -18,7 +18,6 @@ export const cacheMiddleware: MiddlewareHandler = async (c: Context, const { _, metadata } = await c.env.MALACCA_CACHE.getWithMetadata(cacheKeyHex, "stream"); const contentType = metadata['contentType'] || 'application/octet-stream'; c.set('malacca-cache-status', 'hit'); - console.log(contentType); return new Response(response, { headers: { 'malacca-cache-status': 'hit', 'content-type': contentType } }); } diff --git a/src/middlewares/index.ts b/src/middlewares/index.ts index dc6d0c4..2701b2f 100644 --- a/src/middlewares/index.ts +++ b/src/middlewares/index.ts @@ -6,10 +6,9 @@ export { bufferMiddleware } from './buffer'; export { loggingMiddleware } from './logging'; export { virtualKeyMiddleware } from './virtualKey'; export { rateLimiterMiddleware } from './rateLimiter'; -import { Bindings } from '../types'; export type AppContext = { - Bindings: Bindings, + Bindings: Env, Variables: { endpoint: string, 'malacca-cache-status': string, diff --git a/src/types.ts b/src/types.ts index da5318e..218d5ce 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,12 +1,4 @@ import { Context, Hono } from 'hono'; - -export interface Bindings { - MALACCA: AnalyticsEngineDataset, - MALACCA_USER: KVNamespace, - MALACCA_CACHE: KVNamespace, - MY_RATE_LIMITER: RateLimit, -} - export interface AIProvider { name: string; handleRequest: (c: Context) => Promise;