frontexpress/frontexpress.min.js.map

1 line
34 KiB
Plaintext
Raw Normal View History

{"version":3,"file":null,"sources":["lib/methods.js","lib/requester.js","lib/settings.js","lib/middleware.js","lib/router.js","lib/application.js","lib/frontexpress.js"],"sourcesContent":["/**\n * HTTP method list\n * @private\n */\n\n export default ['GET', 'POST', 'PUT', 'DELETE'];\n // not supported yet\n // HEAD', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH';\n","/**\n * Module dependencies.\n * @private\n */\n\nexport default class Requester {\n\n /**\n * Make an ajax request.\n *\n * @param {Object} request\n * @param {Function} success callback\n * @param {Function} failure callback\n * @private\n */\n\n fetch(request, resolve, reject) {\n const {method, uri, headers, data} = request;\n\n const success = (responseText) => {\n resolve(\n request,\n {\n status: 200,\n statusText: 'OK',\n responseText\n }\n );\n };\n\n const fail = ({status, statusText, errorThrown}) => {\n // Removed for reducing size of frontexpress\n // const errors = this._analyzeErrors({status, statusText, errorThrown});\n reject(\n request,\n {\n status,\n statusText,\n errorThrown,\n errors: `HTTP ${status} ${statusText?statusText:''}`\n }\n );\n };\n\n const xmlhttp = new XMLHttpRequest();\n xmlhttp.onreadystatechange = () => {\n if (xmlhttp.readyState === 4) {\n if (xmlhttp.status === 200) {\n success(xmlhttp.responseText);\n } else {\n fail({status: xmlhttp.status, statusText: xmlhttp.statusText});\n }\n }\n };\n try {\n xmlhttp.open(method, uri, true);\n if (headers) {\n for (const header of Object.keys(headers)) {\n xmlhttp.setRequestHeader(header, headers[header]);\n }\n }\n if (data) {\n xmlhttp.send(data);\n } else {\n xmlhttp.send();\n }\n } catch (errorThrown) {\n fail({errorThrown});\n }\n }\n\n // Removed for reducing size of frontexpress\n // /**\n // * Analyse response errors.\n // *\n // * @private\n // */\n\n // _analyzeErrors(response) {\n // // manage exceptions\n // if (response.errorThrown) {\n // if (response.errorThrown.name === 'SyntaxError') {\n // return 'Problem during data decoding [JSON]';\n // }\n // if (response.errorThrown.name === 'TimeoutError') {\n // return 'Server is taking too long to reply';\n // }\n // if (response.errorThrown.name === 'AbortError') {\n // return 'Request cancelled on server';\n // }\n // if (response.errorThrown.name === 'NetworkError') {\n // return 'A network error occurred';\n // }\n // throw response.errorThrown;\n // }\n\n // // manage status\n // if (response.status === 0) {\n // return 'Server access problem. Check your network connection';\n // }\n // if (response.status === 401) {\n // return 'Your session has expired, Please reconnect. [code: 401]';\n // }\n // if (response.status === 404) {\n // return 'Page not found on server. [code: 404]';\n // }\n // if (response.status === 500) {\n // return 'Internal server error. [code: 500]';\n // }\n // return `Unknown error. ${response.statusText?response.statusText:''}`;\n // }\n}\n","/**\n * Module dependencies.\n * @private\n */\n\nimport Requester from './requester';\n\n\n/**\n * Settings object.\n * @private\n */\n\nexport default class Settings {\n\n\n /**\n