mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-13 03:16:31 +08:00
20 lines
806 B
TypeScript
20 lines
806 B
TypeScript
import { Hono } from 'hono';
|
|
import worker from '../../worker/src/worker';
|
|
import { CONSTANTS } from '../../worker/src/constants';
|
|
import mailApi from './mail-api';
|
|
|
|
const testApi = new Hono<HonoCustomType>();
|
|
testApi.post('/seed_mail', c => mailApi.seedMail(c.req.raw, c.env));
|
|
testApi.post('/receive_mail', c => mailApi.receiveMail(c.req.raw, c.env, c.executionCtx as ExecutionContext));
|
|
testApi.get('/telegram_binding', async c => {
|
|
const address = c.req.query('address');
|
|
if (!address) return c.text('address is required', 400);
|
|
return c.json(await c.env.KV.get(`${CONSTANTS.TG_KV_PREFIX}:${address}`));
|
|
});
|
|
|
|
const app = new Hono<HonoCustomType>();
|
|
app.route('/__test', testApi);
|
|
app.all('*', c => worker.fetch(c.req.raw, c.env, c.executionCtx));
|
|
|
|
export default { ...worker, fetch: app.fetch };
|