Skip to content

Commit

Permalink
chore: fixed hono env
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Dec 2, 2024
1 parent 0a1b606 commit 3ca4e9f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Binary file modified bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
"plugin:hello-world": "tsx tests/__mocks__/hello-world-plugin.ts",
"setup-kv": "bun --env-file=.dev.vars scripts/setup-kv-namespace.ts",
"setup": "tsx ./scripts/setup.ts",
"start:local": "run-p proxy build:watch start",
"start": "func start",
"prestart": "bun run build",
"build": "tsup",
"build:watch": "tsup --watch",
"prebuild": "rimraf dist"
},
"keywords": [
Expand Down Expand Up @@ -84,6 +86,7 @@
"@types/jest": "29.5.12",
"@types/node": "20.14.10",
"@types/node-rsa": "^1.1.4",
"azure-functions-core-tools": "^4.0.6610",
"cspell": "8.9.0",
"esbuild": "0.23.0",
"eslint": "9.7.0",
Expand Down
21 changes: 11 additions & 10 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Hono, HonoRequest } from "hono";
import { Env, envSchema } from "./github/types/env";
import { Value } from "@sinclair/typebox/value";
import { WebhookEventName } from "@octokit/webhooks-types";
import { emitterEventNames } from "@octokit/webhooks";
import { WebhookEventName } from "@octokit/webhooks-types";
import { Value } from "@sinclair/typebox/value";
import { Hono, HonoRequest } from "hono";
import { env as honoEnv } from "hono/adapter";
import OpenAI from "openai";
import p from "../package.json";
import { GitHubEventHandler } from "./github/github-event-handler";
import { EmptyStore } from "./github/utils/kv-store";
import { bindHandlers } from "./github/handlers";
import p from "../package.json";
import { Env, envSchema } from "./github/types/env";
import { EmptyStore } from "./github/utils/kv-store";

const app = new Hono();

Expand Down Expand Up @@ -61,10 +62,10 @@ app.get("/", (c) => {
return c.text(`Welcome to UbiquityOS Kernel version ${p.version}`);
});

app.post("/", async (c) => {
app.post("/", async (context) => {
try {
const env = c.env as Env;
const request = c.req;
const env: Env = honoEnv(context);
const request = context.req;
validateEnv(env);
const eventName = getEventName(request);
const signatureSha256 = getSignature(request);
Expand All @@ -91,7 +92,7 @@ app.post("/", async (c) => {
return handleUncaughtError(error);
}

return c.text("OK");
return context.text("OK");
});

export default app;
2 changes: 1 addition & 1 deletion src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dotenv.config({ path: ".dev.vars" });

const smee = new SmeeClient({
source: process.env.WEBHOOK_PROXY_URL || "https://smee.io/new",
target: "http://localhost:8787/events",
target: "http://localhost:7071",
logger: console,
});

Expand Down

0 comments on commit 3ca4e9f

Please sign in to comment.