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ceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/modpacksio-common@1.2.6/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","global.__shardId = require('node-machine-id').machineIdSync();\n\nconst permission = require('./src/permission');\nconst id = require('./src/id');\nconst security = require('./src/security');\nconst database = require('./src/database');\nconst mail = require('./src/mailer');\n\nmodule.exports = Object.freeze({\n    permission, id, security, ...database, handle, mail\n});\n\nfunction handle (controller) {\n    return async (req, res) => {\n        const type = req.params.type;\n        if (req.params.type && type !== 'mods' && type !== 'modpacks')\n            return res.send(404);\n        try {\n            const ip = req.headers['x-forwarded-for'] ? req.headers['x-forwarded-for'] : req.connection.remoteAddress;\n            const response = await controller({\n                headers: req.headers,\n                params: req.params,\n                query: req.query,\n                cookies: req.cookies,\n                ip: security.sanitize(ip.startsWith('::ffff:') ? ip.substring(7) : ip),\n                body: req.body,\n                type: type && type.substring(0, type.length - 1)\n            });\n\n            // Set Cookies\n            if (response.cookies) {\n                response.cookies.filter(cookie => !cookie.remove).forEach(cookie => res.setCookie(\n                    cookie.key,\n                    cookie.value,\n                    cookie.options\n                ));\n                response.cookies.filter(cookie => cookie.remove).forEach(cookie => res.clearCookie(cookie.key));\n            }\n\n            res.headers = Object.assign({ 'Content-Type': 'application/json' }, response.headers || {});\n            res.body = response.body;\n            res.send(response.code || 200);\n        } catch (e) {\n            console.log(`Failed Request: ${e.message}`);\n            console.error(e);\n            res.send(400, { error: e.message || 'An unknown error has occurred.' });\n        }\n    }\n}"]}