We're using Pusher/channel to push a message from server to client. For instance:
When a user type a new comment, the other user will receive this comment immediately.
Or when a new user was added to a new project, he/she will be see it right after the manager update member list
To use it, in your backend code, import the pusherTrigger
and trigger an event as follows:
import { pusherTrigger } from '../../lib/pusher-server'
const eventName = `event-delete-task-comment`
pusherTrigger ( 'team-collab' , eventName , {
id,
triggerBy : updatedBy
} )
Next, on the client side, create a new file in format as follow ui-app/app/_events/useEvent<event-name>.ts
// ui-app/app/_events/useEventDeleteComment.ts
import { usePusher } from './usePusher' // search usePusher in /ui-app
export const useEventDeleteComment = ( ) => {
useEffect ( ( ) => {
const eventName = `event-delete-task-comment`
channelTeamCollab &&
channelTeamCollab . bind ( eventName , ( data ) => {
console . log ( data )
} )
return ( ) => {
channelTeamCollab && channelTeamCollab . unbind ( eventName )
}
} , [ channelTeamCollab ] )
}
Configure environment variables
Name
Value
Desc
Required
NEXT_PUBLIC_FE_GATEWAY
http://localhost:4200/
Frontend url
✔️
NEXT_PUBLIC_BE_GATEWAY
http://localhost:3333/
Backend api url
✔️
NEXT_PUBLIC_APP_NAME
Namviek Dev
App name
✔️
MONGODB_URL
mongodb+srv://:@/?retryWrites=true&w=majority
Database uri
✔️
JWT_SECRET_KEY
12GUY3N76U21d4IJ
Secret key
✔️
JWT_REFRESH_KEY
7us9s88o121ieeuo
Refresh key
✔️
JWT_VERIFY_USER_LINK_TOKEN_EXPIRED
1h
Expired time
✔️
JWT_TOKEN_EXPIRED
30m
Expired time
✔️
JWT_REFRESH_EXPIRED
4h
Expired time
✔️
REDIS_HOST
Redis host
✔️
Configure Email notification and Storage
Name
Value
Desc
Required
RESEND_TOKEN
Token for sending email. Visit: https://resend.com
RESEND_EMAIL_DOMAIN
namviek.com
Email Domain
AWS_ACCESS_KEY
AWS s3 access key
AWS_SECRET_ACCESS_KEY
AWS s3 secret key
AWS_REGION
ap-southeast-1
Aws region
AWS_S3_BUCKET
kampunistore
Aws bucket name
Configure Push notification using Pusher.js
Name
Value
Desc
Required
NEXT_PUBLIC_PUSHER_INSTANCE_ID
Pusher beam instance id
PUSHER_INSTANCE_ID
Pusher beam instance id
PUSHER_SECRET_KEY
Pusher beam secret key
NEXT_PUBLIC_PUSHER_CHANNEL_APP_KEY
Push channel app key
NEXT_PUBLIC_PUSHER_CHANNEL_APP_CLUSTER
ap1
Pusher channel app cluster
PUSHER_CHANNEL_APP_ID
1710577
Pusher channel app id
PUSHER_CHANNEL_SECRET
Pusher channel secret
Configure Livekit for online meeting
Name
Value
Desc
Required
LIVEKIT_API_KEY
ANSWjslSNAwexMy
Livekit api key
LIVEKIT_API_SECRET
Livekit api secret
NEXT_PUBLIC_LIVEKIT_URL
wss://namviek-hmunmehy.livekit.cloud
Livekit url
Name
Value
Desc
Required
LOGTAIL_SOURCE_TOKEN
Logtail source token
Configure firebase for email verification
Name
Value
Desc
Required
FIREBASE_PROJECT_ID
namviek-4234
Project id
FIREBASE_CLIENT_EMAIL
[email protected]
Client email generated by Firebase
FIREBASE_PRIVATE_KEY
Firebase private key