{"size": 887, "ext": "js", "max_stars_repo_path": "src/utilities/general.js", "max_stars_repo_name": "noguntuberu/fb-scraper-server", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/utilities/general.js", "max_issues_repo_name": "noguntuberu/fb-scraper-server", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/utilities/general.js", "max_forks_repo_name": "noguntuberu/fb-scraper-server", "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": 26.0882352941, "max_line_length": 64, "alphanum_fraction": 0.5772266065}
/** */
require('dotenv').config();
const { promisify } = require('util');
const { JWT_ISSUER, JWT_SECRET } = process.env;
const { sign, verify } = require('jsonwebtoken');
const signAsync = promisify(sign);

module.exports = {
    decodeAuthenticationToken: async (token) => {
        return await verify(token, JWT_SECRET, {
            issuer: JWT_ISSUER
        });
    },

    generateAuthenticationToken: async (data) => {
        const expiresIn = 21600000;
        return await signAsync({ ...data }, JWT_SECRET, {
            expiresIn,
            issuer: JWT_ISSUER,
        });
    },

    processFailedResponse: (message, statusCode = 400) => ({
        error: message || 'Invalid Request',
        payload: null,
        statusCode,
    }),

    processSuccessfulResponse: (payload, statusCode = 200) => ({
        error: null,
        payload,
        statusCode,
    }),
}