mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-22 13:00:56 -04:00
17 lines
422 B
TypeScript
17 lines
422 B
TypeScript
import { GrowthBook, Options } from '@growthbook/growthbook';
|
|
import { FastifyPluginAsync } from 'fastify';
|
|
import fp from 'fastify-plugin';
|
|
|
|
const growthBook: FastifyPluginAsync<Options> = async (fastify, options) => {
|
|
const gb = new GrowthBook(options);
|
|
await gb.init({ timeout: 3000 });
|
|
|
|
fastify.decorate('gb', gb);
|
|
|
|
fastify.addHook('onClose', () => {
|
|
gb.destroy();
|
|
});
|
|
};
|
|
|
|
export default fp(growthBook);
|