I have a nodejs App and am using Typescript for it and have implemented Classes and interfaces for the Models for Db . I have a model User class with interface too .I simply want to send notification and am using Puhser basic code like this
let pusher = new Pusher({
appId: process.env.PUSHER_APP_ID,
key: process.env.PUSHER_APP_KEY,
secret: process.env.PUSHER_APP_SECRET,
cluster: process.env.PUSHER_APP_CLUSTER
});
pusher.trigger('notifications', 'user_added', user, req.headers['x-socket-id']);
I thought i would be simple but its giving the following error on all the fields like appId,key etc
(property) appId: string | undefined Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'.ts(2322) index.d.ts(45, 5): The expected type comes from property 'appId' which is declared here on type 'Options'
i tried using pusher variable as interface but pusher is thirdparty system i tried
let pusher = new Pusher({
const appId: string = process.env.PUSHER_APP_ID,
const key: string = process.env.PUSHER_APP_KEY,
const secret: string = process.env.PUSHER_APP_SECRET,
const cluster: string = process.env.PUSHER_APP_CLUSTER
});
type here
PUSHER_APP_ID(etc..) defined in the process' enviroment?