
* Added MS_GRAPH_CLIENT_* credentials to .env.example. * Refactored the google integration into an abstraction layer for creating events and getting the user schedule from either Google or Office 365. * FIX: when re-authorizing the Google Integration the refresh_token would no longer be set and the google integration would stop working. * Updated Office 365 integration image
20 lines
632 B
TypeScript
20 lines
632 B
TypeScript
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
import prisma from '../../../lib/prisma';
|
|
import { getBusyTimes } from '../../../lib/calendarClient';
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
const { user } = req.query
|
|
|
|
const currentUser = await prisma.user.findFirst({
|
|
where: {
|
|
username: user,
|
|
},
|
|
select: {
|
|
credentials: true,
|
|
timeZone: true
|
|
}
|
|
});
|
|
|
|
const availability = await getBusyTimes(currentUser.credentials, req.query.dateFrom, req.query.dateTo);
|
|
res.status(200).json(availability);
|
|
}
|