import { formatResponse } from "../utils/responseData.mjs";
import { ErrorHandler } from "../utils/errors/ErrorHandler.mjs";
import { Request, Response } from "oauth2-server";

//#region src/controllers/oAuth2.controller.ts
const getOAuth2AccessToken = async (req, res, _next) => {
	const oauthRequest = new Request(req);
	const oauthResponse = new Response(res);
	try {
		const responseData = formatResponse({ data: await req.oauth.token(oauthRequest, oauthResponse) });
		res.json(responseData);
		return;
	} catch (error) {
		ErrorHandler.handleAppErrorResponse(res, error);
		return;
	}
};

//#endregion
export { getOAuth2AccessToken };
//# sourceMappingURL=oAuth2.controller.mjs.map