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
const event = await receiver.receive(req.body, req.get('Authorization'));
log(`Events ${event}`);
}
return res.send({method: 'method is POST'});
};
according to the documentation found on this page https://docs.livekit.io/home/server/webhooks,
i need to access the req.get() but i'm getting error
please how do i do this on Appwrite Cloud function?
TL;DR
There is no req.get() function in this context. Retrieve the "Authorization" header from the request using req.headers['authorization'] instead.Just retrieve "Authorization" from the request headers
req.get() does not even exists
Recommended threads
- Custom domain stuck at Generating certif...
Link : https://cloud.appwrite.io/console/project-fra-6601936fa10ca8d54468/functions/function-660194a6ec81f4864cf5/domains Added mentioned appwrite name servers...
- Bun Runtime
Any chance we could get Bun 1.3.8 added to the runtimes? We're currently on 1.1 and the update would be awesome
- Issue setting up url
I'm trying to setup an email verification system in my auth flow. It hasn't worked out too well. I have my domain 'parlay.live' in the web domains in the AppWri...