feat: add example

This commit is contained in:
Kyle Fang
2023-05-04 21:05:59 +08:00
parent 3fb89eb9a5
commit 4fa2cf3ca8
3 changed files with 11 additions and 26 deletions

View File

@@ -1,25 +0,0 @@
import { unstable_dev } from "wrangler";
import type { UnstableDevWorker } from "wrangler";
import { describe, expect, it, beforeAll, afterAll } from "vitest";
describe("Worker", () => {
let worker: UnstableDevWorker;
beforeAll(async () => {
worker = await unstable_dev("src/index.ts", {
experimental: { disableExperimentalWarning: true },
});
});
afterAll(async () => {
await worker.stop();
});
it("should return Hello World", async () => {
const resp = await worker.fetch();
if (resp) {
const text = await resp.text();
expect(text).toMatchInlineSnapshot(`"Hello World!"`);
}
});
});

View File

@@ -64,7 +64,6 @@ router.post("/t/:webhookId", async (context) => {
new Application().use(router.middleware).listen();
async function processUpdate(update: Update): Promise<void> {
console.log(JSON.stringify(update, null, 2));
if (update.message == null) {
return;
}

11
wrangler.toml.example Normal file
View File

@@ -0,0 +1,11 @@
name = "telert"
main = "src/index.ts"
compatibility_date = "2023-05-01"
kv_namespaces = [
{ binding = "TG_GROUPS", id = "***", preview_id = "***" }
]
[vars]
BOT_TOKEN = "***"
WEBHOOK_PREFIX = "***"