Skip to content

Commit

Permalink
remove duplicated bindings
Browse files Browse the repository at this point in the history
Signed-off-by: oilbeater <[email protected]>
  • Loading branch information
oilbeater committed Oct 2, 2024
1 parent ed8ab0f commit 8ab41de
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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!'));

Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/buffer.ts
Original file line number Diff line number Diff line change
@@ -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<AppContext>, next: Next) => {
let buffer = ''
let resolveBuffer!: () => void
const bufferPromise = new Promise<void>((resolve) => {
Expand Down
1 change: 0 additions & 1 deletion src/middlewares/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const cacheMiddleware: MiddlewareHandler = async (c: Context<AppContext>,
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 } });
}

Expand Down
3 changes: 1 addition & 2 deletions src/middlewares/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 0 additions & 8 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -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<Response>;
Expand Down

0 comments on commit 8ab41de

Please sign in to comment.