我正在使用 NestJS 和 Cloud Functions,因为性能原因我想切换到 Fastify。
但我不知道要传递给什么functions.https.onRequest(???)
我的快递旧代码是:
admin.initializeApp(functions.config().firebase);
const server: express.Express = express();
const startNestApplication = async (expressInstance: express.Express) => {
const adapter = new ExpressAdapter(expressInstance);
const app = await NestFactory.create(AppModule, adapter, {});
app.enableCors();
await app.init();
return app;
};
const main = startNestApplication(server);
export const api = functions.https.onRequest(server);
新代码是:
admin.initializeApp(functions.config().firebase);
const startNestApplication = async () => {
const adapter = new FastifyAdapter();
const app = await NestFactory.create<NestFastifyApplication>(AppModule, adapter, {});
app.enableCors();
await app.init();
return app;
};
const main = startNestApplication();
export const api = functions.https.onRequest(???);