UNPKG

graphql-query-shortlink

Version:

Express middleware to generate GraphQL queries shortlinks to GraphiQL.

1 lines 9 kB
!function(r,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e=t();for(var n in e)("object"==typeof exports?exports:r)[n]=e[n]}}(global,function(){return function(r){var t={};function e(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=r,e.c=t,e.d=function(r,t,n){e.o(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:n})},e.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},e.t=function(r,t){if(1&t&&(r=e(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var o in r)e.d(n,o,function(t){return r[t]}.bind(null,o));return n},e.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(t,"a",t),t},e.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},e.p="",e(e.s=0)}([function(r,t,e){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(r){for(var t,e=1,n=arguments.length;e<n;e++)for(var o in t=arguments[e])Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o]);return r}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var o=e(1),i=e(5),u={graphqlUrl:"/graphql",inspectorUrl:"/goto",reportQuery:function(r){return console.log("Received query, inspect: "+r)}};t.default=function(r,t){var e=n({},u,t);return r.locals.queryLog={},r.use(t.graphqlUrl,o.default(e)),r.use(t.inspectorUrl,i.default(e)),r}},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=e(2),o=e(4);t.default=function(r){var t=r.graphqlUrl,e=r.inspectorUrl,i=r.reportQuery;return function(r,u,c){var a=r.headers.host,s=r.body,f=s.query,l=s.variables,p=u.app.locals.queryLog,d=o.default({query:f,variables:JSON.stringify(l)}),h=n.MD5({query:f,variables:l});return p[h]="http://"+a+t+"?"+d,i("http://"+a+e+"?id="+h),c()}}},function(r,t,e){"use strict";var n=e(3);function o(r,t){return function(r,t){var e;e="passthrough"!==t.algorithm?n.createHash(t.algorithm):new f;void 0===e.write&&(e.write=e.update,e.end=e.update);s(t,e).dispatch(r),e.update||e.end("");if(e.digest)return e.digest("buffer"===t.encoding?void 0:t.encoding);var o=e.read();if("buffer"===t.encoding)return o;return o.toString(t.encoding)}(r,t=c(r,t))}(t=r.exports=o).sha1=function(r){return o(r)},t.keys=function(r){return o(r,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},t.MD5=function(r){return o(r,{algorithm:"md5",encoding:"hex"})},t.keysMD5=function(r){return o(r,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var i=n.getHashes?n.getHashes().slice():["sha1","md5"];i.push("passthrough");var u=["buffer","hex","binary","base64"];function c(r,t){if((t=t||{}).algorithm=t.algorithm||"sha1",t.encoding=t.encoding||"hex",t.excludeValues=!!t.excludeValues,t.algorithm=t.algorithm.toLowerCase(),t.encoding=t.encoding.toLowerCase(),t.ignoreUnknown=!0===t.ignoreUnknown,t.respectType=!1!==t.respectType,t.respectFunctionNames=!1!==t.respectFunctionNames,t.respectFunctionProperties=!1!==t.respectFunctionProperties,t.unorderedArrays=!0===t.unorderedArrays,t.unorderedSets=!1!==t.unorderedSets,t.unorderedObjects=!1!==t.unorderedObjects,t.replacer=t.replacer||void 0,t.excludeKeys=t.excludeKeys||void 0,void 0===r)throw new Error("Object argument required.");for(var e=0;e<i.length;++e)i[e].toLowerCase()===t.algorithm.toLowerCase()&&(t.algorithm=i[e]);if(-1===i.indexOf(t.algorithm))throw new Error('Algorithm "'+t.algorithm+'" not supported. supported values: '+i.join(", "));if(-1===u.indexOf(t.encoding)&&"passthrough"!==t.algorithm)throw new Error('Encoding "'+t.encoding+'" not supported. supported values: '+u.join(", "));return t}function a(r){if("function"!=typeof r)return!1;return null!=/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(r))}function s(r,t,e){e=e||[];var n=function(r){return t.update?t.update(r,"utf8"):t.write(r,"utf8")};return{dispatch:function(t){r.replacer&&(t=r.replacer(t));var e=typeof t;return null===t&&(e="null"),this["_"+e](t)},_object:function(t){var o=Object.prototype.toString.call(t),i=/\[object (.*)\]/i.exec(o);i=(i=i?i[1]:"unknown:["+o+"]").toLowerCase();var u;if((u=e.indexOf(t))>=0)return this.dispatch("[CIRCULAR:"+u+"]");if(e.push(t),"undefined"!=typeof Buffer&&Buffer.isBuffer&&Buffer.isBuffer(t))return n("buffer:"),n(t);if("object"===i||"function"===i){var c=Object.keys(t);r.unorderedObjects&&(c=c.sort()),!1===r.respectType||a(t)||c.splice(0,0,"prototype","__proto__","constructor"),r.excludeKeys&&(c=c.filter(function(t){return!r.excludeKeys(t)})),n("object:"+c.length+":");var s=this;return c.forEach(function(e){s.dispatch(e),n(":"),r.excludeValues||s.dispatch(t[e]),n(",")})}if(!this["_"+i]){if(r.ignoreUnknown)return n("["+i+"]");throw new Error('Unknown object type "'+i+'"')}this["_"+i](t)},_array:function(t,o){o=void 0!==o?o:!1!==r.unorderedArrays;var i=this;if(n("array:"+t.length+":"),!o||t.length<=1)return t.forEach(function(r){return i.dispatch(r)});var u=[],c=t.map(function(t){var n=new f,o=e.slice();return s(r,n,o).dispatch(t),u=u.concat(o.slice(e.length)),n.read().toString()});return e=e.concat(u),c.sort(),this._array(c,!1)},_date:function(r){return n("date:"+r.toJSON())},_symbol:function(r){return n("symbol:"+r.toString())},_error:function(r){return n("error:"+r.toString())},_boolean:function(r){return n("bool:"+r.toString())},_string:function(r){n("string:"+r.length+":"),n(r)},_function:function(t){n("fn:"),a(t)?this.dispatch("[native]"):this.dispatch(t.toString()),!1!==r.respectFunctionNames&&this.dispatch("function-name:"+String(t.name)),r.respectFunctionProperties&&this._object(t)},_number:function(r){return n("number:"+r.toString())},_xml:function(r){return n("xml:"+r.toString())},_null:function(){return n("Null")},_undefined:function(){return n("Undefined")},_regexp:function(r){return n("regex:"+r.toString())},_uint8array:function(r){return n("uint8array:"),this.dispatch(Array.prototype.slice.call(r))},_uint8clampedarray:function(r){return n("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(r))},_int8array:function(r){return n("uint8array:"),this.dispatch(Array.prototype.slice.call(r))},_uint16array:function(r){return n("uint16array:"),this.dispatch(Array.prototype.slice.call(r))},_int16array:function(r){return n("uint16array:"),this.dispatch(Array.prototype.slice.call(r))},_uint32array:function(r){return n("uint32array:"),this.dispatch(Array.prototype.slice.call(r))},_int32array:function(r){return n("uint32array:"),this.dispatch(Array.prototype.slice.call(r))},_float32array:function(r){return n("float32array:"),this.dispatch(Array.prototype.slice.call(r))},_float64array:function(r){return n("float64array:"),this.dispatch(Array.prototype.slice.call(r))},_arraybuffer:function(r){return n("arraybuffer:"),this.dispatch(new Uint8Array(r))},_url:function(r){return n("url:"+r.toString())},_map:function(t){n("map:");var e=Array.from(t);return this._array(e,!1!==r.unorderedSets)},_set:function(t){n("set:");var e=Array.from(t);return this._array(e,!1!==r.unorderedSets)},_blob:function(){if(r.ignoreUnknown)return n("[blob]");throw Error('Hashing Blob objects is currently not supported\n(see https://github.com/puleos/object-hash/issues/26)\nUse "options.replacer" or "options.ignoreUnknown"\n')},_domwindow:function(){return n("domwindow")},_process:function(){return n("process")},_timer:function(){return n("timer")},_pipe:function(){return n("pipe")},_tcp:function(){return n("tcp")},_udp:function(){return n("udp")},_tty:function(){return n("tty")},_statwatcher:function(){return n("statwatcher")},_securecontext:function(){return n("securecontext")},_connection:function(){return n("connection")},_zlib:function(){return n("zlib")},_context:function(){return n("context")},_nodescript:function(){return n("nodescript")},_httpparser:function(){return n("httpparser")},_dataview:function(){return n("dataview")},_signal:function(){return n("signal")},_fsevent:function(){return n("fsevent")},_tlswrap:function(){return n("tlswrap")}}}function f(){return{buf:"",write:function(r){this.buf+=r},end:function(r){this.buf+=r},read:function(){return this.buf}}}t.writeToStream=function(r,t,e){return void 0===e&&(e=t,t={}),s(t=c(r,t),e).dispatch(r)}},function(r,t){r.exports=require("crypto")},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r){return Object.keys(r).reduce(function(t,e){return t.concat(e+"="+r[e])},[]).join("&")}},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r){return function(r,t){var e=r.query.id,n=t.app.locals.queryLog[e];return n?t.redirect(n):t.sendStatus(404).end()}}}])});