{"size": 621, "ext": "js", "max_stars_repo_path": "examples/qrcode-producer/lib/iso-time.js", "max_stars_repo_name": "srinikitha09/cloud-function-nodejs-samples", "max_stars_repo_stars_event_min_datetime": "2020-01-22T11:21:02.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-01T15:12:24.000Z", "max_issues_repo_path": "examples/qrcode-producer/lib/iso-time.js", "max_issues_repo_name": "srinikitha09/cloud-function-nodejs-samples", "max_issues_repo_issues_event_min_datetime": "2020-02-06T08:40:34.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-16T08:49:30.000Z", "max_forks_repo_path": "examples/qrcode-producer/lib/iso-time.js", "max_forks_repo_name": "srinikitha09/cloud-function-nodejs-samples", "max_forks_repo_forks_event_min_datetime": "2020-01-07T10:19:03.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-03T12:08:43.000Z"}
{"max_stars_count": 9, "max_issues_count": 9, "max_forks_count": 11, "avg_line_length": 23.0, "max_line_length": 60, "alphanum_fraction": 0.6119162641}
'use strict';
/**
 * @namespace Faas
 * @typedef {import("@sap/faas").Faas.Event} Faas.Event
 * @typedef {import("@sap/faas").Faas.Context} Faas.Context
 */

const qr = require('qrcode');

/**
 * @param {Faas.Event} event
 * @param {Faas.Context} context
 * @return {Promise<*>}
 */
module.exports = async function (event, context) {
    return new Promise((resolve, reject) => {
        const nowUTC = (new Date()).toISOString();

        const stream = event.getResponseStream('image/png');
        stream.on('finish', resolve);
        stream.on('error', reject);

        qr.toFileStream(stream, nowUTC);
    });
};

