Skip to content

fastify-express: fastify.use is not a function #1069

Closed
@vjustov

Description

@vjustov

💬 Question here

We recently migrated from registering everything in a server.js file to separating concerns with plugins. one plugin we are using to register a feature flags proxy.

Getting the following error when trying to use fastify-express as a plugin
TypeError: fastify.use is not a function

import fastifyExpress from "@fastify/express";
import { FastifyPluginAsync } from "fastify";
import { createApp } from "@unleash/proxy";

const featureFlagsProxy: FastifyPluginAsync = async (fastify) => {
  fastify.register(fastifyExpress).after(() => {
    const unleashProxy = createApp({
      unleashUrl: process.env.UNLEASH_INSTANCE_URL,
      unleashApiToken: "NOT_APPLICABLE",
      clientKeys: [process.env.UNLEASH_CLIENT_KEY as string],
      refreshInterval: 1000,
      unleashInstanceId: process.env.UNLEASH_INSTANCE_ID,
      unleashAppName: "dev",
    });
    
    fastify.use(unleashProxy);
  });
};

PD: The discord invite doesnt seem to be working, says invite invalid.

Your Environment

  • node version: v20.11.1
  • fastify version: 5.0.0
  • os: Mac 14.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions