N
Novu10mo ago
KaisSalha

Issue with importing serve function

I'm trying to follow this guide: https://docs.novu.co/echo/concepts/endpoint and this is broken: import { EchoRequestHandler, ServeHandlerOptions } from '@novu/echo'; Those aren't exported from the package
10 Replies
Ask Inkeep
Ask Inkeep10mo ago
Hi @KaisSalha, I'm an AI assistant for Novu. While a team member reviews this question, I'll see if I can find relevant sources for your question. ----------------------------- While I generate an answer, here are some sources that might be helpful: * Integrate Novu with Nuxt * Integrate Novu with Next.js * Introduction * Quick Start -----------------------------
Ask Inkeep
Ask Inkeep10mo ago
Answer It appears that the imports EchoRequestHandler and ServeHandlerOptions you are trying to use are not directly mentioned in the provided documentation extracts. However, the correct import for the serve function from the @novu/echo package should look like this:
import { serve } from "@novu/echo/nuxt"; // For Nuxt.js integration
// or
import { serve } from "@novu/echo/next"; // For Next.js integration
import { serve } from "@novu/echo/nuxt"; // For Nuxt.js integration
// or
import { serve } from "@novu/echo/next"; // For Next.js integration
(1) , (2) These snippets show how to properly use the serve function within Nuxt.js and Next.js frameworks respectively. If EchoRequestHandler and ServeHandlerOptions are not being found, it's possible they might not be exported or could be part of a different version or package. Please ensure you are using the correct version of the package that supports these exports, or check the latest documentation or the repository for any recent changes that might have deprecated or moved these exports.
KaisSalha
KaisSalhaOP10mo ago
I'm intergrating it with Fastify so I'll have to go the manual route. I'm on the latest available version: "@novu/echo": "0.24.3-alpha.0",
Pawan Jain
Pawan Jain10mo ago
@KaisSalha Thanks for sharing. We are working on fix
DominusPrime
DominusPrime3mo ago
Does novu not work with Fastify for some reason?
Pawan Jain
Pawan Jain3mo ago
@DominusPrime Are you using nestjs + fastify?
DominusPrime
DominusPrime3mo ago
We want to, but haven't been able to get it to work with Fastify just yet So for now we're using nestjs + express with novu. In our other projects we've had less problems when using nestjs + fastify, so we've made a policy to only use fastify, so it feels a bit weird now to have a problem using it with novu.
dr.really
dr.really2mo ago
I'm playing around to see if we can get fastify to work, have you tried something like this?
import { serve } from '@novu/framework/express';
import { testWorkflow } from './workflows/hello-world';

....

await fastify.register(require('@fastify/express'));

fastify.get('/api/novu', serve({ workflows: [testWorkflow] }))
import { serve } from '@novu/framework/express';
import { testWorkflow } from './workflows/hello-world';

....

await fastify.register(require('@fastify/express'));

fastify.get('/api/novu', serve({ workflows: [testWorkflow] }))
DominusPrime
DominusPrime2w ago
Haven't tried it yet. This approach is similar to what we did in a previous unrelated project wherein we used fastify as a kind of proxy to an existing express backend. I guess it could work, but we'd lose a bunch of fastify performance benefits when making API calls to Novu.
Novu_Bot
Novu_Bot2w ago
@DominusPrime, you just advanced to level 1!

Did you find this page helpful?