Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vjustov opened this issue Nov 5, 2024 · 1 comment
Closed

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

vjustov opened this issue Nov 5, 2024 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@vjustov
Copy link

vjustov commented Nov 5, 2024

💬 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
@vjustov vjustov added the help wanted Extra attention is needed label Nov 5, 2024
@vjustov vjustov changed the title Help fastify-express: fastify.use is not a function Nov 5, 2024
@dosubot dosubot bot added the bug Something isn't working label Nov 5, 2024
@vjustov
Copy link
Author

vjustov commented Nov 5, 2024

nvm, leaving a comment for prosperity, the after callback is only for error handling.

@vjustov vjustov closed this as completed Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant