Simple API gateway for webhooks

initial commit

finxol.io a07f128b

verified
Changed files
+157
.tangled
workflows
.zed
src
+23
.tangled/workflows/deploy.yaml
···
+
when:
+
- event: ["push", "pull_request"]
+
branch: ["main"]
+
+
dependencies:
+
nixpkgs:
+
- deno
+
+
engine: "nixery"
+
+
steps:
+
- name: Lint code
+
command: |
+
deno lint
+
+
- name: Install deployctl
+
command: |
+
deno install -gArf jsr:@deno/deployctl
+
+
- name: Deploy to Deno Deploy
+
command: |
+
cd .output/public
+
~/.deno/bin/deployctl deploy --project finxol-hook --entrypoint src/main.ts --include=. --prod
+3
.zed/settings.json
···
+
{
+
"language_servers": ["deno", "!biome"]
+
}
+3
README.md
···
+
```
+
deno task start
+
```
+4
config.ts
···
+
export const config = {
+
title: "finxol's Webhook server",
+
description: "Simple API endpoint for webhooks",
+
}
+34
deno.json
···
+
{
+
"imports": {
+
"@hono/ua-blocker": "npm:@hono/ua-blocker@^0.1.9",
+
"hono": "npm:hono@^4.9.6"
+
},
+
"tasks": {
+
"start": "deno run --allow-net src/main.ts"
+
},
+
"unstable": [
+
"kv"
+
],
+
"compilerOptions": {
+
"jsx": "precompile",
+
"jsxImportSource": "hono/jsx"
+
},
+
"fmt": {
+
"useTabs": false,
+
"lineWidth": 90,
+
"indentWidth": 4,
+
"semiColons": false,
+
"singleQuote": false,
+
"proseWrap": "preserve"
+
},
+
"deploy": {
+
"project": "bd2e7894-6133-473d-8093-f84066914d26",
+
"exclude": [
+
"**/node_modules"
+
],
+
"include": [
+
"."
+
],
+
"entrypoint": "src/main.ts"
+
}
+
}
+34
deno.lock
···
+
{
+
"version": "5",
+
"specifiers": {
+
"npm:@hono/ua-blocker@~0.1.9": "0.1.9_hono@4.9.6",
+
"npm:@types/node@*": "24.2.0",
+
"npm:hono@^4.9.6": "4.9.6"
+
},
+
"npm": {
+
"@hono/ua-blocker@0.1.9_hono@4.9.6": {
+
"integrity": "sha512-JETVhZEZGLa/kA0IZB72YhuhscacGLSeFNGxUX06stC1yagGtHAbWV98R4C/Xsta5xpfwiReMIPt+3hbsCiZoQ==",
+
"dependencies": [
+
"hono"
+
]
+
},
+
"@types/node@24.2.0": {
+
"integrity": "sha512-3xyG3pMCq3oYCNg7/ZP+E1ooTaGB4cG8JWRsqqOYQdbWNY4zbaV0Ennrd7stjiJEFZCaybcIgpTjJWHRfBSIDw==",
+
"dependencies": [
+
"undici-types"
+
]
+
},
+
"hono@4.9.6": {
+
"integrity": "sha512-doVjXhSFvYZ7y0dNokjwwSahcrAfdz+/BCLvAMa/vHLzjj8+CFyV5xteThGUsKdkaasgN+gF2mUxao+SGLpUeA=="
+
},
+
"undici-types@7.10.0": {
+
"integrity": "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag=="
+
}
+
},
+
"workspace": {
+
"dependencies": [
+
"npm:@hono/ua-blocker@~0.1.9",
+
"npm:hono@^4.9.6"
+
]
+
}
+
}
+53
src/main.ts
···
+
import { Hono } from "hono"
+
import { uaBlocker } from "@hono/ua-blocker"
+
import { aiBots, useAiRobotsTxt } from "@hono/ua-blocker/ai-bots"
+
import { config } from "../config.ts"
+
+
const app = new Hono()
+
.get("/robots.txt", useAiRobotsTxt())
+
.use(
+
"*",
+
uaBlocker({
+
blocklist: aiBots,
+
}),
+
)
+
.get("/", (ctx) => {
+
return ctx.html(`
+
<html>
+
<head>
+
<title>${config.title || "auth server"}</title>
+
<style>
+
body {
+
font-family: Arial, sans-serif;
+
margin: 0;
+
padding: 0;
+
background-color: #f5f5f5;
+
display: flex;
+
flex-direction: column;
+
justify-content: center;
+
align-items: center;
+
height: 100svh;
+
}
+
h1 {
+
font-size: 3rem;
+
color: #333;
+
text-align: center;
+
}
+
p {
+
font-size: 1.2rem;
+
color: #666;
+
text-align: center;
+
}
+
</style>
+
</head>
+
<body>
+
<h1>${config.title || "auth server"}</h1>
+
<p>
+
${config.description || "This is a simple auth server"}
+
</p>
+
</body>
+
</html>
+
`)
+
})
+
+
Deno.serve(app.fetch)
+3
src/sensors.ts
···
+
import { Hono } from "hono"
+
+
export const app = new Hono().get("/", (c) => c.text("Hello World!"))