shelfio / libreoffice-lambda-base-image

MIT License
30 stars 19 forks source link

event.body for handler #12

Open shak18 opened 2 years ago

shak18 commented 2 years ago

Is there any change from the base aws images that could affect this? as after creating my own image and attempt o use this everything goes well but i cannot send any parameters to the tests it always return a message event.body undefined if i inject the event paramenter to the handler

vladholubiev commented 2 years ago

Most likely smth related to your code, as it still works fine for us, no changes made. Maybe if you paste some of your code somebody will be able to help.

shak18 commented 2 years ago

This is my handler code


const { convertFileToPDF } = require("./logic");

module.exports.handler = async (event, context, cb) => {
    if(! event || ! event.body) {
        console.log('[Empty request body]')
        return  cb(null, {
            headers: {
                "Access-Control-Allow-Origin": "*"
            },
            body: JSON.stringify({ message: 'Invalid body provided' })
        });
    }
    console.log(event)
    const { filename, base64File } = JSON.parse(event.body);
    const pdfFileURL = await convertFileToPDF(base64File, filename).catch(cb);
    return cb(null, {
        headers: {
            "Access-Control-Allow-Origin": "*"
        },
        body: JSON.stringify({ pdfFileURL })
    });
};

it just goes directly into the empty event.body condition and im inserting data through the lambda test interface