Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
44 lines
1.8 KiB
Plaintext
44 lines
1.8 KiB
Plaintext
import { status as httpStatus } from 'http-status';
|
|
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
import { isNumber } from '../../utilities/isNumber.js';
|
|
import { sanitizeJoinParams } from '../../utilities/sanitizeJoinParams.js';
|
|
import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js';
|
|
import { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js';
|
|
import { extractJWT } from '../extractJWT.js';
|
|
import { meOperation } from '../operations/me.js';
|
|
export const meHandler = async (req)=>{
|
|
const { searchParams } = req;
|
|
const collection = getRequestCollection(req);
|
|
const currentToken = extractJWT(req);
|
|
const depthFromSearchParams = searchParams.get('depth');
|
|
const draftFromSearchParams = searchParams.get('depth');
|
|
const { depth: depthFromQuery, draft: draftFromQuery, joins, populate, select } = req.query;
|
|
const depth = depthFromQuery || depthFromSearchParams;
|
|
const draft = draftFromQuery || draftFromSearchParams;
|
|
const result = await meOperation({
|
|
collection,
|
|
currentToken: currentToken,
|
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
draft: draft === 'true',
|
|
joins: sanitizeJoinParams(joins),
|
|
populate: sanitizePopulateParam(populate),
|
|
req,
|
|
select: sanitizeSelectParam(select)
|
|
});
|
|
if (collection.config.auth.removeTokenFromResponses) {
|
|
delete result.token;
|
|
}
|
|
return Response.json({
|
|
...result,
|
|
message: req.t('authentication:account')
|
|
}, {
|
|
headers: headersWithCors({
|
|
headers: new Headers(),
|
|
req
|
|
}),
|
|
status: httpStatus.OK
|
|
});
|
|
};
|
|
|
|
//# sourceMappingURL=me.js.map |