fix xml parser

This commit is contained in:
Omer Sabic 2024-06-13 14:45:06 +02:00
parent b4c44e7622
commit 8412cbc572

View File

@ -36,7 +36,7 @@ export const main = async () => {
origin: true,
credentials: true,
});
server.register(oauth, {
name: 'googleOAuth2',
scope: ['https://www.googleapis.com/auth/youtube.readonly', 'https://www.googleapis.com/auth/youtube.force-ssl', "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"],
@ -58,15 +58,11 @@ export const main = async () => {
callbackUri: `${env.PUBLIC_API_URL}/auth/google/callback`
});
server.addContentTypeParser(['text/xml', 'application/xml', 'application/atom+xml'], { parseAs: 'string' }, async (request, payload, done) => {
try {
let parsed = await xml2js.parseStringPromise(payload);
done(null, parsed)
} catch(e) {
console.log(e);
done(e, undefined)
}
})
server.addContentTypeParser(['text/xml', 'application/xml', 'application/atom+xml'], { parseAs: 'string' }, function (request, payload, done) {
xml2js.parseString(payload, function (err, body) {
done(err, body)
})
})
// Routes
server.register(channelRoutes, {