From 94f7b47c5a094af711a0157726218365e9dc1ac0 Mon Sep 17 00:00:00 2001 From: xizeyoupan <44920131+xizeyoupan@users.noreply.github.com> Date: Mon, 25 Sep 2023 21:16:48 +0800 Subject: [PATCH] test --- api/index.js | 21 +++++++++++++++++++-- node.js | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/api/index.js b/api/index.js index ab8fc40..55d12c1 100644 --- a/api/index.js +++ b/api/index.js @@ -1,4 +1,4 @@ -import app from "../app.js" +// import app from "../app.js" async function writeReadableStreamToWritable(stream, writable) { let reader = stream.getReader() @@ -95,4 +95,21 @@ const getRequestListener = (fetchCallback) => { } } -export default getRequestListener(app.fetch) +// export default getRequestListener(app.fetch) + + +import api from '../src/service/api.js' +import { handler } from '../src/template.js' +import { Hono } from 'hono' +import { logger } from 'hono/logger' +import { cors } from 'hono/cors' +import { handle } from 'hono/vercel' + +const app = new Hono() +app.use('*', cors()) +app.use('*', logger()) +app.get('/api', api) +app.get('/test', handler) +app.get('/', (c) => c.text('你好!访问/test以测试。')) + +export default handle(app) diff --git a/node.js b/node.js index 7723588..b64b243 100644 --- a/node.js +++ b/node.js @@ -1,4 +1,4 @@ -import { handler } from './src/template.js' +import { handler } from './src/template' import config from './src/config.js' import api from './src/service/api.js' import { Hono } from 'hono'