用 node 做示例的话,应用大概是这样的
// app.ts
import fastify from 'fastify';
export const app = fastify();
app.get('/foo', async () => { ... });
app.post('/bar', async () => { ... });
// standalone.ts
import { app } from './app';
const main = async () => {
await app.listen({ host: ..., port: ... });
};
main();
// index.ts
import awsLambdaFastify from '@fastify/aws-lambda';
import { app } from './app';
export const handler = awsLambdaFastify(app);
这样本地开发,或者部署成单独的 http server 的时候,用 standalone 来启动应用,这种情况下用不到 index.ts。反之 aws lambda 用的话,就不需要 standalone.ts,aws 会调用 index 里的 handler。
【 在 keygen 的大作中提到: 】
: 我感觉不是太理解你这个 web service 的定义
: 一般作为 web service,不是常驻一个服务端进程,一直处理传过来的 http request 吗?
:
: ...................
--
修改:eGust FROM 222.153.59.*
FROM 222.153.59.*