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'