我想将 NestJS 用作为 Firebase 功能提供功能的服务器。我想使用 Fastify 而不是 Express。使用 express 很容易:
const server = express();
const createNestServer = async (expressInstance: express.Express) => { const app =
await NestFactory.create(AppModule, new ExpressAdapter(expressInstance));
return await app.init();
};
const main = createNestServer(server);
export const api = functions.https.onRequest(server);
但正如我所说,我想使用 Fastify。到目前为止,我有:
const fastifyServer = Fastify();
const createNestServer = async (
fastifyInstance,
): Promise<NestFastifyApplication> => {
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter(fastifyInstance),
);
return await app.init();
};
createNestServer(fastifyServer)
.then(() => console.log('Nest with Fastify server is ready!'))
.catch((err) => console.log('Nest with Fastify server is broken!', err));
export const api = functions
.region('europe-central2')
.https.onRequest(???);
我用什么代替???
?
我发现了这个问题How to use fastify + nestjs + firebase functions但问题和答案都已经很老了。我想知道是否已经有更好的方法来做到这一点。