request-scope-api 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/capture.js
CHANGED
|
@@ -244,27 +244,6 @@ function wrapResponse(res, req, requestBody, requestBodySize, clientIp, sensitiv
|
|
|
244
244
|
}
|
|
245
245
|
originalEnd.call(this, chunk, encoding, cb);
|
|
246
246
|
};
|
|
247
|
-
// Patch Express-specific methods that might bypass res.write/res.end
|
|
248
|
-
const expressRes = res;
|
|
249
|
-
if (expressRes.send) {
|
|
250
|
-
const originalSend = expressRes.send;
|
|
251
|
-
expressRes.send = function (body) {
|
|
252
|
-
// Capture the body before sending
|
|
253
|
-
if (body !== undefined) {
|
|
254
|
-
const str = typeof body === 'string' ? body : JSON.stringify(body);
|
|
255
|
-
accumulateChunk(str, 'utf8');
|
|
256
|
-
}
|
|
257
|
-
return originalSend.call(this, body);
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
if (expressRes.json) {
|
|
261
|
-
const originalJson = expressRes.json;
|
|
262
|
-
expressRes.json = function (obj) {
|
|
263
|
-
const str = JSON.stringify(obj);
|
|
264
|
-
accumulateChunk(str, 'utf8');
|
|
265
|
-
return originalJson.call(this, obj);
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
247
|
// Listen for finish event to build the record
|
|
269
248
|
res.on('finish', () => {
|
|
270
249
|
const endTime = process.hrtime.bigint();
|
package/dist/cjs/capture.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../../src/capture.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAiCH,sCAaC;AA0DD,8CAuFC;AAgDD,
|
|
1
|
+
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../../src/capture.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAiCH,sCAaC;AA0DD,8CAuFC;AAgDD,oCAsJ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
|
|
65
65
|
*
|
|
66
66
|
* @license MIT
|
|
67
|
-
*/function ri(){return ri=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ri.apply(null,arguments)}function Sh(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Eh(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ch(e,t){return e.button===0&&(!t||t==="_self")&&!Eh(e)}const Nh=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],jh="6";try{window.__reactRouterVersion=jh}catch{}const _h="startTransition",ks=vf[_h];function Ph(e){let{basename:t,children:n,future:r,window:l}=e,o=k.useRef();o.current==null&&(o.current=Pp({window:l,v5Compat:!0}));let i=o.current,[u,s]=k.useState({action:i.action,location:i.location}),{v7_startTransition:a}=r||{},m=k.useCallback(p=>{a&&ks?ks(()=>s(p)):s(p)},[s,a]);return k.useLayoutEffect(()=>i.listen(m),[i,m]),k.useEffect(()=>yh(r),[r]),k.createElement(wh,{basename:t,children:n,location:u.location,navigationType:u.action,navigator:i,future:r})}const Lh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Th=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,li=k.forwardRef(function(t,n){let{onClick:r,relative:l,reloadDocument:o,replace:i,state:u,target:s,to:a,preventScrollReset:m,viewTransition:p}=t,v=Sh(t,Nh),{basename:w}=k.useContext(wt),g,y=!1;if(typeof a=="string"&&Th.test(a)&&(g=a,Lh))try{let h=new URL(window.location.href),x=a.startsWith("//")?new URL(h.protocol+a):new URL(a),C=bi(x.pathname,w);x.origin===h.origin&&C!=null?a=C+x.search+x.hash:y=!0}catch{}let E=nh(a,{relative:l}),f=Rh(a,{replace:i,state:u,target:s,preventScrollReset:m,relative:l,viewTransition:p});function c(h){r&&r(h),h.defaultPrevented||f(h)}return k.createElement("a",ri({},v,{href:g||E,onClick:y||o?r:c,ref:n,target:s}))});var Ss;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Ss||(Ss={}));var Es;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Es||(Es={}));function Rh(e,t){let{target:n,replace:r,state:l,preventScrollReset:o,relative:i,viewTransition:u}=t===void 0?{}:t,s=Hc(),a=sr(),m=Qc(e,{relative:i});return k.useCallback(p=>{if(Ch(p,n)){p.preventDefault();let v=r!==void 0?r:dl(a)===dl(m);s(e,{replace:v,state:l,preventScrollReset:o,relative:i,viewTransition:u})}},[a,s,m,r,l,n,e,o,i,u])}const ru="/requestscope/api";async function zh(e){const t=new URLSearchParams;e.search&&t.set("search",e.search),e.startDate&&t.set("startDate",e.startDate),e.endDate&&t.set("endDate",e.endDate),e.statusCodeGroup&&t.set("statusCodeGroup",e.statusCodeGroup),e.statusCode&&t.set("statusCode",e.statusCode.toString()),e.method&&t.set("method",e.method),e.sortBy&&t.set("sortBy",e.sortBy),e.sortOrder&&t.set("sortOrder",e.sortOrder),t.set("page",e.page.toString()),t.set("pageSize",e.pageSize.toString());const n=await fetch(`${ru}/records?${t.toString()}`);if(!n.ok)throw new Error(`Failed to fetch records: ${n.statusText}`);return n.json()}async function Oh(e){const t=await fetch(`${ru}/records/${e}`);if(!t.ok)throw new Error(`Failed to fetch record: ${t.statusText}`);return t.json()}async function Dh(){const e=await fetch(`${ru}/records`,{method:"DELETE"});if(!e.ok)throw new Error(`Failed to delete records: ${e.statusText}`);return e.json()}function Mh(e){const[t,n]=k.useState([]),[r,l]=k.useState(0),[o,i]=k.useState(!1),[u,s]=k.useState(null),a=k.useCallback((m=!0)=>{m&&i(!0),s(null),zh(e).then(p=>{n(p.records),l(p.total)}).catch(p=>{s(p instanceof Error?p.message:"Failed to fetch records")}).finally(()=>{m&&i(!1)})},[e]);return k.useEffect(()=>{a(!0)},[a]),{records:t,total:r,loading:o,error:u,refetch:()=>a(!0),silentRefetch:()=>a(!1)}}function lu(){const[e,t]=k.useState(()=>localStorage.getItem("requestscope-theme")||"light");return k.useEffect(()=>{localStorage.setItem("requestscope-theme",e),document.documentElement.className=e},[e]),[e,t]}const Ih={GET:"bg-green-100 text-green-800",POST:"bg-blue-100 text-blue-800",PUT:"bg-yellow-100 text-yellow-800",DELETE:"bg-red-100 text-red-800",PATCH:"bg-purple-100 text-purple-800"};function Xc({method:e}){const t=Ih[e]||"bg-gray-100 text-gray-800";return d.jsx("span",{className:`px-2 py-1 rounded text-xs font-mono font-bold ${t}`,children:e})}const Fh=e=>e>=200&&e<300?"bg-green-100 text-green-800":e>=300&&e<400?"bg-blue-100 text-blue-800":e>=400&&e<500?"bg-yellow-100 text-yellow-800":e>=500?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800";function Jc({statusCode:e}){const t=Fh(e);return d.jsx("span",{className:`px-2 py-1 rounded text-xs font-mono font-bold ${t}`,children:e})}function Uh({filters:e,onFiltersChange:t}){const[n,r]=k.useState(e.search||""),[l,o]=k.useState(e.method||""),[i,u]=k.useState(e.statusCodeGroup||""),[s,a]=k.useState(e.startDate||""),[m,p]=k.useState(e.endDate||""),v=()=>{let g,y;if(s&&(g=new Date(s).toISOString()),m){const E=new Date(m);E.setHours(23,59,59,999),y=E.toISOString()}t({...e,search:n||void 0,method:l||void 0,statusCodeGroup:i||void 0,startDate:g,endDate:y})},w=()=>{r(""),o(""),u(""),a(""),p(""),t({...e,search:void 0,method:void 0,statusCodeGroup:void 0,startDate:void 0,endDate:void 0})};return d.jsxs("div",{className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 mb-6",children:[d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-4",children:[d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Search URL"}),d.jsx("input",{type:"text",value:n,onChange:g=>r(g.target.value),className:"w-full px-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 transition-colors",placeholder:"Search..."})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Method"}),d.jsxs("select",{value:l,onChange:g=>o(g.target.value),className:"w-full px-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-white transition-colors",children:[d.jsx("option",{value:"",children:"All"}),d.jsx("option",{value:"GET",children:"GET"}),d.jsx("option",{value:"POST",children:"POST"}),d.jsx("option",{value:"PUT",children:"PUT"}),d.jsx("option",{value:"DELETE",children:"DELETE"}),d.jsx("option",{value:"PATCH",children:"PATCH"})]})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Status"}),d.jsxs("select",{value:i,onChange:g=>u(g.target.value),className:"w-full px-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-white transition-colors",children:[d.jsx("option",{value:"",children:"All"}),d.jsx("option",{value:"2xx",children:"2xx"}),d.jsx("option",{value:"3xx",children:"3xx"}),d.jsx("option",{value:"4xx",children:"4xx"}),d.jsx("option",{value:"5xx",children:"5xx"})]})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Start Date"}),d.jsx("input",{type:"date",value:s,onChange:g=>a(g.target.value),className:"w-full px-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-white transition-colors"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"End Date"}),d.jsx("input",{type:"date",value:m,onChange:g=>p(g.target.value),className:"w-full px-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-white transition-colors"})]})]}),d.jsxs("div",{className:"flex space-x-3 mt-6",children:[d.jsx("button",{onClick:v,className:"px-6 py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors font-medium",children:"Apply Filters"}),d.jsx("button",{onClick:w,className:"px-6 py-2.5 bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-300 dark:hover:bg-gray-600 focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 transition-colors font-medium",children:"Reset"})]})]})}function $h({currentPage:e,totalPages:t,onPageChange:n}){const r=[];let o=Math.max(1,e-Math.floor(2.5)),i=Math.min(t,o+5-1);i-o<4&&(o=Math.max(1,i-5+1));for(let u=o;u<=i;u++)r.push(u);return d.jsxs("div",{className:"flex items-center justify-center space-x-2 mt-4",children:[d.jsx("button",{onClick:()=>n(e-1),disabled:e===1,className:"px-3 py-1 rounded border disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),o>1&&d.jsxs(d.Fragment,{children:[d.jsx("button",{onClick:()=>n(1),className:"px-3 py-1 rounded border",children:"1"}),o>2&&d.jsx("span",{className:"px-2",children:"..."})]}),r.map(u=>d.jsx("button",{onClick:()=>n(u),className:`px-3 py-1 rounded border ${u===e?"bg-blue-500 text-white":""}`,children:u},u)),i<t&&d.jsxs(d.Fragment,{children:[i<t-1&&d.jsx("span",{className:"px-2",children:"..."}),d.jsx("button",{onClick:()=>n(t),className:"px-3 py-1 rounded border",children:t})]}),d.jsx("button",{onClick:()=>n(e+1),disabled:e===t,className:"px-3 py-1 rounded border disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})}function Bh(){const[e]=lu(),[t,n]=k.useState({page:1,pageSize:25,sortBy:"timestamp",sortOrder:"desc"}),{records:r,total:l,loading:o,error:i,silentRefetch:u}=Mh(t),s=Math.ceil(l/t.pageSize),a=k.useRef(null),[m,p]=k.useState(!1),[v,w]=k.useState(!1),g=async()=>{if(!v){w(!0);return}p(!0);try{await Dh(),u(),w(!1)}catch(y){console.error("Failed to delete records:",y),alert("Failed to delete records. Please try again.")}finally{p(!1)}};return k.useEffect(()=>(a.current&&clearInterval(a.current),a.current=setInterval(()=>{u()},5e3),()=>{a.current&&clearInterval(a.current)}),[t]),d.jsx("div",{className:`min-h-screen ${e==="dark"?"bg-gray-900 text-white":"bg-white text-gray-900"}`,children:d.jsxs("div",{className:"container mx-auto px-4 py-8",children:[d.jsxs("div",{className:"flex justify-between items-center mb-6",children:[d.jsx("h1",{className:"text-3xl font-bold",children:"RequestScope Dashboard"}),d.jsx("button",{onClick:g,disabled:m,className:`flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors ${v?"bg-red-600 text-white hover:bg-red-700":"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-900/50"} ${m?"opacity-50 cursor-not-allowed":""}`,children:m?d.jsxs(d.Fragment,{children:[d.jsxs("svg",{className:"w-5 h-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[d.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),d.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Deleting..."]}):v?d.jsxs(d.Fragment,{children:[d.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Confirm Delete"]}):d.jsxs(d.Fragment,{children:[d.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),"Delete All"]})})]}),d.jsx(Uh,{filters:t,onFiltersChange:n}),i&&d.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4",children:i}),o?d.jsx("div",{className:"text-center py-8",children:"Loading..."}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"mb-4 text-sm text-gray-600 dark:text-gray-400",children:["Total: ",l," records"]}),d.jsx("div",{className:"overflow-x-auto",children:d.jsxs("table",{className:"min-w-full border-collapse bg-white dark:bg-gray-800 rounded-lg shadow-sm overflow-hidden",children:[d.jsx("thead",{children:d.jsxs("tr",{className:"bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:[d.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"Method"}),d.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"URL"}),d.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"Status"}),d.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"Time"}),d.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"Timestamp"})]})}),d.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:r.map(y=>d.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[d.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:d.jsx(Xc,{method:y.method})}),d.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:d.jsx(li,{to:`/${y.id}`,className:"text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 font-medium",children:y.url})}),d.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:d.jsx(Jc,{statusCode:y.statusCode})}),d.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white font-mono",children:[y.responseTime.toFixed(2),"ms"]}),d.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white",children:new Date(y.timestamp).toLocaleString("en-GB",{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})})]},y.id))})]})}),s>1&&d.jsx($h,{currentPage:t.page,totalPages:s,onPageChange:y=>n({...t,page:y})})]})]})})}function Pr({data:e}){const[t,n]=k.useState(!1),[r,l]=k.useState(!1);let o;if(typeof e=="string")try{const u=JSON.parse(e);o=JSON.stringify(u,null,2)}catch{o=e}else o=JSON.stringify(e,null,2);const i=async()=>{await navigator.clipboard.writeText(o),l(!0),setTimeout(()=>l(!1),2e3)};return d.jsx("div",{className:"json-viewer",children:d.jsxs("div",{className:"relative",children:[d.jsx("pre",{className:`bg-gray-900 text-gray-100 p-4 rounded-lg overflow-x-auto text-sm font-mono whitespace-pre-wrap break-words ${t?"":"max-h-96"}`,children:o||"null"}),d.jsxs("div",{className:"absolute top-2 right-2 flex gap-2",children:[o.length>200&&d.jsx("button",{onClick:()=>n(!t),className:"bg-gray-700 hover:bg-gray-600 text-white px-2 py-1 rounded text-xs transition-colors",children:t?"Collapse":"Expand"}),d.jsx("button",{onClick:i,className:"bg-gray-700 hover:bg-gray-600 text-white px-2 py-1 rounded text-xs transition-colors flex items-center gap-1",children:r?d.jsxs(d.Fragment,{children:[d.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Copied"]}):d.jsxs(d.Fragment,{children:[d.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})}),"Copy"]})})]})]})})}function Cs({tabs:e}){const[t,n]=k.useState(0);return d.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700",children:[d.jsx("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:e.map((r,l)=>d.jsx("button",{onClick:()=>n(l),className:`px-6 py-3 text-sm font-medium transition-colors ${t===l?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-50 dark:hover:bg-gray-700"}`,children:r.label},r.label))}),d.jsx("div",{className:"p-4",children:e[t].content})]})}function Ah(){const{id:e}=lh(),[t]=lu(),[n,r]=k.useState(null),[l,o]=k.useState(!0),[i,u]=k.useState(null);if(k.useEffect(()=>{e&&(o(!0),u(null),Oh(e).then(a=>{r(a)}).catch(a=>{u(a instanceof Error?a.message:"Failed to fetch record")}).finally(()=>{o(!1)}))},[e]),l)return d.jsx("div",{className:`min-h-screen ${t==="dark"?"bg-gray-900 text-white":"bg-white text-gray-900"}`,children:d.jsx("div",{className:"container mx-auto px-4 py-8",children:d.jsx("div",{className:"text-center py-8",children:"Loading..."})})});if(i||!n)return d.jsx("div",{className:`min-h-screen ${t==="dark"?"bg-gray-900 text-white":"bg-white text-gray-900"}`,children:d.jsxs("div",{className:"container mx-auto px-4 py-8",children:[d.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded",children:i||"Record not found"}),d.jsx(li,{to:"/",className:"mt-4 inline-block text-blue-500 hover:underline",children:"Back to list"})]})});const s=a=>{const m=new Date(a),v=new Date().getTime()-m.getTime(),w=Math.floor(v/(1e3*60*60)),g=w>0?`${w}h ago`:"Just now";return`${m.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})}, ${m.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"})} (${g})`};return d.jsx("div",{className:`min-h-screen ${t==="dark"?"bg-gray-900 text-white":"bg-gray-50 text-gray-900"}`,children:d.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-7xl",children:[d.jsxs(li,{to:"/",className:"inline-flex items-center mb-8 text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300 transition-colors",children:[d.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back to list"]}),d.jsx("div",{className:"flex justify-between items-center mb-8",children:d.jsx("div",{children:d.jsx("h1",{className:"text-3xl font-bold text-black",children:"Request Details"})})}),d.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 mb-8",children:[d.jsx("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:d.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Request Details"})}),d.jsx("div",{className:"p-6",children:d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Time"}),d.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:s(n.timestamp)})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Method"}),d.jsx(Xc,{method:n.method})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Path"}),d.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:n.url})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Status"}),d.jsx(Jc,{statusCode:n.statusCode})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Duration"}),d.jsxs("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:[n.responseTime.toFixed(2)," ms"]})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"IP Address"}),d.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:n.clientIp})]}),n.route&&d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Route"}),d.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:n.route})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Request Size"}),d.jsxs("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:[n.requestBodySize.toLocaleString()," bytes"]})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Response Size"}),d.jsxs("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:[n.responseBodySize.toLocaleString()," bytes"]})]})]})})]}),d.jsxs("div",{className:"space-y-8",children:[d.jsxs("div",{children:[d.jsx("h3",{className:"text-lg font-semibold text-black mb-4",children:"Payload"}),d.jsx(Cs,{tabs:[{label:"Payload",content:d.jsx(Pr,{data:n.requestBody})},{label:"Headers",content:d.jsx(Pr,{data:n.requestHeaders})}]})]}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-lg font-semibold text-black mb-4",children:"Response"}),d.jsx(Cs,{tabs:[{label:"Response",content:d.jsx(Pr,{data:n.responseBody})},{label:"Headers",content:d.jsx(Pr,{data:n.responseHeaders})}]})]})]}),n.errorMessage&&d.jsxs("div",{className:"mt-8 bg-red-50 dark:bg-red-900/20 rounded-lg shadow-sm border border-red-200 dark:border-red-800",children:[d.jsx("div",{className:"px-6 py-4 border-b border-red-200 dark:border-red-800",children:d.jsx("h3",{className:"text-lg font-semibold text-red-900 dark:text-red-300",children:"Error Information"})}),d.jsxs("div",{className:"p-6 space-y-4",children:[d.jsxs("div",{children:[d.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-400",children:"Message:"}),d.jsx("p",{className:"text-sm text-red-900 dark:text-red-300 mt-1",children:n.errorMessage})]}),n.errorStack&&d.jsxs("div",{children:[d.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-400",children:"Stack Trace:"}),d.jsx("pre",{className:"text-xs text-red-900 dark:text-red-300 mt-1 overflow-x-auto bg-red-100 dark:bg-red-900/30 p-3 rounded",children:n.errorStack})]})]})]})]})})}function Vh(){const[e]=lu();return d.jsx("div",{className:`app ${e}`,children:d.jsx(Ph,{children:d.jsxs(kh,{children:[d.jsx(Ar,{path:"/",element:d.jsx(Bh,{})}),d.jsx(Ar,{path:"/:id",element:d.jsx(Ah,{})}),d.jsx(Ar,{path:"*",element:d.jsx(xh,{to:"/",replace:!0})})]})})})}uo.createRoot(document.getElementById("root")).render(d.jsx(Ms.StrictMode,{children:d.jsx(Vh,{})}));
|
|
67
|
+
*/function ri(){return ri=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ri.apply(null,arguments)}function Sh(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Eh(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ch(e,t){return e.button===0&&(!t||t==="_self")&&!Eh(e)}const Nh=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],jh="6";try{window.__reactRouterVersion=jh}catch{}const _h="startTransition",ks=vf[_h];function Ph(e){let{basename:t,children:n,future:r,window:l}=e,o=k.useRef();o.current==null&&(o.current=Pp({window:l,v5Compat:!0}));let i=o.current,[u,s]=k.useState({action:i.action,location:i.location}),{v7_startTransition:a}=r||{},m=k.useCallback(p=>{a&&ks?ks(()=>s(p)):s(p)},[s,a]);return k.useLayoutEffect(()=>i.listen(m),[i,m]),k.useEffect(()=>yh(r),[r]),k.createElement(wh,{basename:t,children:n,location:u.location,navigationType:u.action,navigator:i,future:r})}const Lh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Th=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,li=k.forwardRef(function(t,n){let{onClick:r,relative:l,reloadDocument:o,replace:i,state:u,target:s,to:a,preventScrollReset:m,viewTransition:p}=t,v=Sh(t,Nh),{basename:w}=k.useContext(wt),g,y=!1;if(typeof a=="string"&&Th.test(a)&&(g=a,Lh))try{let h=new URL(window.location.href),x=a.startsWith("//")?new URL(h.protocol+a):new URL(a),C=bi(x.pathname,w);x.origin===h.origin&&C!=null?a=C+x.search+x.hash:y=!0}catch{}let E=nh(a,{relative:l}),f=Rh(a,{replace:i,state:u,target:s,preventScrollReset:m,relative:l,viewTransition:p});function c(h){r&&r(h),h.defaultPrevented||f(h)}return k.createElement("a",ri({},v,{href:g||E,onClick:y||o?r:c,ref:n,target:s}))});var Ss;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Ss||(Ss={}));var Es;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Es||(Es={}));function Rh(e,t){let{target:n,replace:r,state:l,preventScrollReset:o,relative:i,viewTransition:u}=t===void 0?{}:t,s=Hc(),a=sr(),m=Qc(e,{relative:i});return k.useCallback(p=>{if(Ch(p,n)){p.preventDefault();let v=r!==void 0?r:dl(a)===dl(m);s(e,{replace:v,state:l,preventScrollReset:o,relative:i,viewTransition:u})}},[a,s,m,r,l,n,e,o,i,u])}const ru="/requestscope/api";async function zh(e){const t=new URLSearchParams;e.search&&t.set("search",e.search),e.startDate&&t.set("startDate",e.startDate),e.endDate&&t.set("endDate",e.endDate),e.statusCodeGroup&&t.set("statusCodeGroup",e.statusCodeGroup),e.statusCode&&t.set("statusCode",e.statusCode.toString()),e.method&&t.set("method",e.method),e.sortBy&&t.set("sortBy",e.sortBy),e.sortOrder&&t.set("sortOrder",e.sortOrder),t.set("page",e.page.toString()),t.set("pageSize",e.pageSize.toString());const n=await fetch(`${ru}/records?${t.toString()}`);if(!n.ok)throw new Error(`Failed to fetch records: ${n.statusText}`);return n.json()}async function Oh(e){const t=await fetch(`${ru}/records/${e}`);if(!t.ok)throw new Error(`Failed to fetch record: ${t.statusText}`);return t.json()}async function Dh(){const e=await fetch(`${ru}/records`,{method:"DELETE"});if(!e.ok)throw new Error(`Failed to delete records: ${e.statusText}`);return e.json()}function Mh(e){const[t,n]=k.useState([]),[r,l]=k.useState(0),[o,i]=k.useState(!1),[u,s]=k.useState(null),a=k.useCallback((m=!0)=>{m&&i(!0),s(null),zh(e).then(p=>{n(p.records),l(p.total)}).catch(p=>{s(p instanceof Error?p.message:"Failed to fetch records")}).finally(()=>{m&&i(!1)})},[e]);return k.useEffect(()=>{a(!0)},[a]),{records:t,total:r,loading:o,error:u,refetch:()=>a(!0),silentRefetch:()=>a(!1)}}function lu(){const[e,t]=k.useState(()=>localStorage.getItem("requestscope-theme")||"light");return k.useEffect(()=>{localStorage.setItem("requestscope-theme",e),document.documentElement.className=e},[e]),[e,t]}const Ih={GET:"bg-green-100 text-green-800",POST:"bg-blue-100 text-blue-800",PUT:"bg-yellow-100 text-yellow-800",DELETE:"bg-red-100 text-red-800",PATCH:"bg-purple-100 text-purple-800"};function Xc({method:e}){const t=Ih[e]||"bg-gray-100 text-gray-800";return d.jsx("span",{className:`px-2 py-1 rounded text-xs font-mono font-bold ${t}`,children:e})}const Fh=e=>e>=200&&e<300?"bg-green-100 text-green-800":e>=300&&e<400?"bg-blue-100 text-blue-800":e>=400&&e<500?"bg-yellow-100 text-yellow-800":e>=500?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800";function Jc({statusCode:e}){const t=Fh(e);return d.jsx("span",{className:`px-2 py-1 rounded text-xs font-mono font-bold ${t}`,children:e})}function Uh({filters:e,onFiltersChange:t}){const[n,r]=k.useState(e.search||""),[l,o]=k.useState(e.method||""),[i,u]=k.useState(e.statusCodeGroup||""),[s,a]=k.useState(e.startDate||""),[m,p]=k.useState(e.endDate||""),v=()=>{let g,y;if(s&&(g=new Date(s).toISOString()),m){const E=new Date(m);E.setHours(23,59,59,999),y=E.toISOString()}t({...e,search:n||void 0,method:l||void 0,statusCodeGroup:i||void 0,startDate:g,endDate:y})},w=()=>{r(""),o(""),u(""),a(""),p(""),t({...e,search:void 0,method:void 0,statusCodeGroup:void 0,startDate:void 0,endDate:void 0})};return d.jsxs("div",{className:"bg-white dark:bg-gray-800 p-6 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 mb-6",children:[d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-4",children:[d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Search URL"}),d.jsx("input",{type:"text",value:n,onChange:g=>r(g.target.value),className:"w-full px-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 transition-colors",placeholder:"Search..."})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Method"}),d.jsxs("select",{value:l,onChange:g=>o(g.target.value),className:"w-full px-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-white transition-colors",children:[d.jsx("option",{value:"",children:"All"}),d.jsx("option",{value:"GET",children:"GET"}),d.jsx("option",{value:"POST",children:"POST"}),d.jsx("option",{value:"PUT",children:"PUT"}),d.jsx("option",{value:"DELETE",children:"DELETE"}),d.jsx("option",{value:"PATCH",children:"PATCH"})]})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Status"}),d.jsxs("select",{value:i,onChange:g=>u(g.target.value),className:"w-full px-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-white transition-colors",children:[d.jsx("option",{value:"",children:"All"}),d.jsx("option",{value:"2xx",children:"2xx"}),d.jsx("option",{value:"3xx",children:"3xx"}),d.jsx("option",{value:"4xx",children:"4xx"}),d.jsx("option",{value:"5xx",children:"5xx"})]})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Start Date"}),d.jsx("input",{type:"date",value:s,onChange:g=>a(g.target.value),className:"w-full px-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-white transition-colors"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"End Date"}),d.jsx("input",{type:"date",value:m,onChange:g=>p(g.target.value),className:"w-full px-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-white transition-colors"})]})]}),d.jsxs("div",{className:"flex space-x-3 mt-6",children:[d.jsx("button",{onClick:v,className:"px-6 py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors font-medium",children:"Apply Filters"}),d.jsx("button",{onClick:w,className:"px-6 py-2.5 bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-300 dark:hover:bg-gray-600 focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 transition-colors font-medium",children:"Reset"})]})]})}function $h({currentPage:e,totalPages:t,onPageChange:n}){const r=[];let o=Math.max(1,e-Math.floor(2.5)),i=Math.min(t,o+5-1);i-o<4&&(o=Math.max(1,i-5+1));for(let u=o;u<=i;u++)r.push(u);return d.jsxs("div",{className:"flex items-center justify-center space-x-2 mt-4",children:[d.jsx("button",{onClick:()=>n(e-1),disabled:e===1,className:"px-3 py-1 rounded border disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),o>1&&d.jsxs(d.Fragment,{children:[d.jsx("button",{onClick:()=>n(1),className:"px-3 py-1 rounded border",children:"1"}),o>2&&d.jsx("span",{className:"px-2",children:"..."})]}),r.map(u=>d.jsx("button",{onClick:()=>n(u),className:`px-3 py-1 rounded border ${u===e?"bg-blue-500 text-white":""}`,children:u},u)),i<t&&d.jsxs(d.Fragment,{children:[i<t-1&&d.jsx("span",{className:"px-2",children:"..."}),d.jsx("button",{onClick:()=>n(t),className:"px-3 py-1 rounded border",children:t})]}),d.jsx("button",{onClick:()=>n(e+1),disabled:e===t,className:"px-3 py-1 rounded border disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})}function Bh(){const[e]=lu(),[t,n]=k.useState({page:1,pageSize:25,sortBy:"timestamp",sortOrder:"desc"}),{records:r,total:l,loading:o,error:i,silentRefetch:u}=Mh(t),s=Math.ceil(l/t.pageSize),a=k.useRef(null),[m,p]=k.useState(!1),[v,w]=k.useState(!1),g=async()=>{if(!v){w(!0);return}p(!0);try{await Dh(),u(),w(!1)}catch(y){console.error("Failed to delete records:",y),alert("Failed to delete records. Please try again.")}finally{p(!1)}};return k.useEffect(()=>(a.current&&clearInterval(a.current),a.current=setInterval(()=>{u()},5e3),()=>{a.current&&clearInterval(a.current)}),[t]),d.jsx("div",{className:`min-h-screen ${e==="dark"?"bg-gray-900 text-white":"bg-white text-gray-900"}`,children:d.jsxs("div",{className:"container mx-auto px-4 py-8",children:[d.jsxs("div",{className:"flex justify-between items-center mb-6",children:[d.jsx("h1",{className:"text-3xl font-bold",children:"RequestScope Dashboard"}),d.jsx("button",{onClick:g,disabled:m,className:`flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors ${v?"bg-red-600 text-white hover:bg-red-700":"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-900/50"} ${m?"opacity-50 cursor-not-allowed":""}`,children:m?d.jsxs(d.Fragment,{children:[d.jsxs("svg",{className:"w-5 h-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[d.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),d.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Deleting..."]}):v?d.jsxs(d.Fragment,{children:[d.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Confirm Delete"]}):d.jsxs(d.Fragment,{children:[d.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),"Delete All"]})})]}),d.jsx(Uh,{filters:t,onFiltersChange:n}),i&&d.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4",children:i}),o?d.jsx("div",{className:"text-center py-8",children:"Loading..."}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"mb-4 text-sm text-gray-600 dark:text-gray-400",children:["Total: ",l," records"]}),d.jsx("div",{className:"overflow-x-auto",children:d.jsxs("table",{className:"min-w-full border-collapse bg-white dark:bg-gray-800 rounded-lg shadow-sm overflow-hidden",children:[d.jsx("thead",{children:d.jsxs("tr",{className:"bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600",children:[d.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"Method"}),d.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"URL"}),d.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"Status"}),d.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"Time"}),d.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"Timestamp"})]})}),d.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:r.map(y=>d.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[d.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:d.jsx(Xc,{method:y.method})}),d.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:d.jsx(li,{to:`/${y.id}`,className:"text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 font-medium",children:y.url})}),d.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:d.jsx(Jc,{statusCode:y.statusCode})}),d.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white font-mono",children:[y.responseTime.toFixed(2),"ms"]}),d.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white",children:new Date(y.timestamp).toLocaleString("en-GB",{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})})]},y.id))})]})}),s>1&&d.jsx($h,{currentPage:t.page,totalPages:s,onPageChange:y=>n({...t,page:y})})]})]})})}function Ah(e){const t=[];let n=-1,r=0,l=!1,o=!1;for(let i=0;i<e.length;i+=1){const u=e[i];if(n===-1){if(/\s/.test(u))continue;if(u!=="{"&&u!=="[")return null;n=i,r=1;continue}if(l){o?o=!1:u==="\\"?o=!0:u==='"'&&(l=!1);continue}if(u==='"')l=!0;else if(u==="{"||u==="[")r+=1;else if((u==="}"||u==="]")&&(r-=1,r===0)){try{t.push(JSON.parse(e.slice(n,i+1)))}catch{return null}n=-1}}return n===-1&&t.length>1?t:null}function Pr({data:e}){const[t,n]=k.useState(!1),[r,l]=k.useState(!1);let o;if(typeof e=="string")try{const u=JSON.parse(e);o=JSON.stringify(u,null,2)}catch{const u=Ah(e);o=u?JSON.stringify(u,null,2):e}else o=JSON.stringify(e,null,2);const i=async()=>{await navigator.clipboard.writeText(o),l(!0),setTimeout(()=>l(!1),2e3)};return d.jsx("div",{className:"json-viewer",children:d.jsxs("div",{className:"relative",children:[d.jsx("pre",{className:`bg-gray-900 text-gray-100 p-4 rounded-lg overflow-x-auto text-sm font-mono whitespace-pre-wrap break-words ${t?"":"max-h-96"}`,children:o||"null"}),d.jsxs("div",{className:"absolute top-2 right-2 flex gap-2",children:[o.length>200&&d.jsx("button",{onClick:()=>n(!t),className:"bg-gray-700 hover:bg-gray-600 text-white px-2 py-1 rounded text-xs transition-colors",children:t?"Collapse":"Expand"}),d.jsx("button",{onClick:i,className:"bg-gray-700 hover:bg-gray-600 text-white px-2 py-1 rounded text-xs transition-colors flex items-center gap-1",children:r?d.jsxs(d.Fragment,{children:[d.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Copied"]}):d.jsxs(d.Fragment,{children:[d.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})}),"Copy"]})})]})]})})}function Cs({tabs:e}){const[t,n]=k.useState(0);return d.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700",children:[d.jsx("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:e.map((r,l)=>d.jsx("button",{onClick:()=>n(l),className:`px-6 py-3 text-sm font-medium transition-colors ${t===l?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-50 dark:hover:bg-gray-700"}`,children:r.label},r.label))}),d.jsx("div",{className:"p-4",children:e[t].content})]})}function Vh(){const{id:e}=lh(),[t]=lu(),[n,r]=k.useState(null),[l,o]=k.useState(!0),[i,u]=k.useState(null);if(k.useEffect(()=>{e&&(o(!0),u(null),Oh(e).then(a=>{r(a)}).catch(a=>{u(a instanceof Error?a.message:"Failed to fetch record")}).finally(()=>{o(!1)}))},[e]),l)return d.jsx("div",{className:`min-h-screen ${t==="dark"?"bg-gray-900 text-white":"bg-white text-gray-900"}`,children:d.jsx("div",{className:"container mx-auto px-4 py-8",children:d.jsx("div",{className:"text-center py-8",children:"Loading..."})})});if(i||!n)return d.jsx("div",{className:`min-h-screen ${t==="dark"?"bg-gray-900 text-white":"bg-white text-gray-900"}`,children:d.jsxs("div",{className:"container mx-auto px-4 py-8",children:[d.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded",children:i||"Record not found"}),d.jsx(li,{to:"/",className:"mt-4 inline-block text-blue-500 hover:underline",children:"Back to list"})]})});const s=a=>{const m=new Date(a),v=new Date().getTime()-m.getTime(),w=Math.floor(v/(1e3*60*60)),g=w>0?`${w}h ago`:"Just now";return`${m.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})}, ${m.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"})} (${g})`};return d.jsx("div",{className:`min-h-screen ${t==="dark"?"bg-gray-900 text-white":"bg-gray-50 text-gray-900"}`,children:d.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-7xl",children:[d.jsxs(li,{to:"/",className:"inline-flex items-center mb-8 text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300 transition-colors",children:[d.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back to list"]}),d.jsx("div",{className:"flex justify-between items-center mb-8",children:d.jsx("div",{children:d.jsx("h1",{className:"text-3xl font-bold text-black",children:"Request Details"})})}),d.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 mb-8",children:[d.jsx("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:d.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Request Details"})}),d.jsx("div",{className:"p-6",children:d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Time"}),d.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:s(n.timestamp)})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Method"}),d.jsx(Xc,{method:n.method})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Path"}),d.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:n.url})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Status"}),d.jsx(Jc,{statusCode:n.statusCode})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Duration"}),d.jsxs("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:[n.responseTime.toFixed(2)," ms"]})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"IP Address"}),d.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:n.clientIp})]}),n.route&&d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Route"}),d.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:n.route})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Request Size"}),d.jsxs("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:[n.requestBodySize.toLocaleString()," bytes"]})]}),d.jsxs("div",{className:"flex items-start",children:[d.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-400 w-32 flex-shrink-0",children:"Response Size"}),d.jsxs("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:[n.responseBodySize.toLocaleString()," bytes"]})]})]})})]}),d.jsxs("div",{className:"space-y-8",children:[d.jsxs("div",{children:[d.jsx("h3",{className:"text-lg font-semibold text-black mb-4",children:"Payload"}),d.jsx(Cs,{tabs:[{label:"Payload",content:d.jsx(Pr,{data:n.requestBody})},{label:"Headers",content:d.jsx(Pr,{data:n.requestHeaders})}]})]}),d.jsxs("div",{children:[d.jsx("h3",{className:"text-lg font-semibold text-black mb-4",children:"Response"}),d.jsx(Cs,{tabs:[{label:"Response",content:d.jsx(Pr,{data:n.responseBody})},{label:"Headers",content:d.jsx(Pr,{data:n.responseHeaders})}]})]})]}),n.errorMessage&&d.jsxs("div",{className:"mt-8 bg-red-50 dark:bg-red-900/20 rounded-lg shadow-sm border border-red-200 dark:border-red-800",children:[d.jsx("div",{className:"px-6 py-4 border-b border-red-200 dark:border-red-800",children:d.jsx("h3",{className:"text-lg font-semibold text-red-900 dark:text-red-300",children:"Error Information"})}),d.jsxs("div",{className:"p-6 space-y-4",children:[d.jsxs("div",{children:[d.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-400",children:"Message:"}),d.jsx("p",{className:"text-sm text-red-900 dark:text-red-300 mt-1",children:n.errorMessage})]}),n.errorStack&&d.jsxs("div",{children:[d.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-400",children:"Stack Trace:"}),d.jsx("pre",{className:"text-xs text-red-900 dark:text-red-300 mt-1 overflow-x-auto bg-red-100 dark:bg-red-900/30 p-3 rounded",children:n.errorStack})]})]})]})]})})}function Wh(){const[e]=lu();return d.jsx("div",{className:`app ${e}`,children:d.jsx(Ph,{children:d.jsxs(kh,{children:[d.jsx(Ar,{path:"/",element:d.jsx(Bh,{})}),d.jsx(Ar,{path:"/:id",element:d.jsx(Vh,{})}),d.jsx(Ar,{path:"*",element:d.jsx(xh,{to:"/",replace:!0})})]})})})}uo.createRoot(document.getElementById("root")).render(d.jsx(Ms.StrictMode,{children:d.jsx(Wh,{})}));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>RequestScope Dashboard</title>
|
|
7
|
-
<script type="module" crossorigin src="/requestscope/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/requestscope/assets/index-AJRkt_xG.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/requestscope/assets/index-COYPzzrh.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/dist/esm/capture.js
CHANGED
|
@@ -238,27 +238,6 @@ export function wrapResponse(res, req, requestBody, requestBodySize, clientIp, s
|
|
|
238
238
|
}
|
|
239
239
|
originalEnd.call(this, chunk, encoding, cb);
|
|
240
240
|
};
|
|
241
|
-
// Patch Express-specific methods that might bypass res.write/res.end
|
|
242
|
-
const expressRes = res;
|
|
243
|
-
if (expressRes.send) {
|
|
244
|
-
const originalSend = expressRes.send;
|
|
245
|
-
expressRes.send = function (body) {
|
|
246
|
-
// Capture the body before sending
|
|
247
|
-
if (body !== undefined) {
|
|
248
|
-
const str = typeof body === 'string' ? body : JSON.stringify(body);
|
|
249
|
-
accumulateChunk(str, 'utf8');
|
|
250
|
-
}
|
|
251
|
-
return originalSend.call(this, body);
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
if (expressRes.json) {
|
|
255
|
-
const originalJson = expressRes.json;
|
|
256
|
-
expressRes.json = function (obj) {
|
|
257
|
-
const str = JSON.stringify(obj);
|
|
258
|
-
accumulateChunk(str, 'utf8');
|
|
259
|
-
return originalJson.call(this, obj);
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
241
|
// Listen for finish event to build the record
|
|
263
242
|
res.on('finish', () => {
|
|
264
243
|
const endTime = process.hrtime.bigint();
|