{"size": 1086, "ext": "js", "max_stars_repo_path": "src/api/impl/ServiceImpl.js", "max_stars_repo_name": "19bharat/scannearn-backend", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/api/impl/ServiceImpl.js", "max_issues_repo_name": "19bharat/scannearn-backend", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/api/impl/ServiceImpl.js", "max_forks_repo_name": "19bharat/scannearn-backend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.625, "max_line_length": 89, "alphanum_fraction": 0.6307550645}
const {ServerConstants} = require('../../utilities/AppConstants.js');
const base64Img = require('base64-img');

/**
 * This is a post api
 * @param req
 * @param res
 */
function addUser(req, res) {
    global.logger.info("Received POST request: " + JSON.stringify(req.body));
    res.status(200).send({
        added: true
    });
}

/*
 * Get API
 */
function getUserStatus(req, res) {
    global.logger.info("Received GET request with path param: " + req.params.name);
    res.status(200).send({
        isActive: true
    });
}

/**
 * Handle image upload
 * @param req
 * @param res
 */
function postImageData(req, res) {
    const requestData = req.body;
    global.logger.info("Received POST request for image from user: " + requestData.user);
    const image = requestData.image;
    global.logger.info(image);
    base64Img.img(image, 'data', 'NewImage', function (err, filepath) {
        global.logger.info('Image has been saved.');
    });
    res.status(200).send({
        imageAdded: true
    });
}

module.exports = {
    getUserStatus,
    addUser,
    postImageData
};