#Create webhook/callback when a job is completed
1 messages · Page 1 of 1 (latest)
sorry i think I didn't explain very clearly.
The user is using an endpoint (POST), with a payload that contains the URI that he wants to specify for the webhook.
When the job is completed, i would like to notify him that the job is finished (with some additional information about the job).
Ah, so they should have their own server set up to receive these updates. Yeah okay, that makes sense
yes ! I was thinking about using axios to send those job's information when the job is finished, would it be the best way to do it ?
i tried to find some "webhook/callback" implementation with nestjs
They give you an endpoint to call, so yeah, using an HTTP client to call that endpoint with the correct data is a pretty good way to go about it. Anything else would require re-architecting the endpoint on the clieint side, right? Like if you wanted to send a socket event via websockets/socket.io they'd have to set up a websocket server instead/parallel to their current server
Call injected gateway from DI into your job.
this.injectedGateway.server.emit('EventName, 'EventData')
hi, can you give more information about this ?
Read documentation about Nest.js Gateway : https://docs.nestjs.com/websockets/gateways
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
Create gateway from CLI nest g ga MyGateway
Inject gateway into your controller
class AppController {
constructor(
private readonly myGateway: MyGateway,
private readonly scheduleRegistry: ScheduleRegistry
) {}
// more code
}