Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: oilbeater <[email protected]>
  • Loading branch information
oilbeater committed Oct 3, 2024
1 parent 479fb6f commit f52668c
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/middlewares/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Context, MiddlewareHandler, Next } from 'hono';
import { AppContext } from './index';
import { AppContext } from '.';

export function recordAnalytics(
c: Context<AppContext>,
Expand All @@ -26,7 +26,6 @@ export function recordAnalytics(

export const metricsMiddleware: MiddlewareHandler = async (c: Context<AppContext>, next: Next) => {
const startTime = Date.now();
c.env.MALACCA
await next();

c.executionCtx.waitUntil((async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/buffer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Context, MiddlewareHandler, Next } from 'hono'
import { AppContext } from './index';
import { AppContext } from '.';

export const bufferMiddleware: MiddlewareHandler = async (c: Context<AppContext>, next: Next) => {
let buffer = ''
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/cache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Context, MiddlewareHandler, Next } from "hono";
import { AppContext } from './index';
import { AppContext } from '.';

export async function generateCacheKey(urlWithQueryParams: string, body: string): Promise<string> {
const cacheKey = await crypto.subtle.digest(
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export { loggingMiddleware } from './logging';
export { virtualKeyMiddleware } from './virtualKey';
export { rateLimiterMiddleware } from './rateLimiter';
export { guardMiddleware } from './guard';
export type AppContext = {
export interface AppContext {
Bindings: Env,
Variables: {
endpoint: string,
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/logging.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Context, Next } from 'hono';
import { AppContext } from './index';
import { AppContext } from '.';

export const loggingMiddleware = async (c: Context<AppContext>, next: Next) => {
await next();
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/rateLimiter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Context, Next } from "hono";
import { AppContext } from './index';
import { AppContext } from '.';

export const rateLimiterMiddleware = async (c: Context<AppContext>, next: Next) => {
const key = c.req.header('api-key') || '';
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/virtualKey.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Context, Next } from "hono";
import { AppContext } from './index';
import { AppContext } from '.';

export const virtualKeyMiddleware = async (c: Context<AppContext>, next: Next) => {
const apiKey = c.req.header('api-key') || '';
Expand Down
3 changes: 2 additions & 1 deletion src/providers/azureOpenAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ function getModelName(c: Context): string {
if (jsonData.model != "") {
return jsonData.model;
}
} catch (error) {
} catch {
continue;
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ beforeAll(async () => {
});

describe('Welcome to Malacca worker', () => {
it('responds with Welcome to Malacca! (integration style)', async () => {
it('responds with Welcome to Malacca!', async () => {
const response = await SELF.fetch('https://example.com');
expect(await response.text()).toMatchInlineSnapshot(`"Welcome to Malacca!"`);
});
Expand Down Expand Up @@ -145,10 +145,8 @@ describe('Test Guard', () => {
method: 'POST',
body: createRequestBody(true, 'password'),
headers: { 'Content-Type': 'application/json', 'api-key': 'oilbeater' }
});
});

expect(response.status).toBe(403);
});
});


0 comments on commit f52668c

Please sign in to comment.