Zionnite
here is my code
TypeScript
import { default as axios } from 'axios';
import fetch from 'node-fetch';
import { WebhookReceiver } from 'livekit-server-sdk';
// This is your Appwrite function
// It's executed each time we get a request
export default async ({ req, res, log, error }) => {
const client = new Client();
const functions = new Functions(client);
const database = new Databases(client);
client.setEndpoint('https://cloud.appwrite.io/v1')
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(process.env.APPWRITE_API_KEY);
const ENDPOINT = process.env.MY_APPWRITE_ENDPOINT;
const PROJECT_ID = process.env.APPWRITE_PROJECT_ID;
const API_KEY = process.env.APPWRITE_API_KEY;
const DATABASE_ID = process.env.DATABASE_ID;
const LIVEKIT_STREAMING_COLLECTION = process.env.LIVEKIT_STREAMING_COLLECTION;
const LIVE_KIT_API = process.env.LIVE_KIT_API;
const LIVE_KIT_SEC_KEY = process.env.LIVE_KIT_SEC_KEY;
const LIVE_KIT_WEBSOCKET = process.env.LIVE_KIT_WEBSOCKET;
const receiver = new WebhookReceiver(LIVE_KIT_API, LIVE_KIT_SEC_KEY);
if (req.method === 'POST') {
const jsondData = JSON.parse(req.bodyRaw);
const VideoLibraryId = jsondData.VideoLibraryId;
const VideoGuid = jsondData.VideoGuid;
const Status = jsondData.Status;
// Event is a WebhookEvent object
var headers = req.headers;
log(`headers ${headers}`);
var authorization = headers['authorization'];
// const authorization = req.headers["Authorization"];
const event = await receiver.receive(req.body, authorization);
log(`Events ${event}`);
}
return res.send({method: 'method is POST'});
};
TL;DR
Error message: ReferenceError: crypto is not defined
Developer needs a higher NodeJS runtime. The issue is due to the usage of WebhookReceiver from 'livekit-server-sdk' that requires the 'crypto' module which is not available in the current NodeJS runtime version (18.0).
Solution: Update NodeJS to a higher version that includes the 'crypto' module. Zionnite
I'm using NodeJs Runtime Environment 18.0
Zionnite
@Joshi hello
Joshi
You literally put the answer to your problem in the title
Zionnite
my head is smoking and confused...
Zionnite
it seem like i need a higher nodejs runtime
Recommended threads
- My account is blocked so please check an...
My account is blocked so please unblock my account because all the apps are closed due to which it is causing a lot of problems
- Applying free credits on Github Student ...
So this post is kind of related to my old post where i was charged 15usd by mistake. This happens when you are trying to apply free credits you got from somewh...
- Attributes Confusion
```import 'package:appwrite/models.dart'; class OrdersModel { String id, email, name, phone, status, user_id, address; int discount, total, created_at; L...