underfisk / nestjs-pusher Goto Github PK
View Code? Open in Web Editor NEWPusher module for nestjs with support for event chunking and decorators
Home Page: https://underfisk.github.io/nestjs-pusher/
Pusher module for nestjs with support for event chunking and decorators
Home Page: https://underfisk.github.io/nestjs-pusher/
TypeError: _pusher is not a constructor
at new PusherService (/usr/src/app/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/nestjs-pusher/dist/pusher.service.js:129:23)
at Object.<anonymous> (/usr/src/app/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/nestjs-pusher/dist/pusher-testing-util.js:14:15)
at Module._compile (node:internal/modules/cjs/loader:1257:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1311:10)
at Module.load (node:internal/modules/cjs/loader:1115:32)
at Function.Module._load (node:internal/modules/cjs/loader:962:12)
at Module.require (node:internal/modules/cjs/loader:1139:19)
at require (node:internal/modules/helpers:121:18)
at Object.<anonymous> (/usr/src/app/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/nestjs-pusher/dist/index.js:8:14)
at Module._compile (node:internal/modules/cjs/loader:1257:14)
```
In addition to the current forRoot()
method, a forRootAsync()
option will make it easy to provide pusher options asynchronously. This option is specially useful if you rely on @nestjs' ConfgService to read environment variables from a .env
file.
P.S: Send a PR shortly.
@underfisk Thanks for creating this amazing library! However, I noticed the following error as I tried using it in one of my projects. On some digging, I found that the issue gets fixed if you use import * as Pusher
instead of import Pusher
in this line. Please let me know if you need a PR for this change.
node_modules/nestjs-pusher/dist/pusher.service.js:21
this.pusher = new pusher_1.default(options);
^
TypeError: pusher_1.default is not a constructor
at new PusherService (/Users/gul/Dev/vt_ed/dist/apps/api/webpack:/vt/node_modules/nestjs-pusher/dist/pusher.service.js:21:1)
GraphQL package is being installed so that we can grab the context helper and the gql context type. The type could be easily removed as it is not relevant but the main package should be lazy loaded (Nestjs offers a solution for that, either that or we use import invocation)
###Reference
nestjs-pusher/src/pusher.interceptor.ts
Line 40 in eac3101
I tried to import this package in my NestJS v8 project, but it failed to install as nestjs-pusher requires NestJS v7 as a peer dependency.
This is my exact error
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @nestjs/[email protected]
npm ERR! node_modules/@nestjs/common
npm ERR! @nestjs/common@"^8.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @nestjs/common@"^7.5.1" from [email protected]
npm ERR! node_modules/nestjs-pusher
npm ERR! nestjs-pusher@"^0.0.10" from the root project
I also noticed you use NestJS v8 as a dev dependency. What's the reason for the mismatch?
PusherInterceptor
throws an error on the following line as it is expecting eventName
to be an object, but it is a string.
this.pusherService.trigger(
channelName,
eventName.event.name,
data,
socketId,
)
Update the interceptor to expect eventName
to be a string and not an object.
Update PusherEvent
decorator to set the metadata value as an object as shown below:
const eventName = { event: { name } };
Reflect.defineMetadata(PUSHER_EVENT, eventName, descriptor.value);
Disclaimer: I don't know the side-effects of either fix.
Is there any sample code to know how can we use and sent event to Pusher?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.