Skip to content

Commit

Permalink
create create meeting id
Browse files Browse the repository at this point in the history
  • Loading branch information
MAES-Pyramids committed Sep 15, 2023
1 parent 9b497c7 commit 455b09e
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 24 deletions.
49 changes: 26 additions & 23 deletions src/models/meeting.model.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
const mongoose = require('mongoose');
//-------------------Schema----------------//
const meetingsSchema = new mongoose.Schema({
mentor: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Mentor'
},
user: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User'
},
status: {
type: String,
enum: ['not-selected', 'pending', 'accepted', 'rejected'],
default: 'not-selected'
},
scheduledDate: {
type: Date,
required: [true, 'A meeting must have a scheduled date']
},
createdAt: {
type: Date,
default: Date.now()
}
mentor: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Mentor'
},
user: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User'
},
dyteMeetingId: {
type: String
},
status: {
type: String,
enum: ['not-selected', 'pending', 'accepted', 'rejected'],
default: 'not-selected'
},
scheduledDate: {
type: Date,
required: [true, 'A meeting must have a scheduled date']
},
createdAt: {
type: Date,
default: Date.now()
}
});
//-------------------Query Middleware----------------//
meetingsSchema.pre(/^find/, function(next) {
this.select('mentor user status scheduledDate');
next();
this.select('mentor user status scheduledDate');
next();
});
//-------------------------Export-----------------------//
const Meeting = mongoose.model('Meeting', meetingsSchema);
Expand Down
42 changes: 41 additions & 1 deletion src/utils/dyte.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
//create meeting -->meeting id
const axios = require('axios').default;

const DYTE_API_Meeting_URL = 'https://api.dyte.io/v2/meetings';
const DYTE_API_Adding_URL = `https://api.dyte.io/v2
/meetings/{meeting_id}/participants`;

const DYTE_API_TOKEN = `${process.env.ORG_ID}:${process.env.API_KEY}`;

async function createDyteMeeting(title) {
try {
const response = await axios.post(
DYTE_API_Meeting_URL,
{
title: `${title}`,
preferred_region: 'ap-south-1',
record_on_start: false,
live_stream_on_start: false
},
{
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${DYTE_API_TOKEN}`
}
}
);

return response.data.id;
} catch (error) {
console.error('Error creating Dyte meeting:', error);
throw error;
}
}

// Example usage:
const meetingTitle = 'My Dyte Meeting';
createDyteMeeting(meetingTitle)
.then(meetingId => {
console.log('Created Dyte Meeting with ID:', meetingId);
})
.catch(error => {});

//add participant -->auth token

0 comments on commit 455b09e

Please sign in to comment.