fixed 90 day code

This commit is contained in:
Raj Nandan Sharma
2023-12-15 09:42:29 +05:30
parent a431793d13
commit fdfc6b8aa6
26 changed files with 148 additions and 62 deletions

View File

@@ -1 +1 @@
import{w as u}from"./index.addbbfd3.js";var b;const E=((b=globalThis.__sveltekit_1j67nna)==null?void 0:b.base)??"";var h;(h=globalThis.__sveltekit_1j67nna)==null||h.assets;const I="sveltekit:snapshot",x="sveltekit:scroll",O="sveltekit:index",c={tap:1,hover:2,viewport:3,eager:4,off:-1},v=location.origin;function T(e){let t=e.baseURI;if(!t){const n=e.getElementsByTagName("base");t=n.length?n[0].href:e.URL}return t}function U(){return{x:pageXOffset,y:pageYOffset}}const d=new WeakSet,p={"preload-code":["","off","tap","hover","viewport","eager"],"preload-data":["","off","tap","hover"],keepfocus:["","true","off","false"],noscroll:["","true","off","false"],reload:["","true","off","false"],replacestate:["","true","off","false"]};function f(e,t){const n=e.getAttribute(`data-sveltekit-${t}`);return S(e,t,n),n}function S(e,t,n){n!==null&&!d.has(e)&&!p[t].includes(n)&&(console.error(`Unexpected value for ${t} — should be one of ${p[t].map(s=>JSON.stringify(s)).join(", ")}`,e),d.add(e))}const _={...c,"":c.hover};function k(e){let t=e.assignedSlot??e.parentNode;return(t==null?void 0:t.nodeType)===11&&(t=t.host),t}function N(e,t){for(;e&&e!==t;){if(e.nodeName.toUpperCase()==="A"&&e.hasAttribute("href"))return e;e=k(e)}}function L(e,t){let n;try{n=new URL(e instanceof SVGAElement?e.href.baseVal:e.href,document.baseURI)}catch{}const s=e instanceof SVGAElement?e.target.baseVal:e.target,l=!n||!!s||R(n,t)||(e.getAttribute("rel")||"").split(/\s+/).includes("external"),r=(n==null?void 0:n.origin)===v&&e.hasAttribute("download");return{url:n,external:l,target:s,download:r}}function P(e){let t=null,n=null,s=null,l=null,r=null,a=null,o=e;for(;o&&o!==document.documentElement;)s===null&&(s=f(o,"preload-code")),l===null&&(l=f(o,"preload-data")),t===null&&(t=f(o,"keepfocus")),n===null&&(n=f(o,"noscroll")),r===null&&(r=f(o,"reload")),a===null&&(a=f(o,"replacestate")),o=k(o);function i(w){switch(w){case"":case"true":return!0;case"off":case"false":return!1;default:return null}}return{preload_code:_[s??"off"],preload_data:_[l??"off"],keep_focus:i(t),noscroll:i(n),reload:i(r),replace_state:i(a)}}function g(e){const t=u(e);let n=!0;function s(){n=!0,t.update(a=>a)}function l(a){n=!1,t.set(a)}function r(a){let o;return t.subscribe(i=>{(o===void 0||n&&i!==o)&&a(o=i)})}return{notify:s,set:l,subscribe:r}}function A(){const{set:e,subscribe:t}=u(!1);return{subscribe:t,check:async()=>!1}}function R(e,t){return e.origin!==v||!e.pathname.startsWith(t)}function V(e){e.client}const Y={url:g({}),page:g({}),navigating:u(null),updated:A()};export{O as I,c as P,x as S,I as a,L as b,P as c,Y as d,E as e,N as f,T as g,V as h,R as i,v as o,U as s};
import{w as u}from"./index.addbbfd3.js";var b;const E=((b=globalThis.__sveltekit_1cnvd0d)==null?void 0:b.base)??"";var h;(h=globalThis.__sveltekit_1cnvd0d)==null||h.assets;const I="sveltekit:snapshot",x="sveltekit:scroll",O="sveltekit:index",c={tap:1,hover:2,viewport:3,eager:4,off:-1},v=location.origin;function T(e){let t=e.baseURI;if(!t){const o=e.getElementsByTagName("base");t=o.length?o[0].href:e.URL}return t}function U(){return{x:pageXOffset,y:pageYOffset}}const d=new WeakSet,p={"preload-code":["","off","tap","hover","viewport","eager"],"preload-data":["","off","tap","hover"],keepfocus:["","true","off","false"],noscroll:["","true","off","false"],reload:["","true","off","false"],replacestate:["","true","off","false"]};function f(e,t){const o=e.getAttribute(`data-sveltekit-${t}`);return S(e,t,o),o}function S(e,t,o){o!==null&&!d.has(e)&&!p[t].includes(o)&&(console.error(`Unexpected value for ${t} — should be one of ${p[t].map(s=>JSON.stringify(s)).join(", ")}`,e),d.add(e))}const _={...c,"":c.hover};function k(e){let t=e.assignedSlot??e.parentNode;return(t==null?void 0:t.nodeType)===11&&(t=t.host),t}function N(e,t){for(;e&&e!==t;){if(e.nodeName.toUpperCase()==="A"&&e.hasAttribute("href"))return e;e=k(e)}}function L(e,t){let o;try{o=new URL(e instanceof SVGAElement?e.href.baseVal:e.href,document.baseURI)}catch{}const s=e instanceof SVGAElement?e.target.baseVal:e.target,l=!o||!!s||R(o,t)||(e.getAttribute("rel")||"").split(/\s+/).includes("external"),r=(o==null?void 0:o.origin)===v&&e.hasAttribute("download");return{url:o,external:l,target:s,download:r}}function P(e){let t=null,o=null,s=null,l=null,r=null,a=null,n=e;for(;n&&n!==document.documentElement;)s===null&&(s=f(n,"preload-code")),l===null&&(l=f(n,"preload-data")),t===null&&(t=f(n,"keepfocus")),o===null&&(o=f(n,"noscroll")),r===null&&(r=f(n,"reload")),a===null&&(a=f(n,"replacestate")),n=k(n);function i(w){switch(w){case"":case"true":return!0;case"off":case"false":return!1;default:return null}}return{preload_code:_[s??"off"],preload_data:_[l??"off"],keep_focus:i(t),noscroll:i(o),reload:i(r),replace_state:i(a)}}function g(e){const t=u(e);let o=!0;function s(){o=!0,t.update(a=>a)}function l(a){o=!1,t.set(a)}function r(a){let n;return t.subscribe(i=>{(n===void 0||o&&i!==n)&&a(n=i)})}return{notify:s,set:l,subscribe:r}}function A(){const{set:e,subscribe:t}=u(!1);return{subscribe:t,check:async()=>!1}}function R(e,t){return e.origin!==v||!e.pathname.startsWith(t)}function V(e){e.client}const Y={url:g({}),page:g({}),navigating:u(null),updated:A()};export{O as I,c as P,x as S,I as a,L as b,P as c,Y as d,E as e,N as f,T as g,V as h,R as i,v as o,U as s};

View File

@@ -1 +1 @@
import{s as B,B as D,C as O,g as b,l as g,c as R,h as E,i as $,m as w,d as q,k as S,D as k}from"../chunks/scheduler.4b6b5798.js";import{S as H,i as N,d as y,v as P,e as d,a as m,o as C,s as j}from"../chunks/index.7f0074cb.js";import{d as z}from"../chunks/singletons.ff6fb23c.js";const A=()=>{const t=z;return{page:{subscribe:t.page.subscribe},navigating:{subscribe:t.navigating.subscribe},updated:t.updated}},_={subscribe(t){return A().page.subscribe(t)}},x="node_modules/@sveltejs/kit/src/runtime/components/error.svelte";function f(t){var h;let e,i=t[0].status+"",r,l,n,c=((h=t[0].error)==null?void 0:h.message)+"",a;const v={c:function(){e=b("h1"),r=g(i),l=R(),n=b("p"),a=g(c),this.h()},l:function(s){e=E(s,"H1",{});var o=$(e);r=w(o,i),o.forEach(d),l=q(s),n=E(s,"P",{});var p=$(n);a=w(p,c),p.forEach(d),this.h()},h:function(){S(e,x,4,0,57),S(n,x,5,0,81)},m:function(s,o){m(s,e,o),C(e,r),m(s,l,o),m(s,n,o),C(n,a)},p:function(s,[o]){var p;o&1&&i!==(i=s[0].status+"")&&j(r,i),o&1&&c!==(c=((p=s[0].error)==null?void 0:p.message)+"")&&j(a,c)},i:k,o:k,d:function(s){s&&(d(e),d(l),d(n))}};return y("SvelteRegisterBlock",{block:v,id:f.name,type:"component",source:"",ctx:t}),v}function F(t,e,i){let r;D(_,"page"),O(t,_,a=>i(0,r=a));let{$$slots:l={},$$scope:n}=e;P("Error",l,[]);const c=[];return Object.keys(e).forEach(a=>{!~c.indexOf(a)&&a.slice(0,2)!=="$$"&&a!=="slot"&&console.warn(`<Error> was created with unknown prop '${a}'`)}),t.$capture_state=()=>({page:_,$page:r}),[r]}let K=class extends H{constructor(e){super(e),N(this,e,F,f,B,{}),y("SvelteRegisterComponent",{component:this,tagName:"Error",options:e,id:f.name})}};export{K as component};
import{s as B,B as D,C as O,g as b,l as g,c as R,h as E,i as $,m as w,d as q,k as S,D as k}from"../chunks/scheduler.4b6b5798.js";import{S as H,i as N,d as y,v as P,e as d,a as m,o as C,s as j}from"../chunks/index.7f0074cb.js";import{d as z}from"../chunks/singletons.758dd10d.js";const A=()=>{const t=z;return{page:{subscribe:t.page.subscribe},navigating:{subscribe:t.navigating.subscribe},updated:t.updated}},_={subscribe(t){return A().page.subscribe(t)}},x="node_modules/@sveltejs/kit/src/runtime/components/error.svelte";function f(t){var h;let e,i=t[0].status+"",r,l,n,c=((h=t[0].error)==null?void 0:h.message)+"",a;const v={c:function(){e=b("h1"),r=g(i),l=R(),n=b("p"),a=g(c),this.h()},l:function(s){e=E(s,"H1",{});var o=$(e);r=w(o,i),o.forEach(d),l=q(s),n=E(s,"P",{});var p=$(n);a=w(p,c),p.forEach(d),this.h()},h:function(){S(e,x,4,0,57),S(n,x,5,0,81)},m:function(s,o){m(s,e,o),C(e,r),m(s,l,o),m(s,n,o),C(n,a)},p:function(s,[o]){var p;o&1&&i!==(i=s[0].status+"")&&j(r,i),o&1&&c!==(c=((p=s[0].error)==null?void 0:p.message)+"")&&j(a,c)},i:k,o:k,d:function(s){s&&(d(e),d(l),d(n))}};return y("SvelteRegisterBlock",{block:v,id:f.name,type:"component",source:"",ctx:t}),v}function F(t,e,i){let r;D(_,"page"),O(t,_,a=>i(0,r=a));let{$$slots:l={},$$scope:n}=e;P("Error",l,[]);const c=[];return Object.keys(e).forEach(a=>{!~c.indexOf(a)&&a.slice(0,2)!=="$$"&&a!=="slot"&&console.warn(`<Error> was created with unknown prop '${a}'`)}),t.$capture_state=()=>({page:_,$page:r}),[r]}let K=class extends H{constructor(e){super(e),N(this,e,F,f,B,{}),y("SvelteRegisterComponent",{component:this,tagName:"Error",options:e,id:f.name})}};export{K as component};

View File

@@ -1 +1 @@
{"version":"1702491155794"}
{"version":"1702613492667"}

View File

@@ -1,9 +1,9 @@
const index = 1;
let component_cache;
const component = async () => component_cache ??= (await import('./error.svelte-da5d7deb.js')).default;
const imports = ["_app/immutable/nodes/1.75a4e9e9.js","_app/immutable/chunks/scheduler.4b6b5798.js","_app/immutable/chunks/index.7f0074cb.js","_app/immutable/chunks/singletons.ff6fb23c.js","_app/immutable/chunks/index.addbbfd3.js"];
const imports = ["_app/immutable/nodes/1.b0fef6e1.js","_app/immutable/chunks/scheduler.4b6b5798.js","_app/immutable/chunks/index.7f0074cb.js","_app/immutable/chunks/singletons.758dd10d.js","_app/immutable/chunks/index.addbbfd3.js"];
const stylesheets = [];
const fonts = [];
export { component, fonts, imports, index, stylesheets };
//# sourceMappingURL=1-bdc90f37.js.map
//# sourceMappingURL=1-437b1c00.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"1-bdc90f37.js","sources":["../../../.svelte-kit/adapter-node/nodes/1.js"],"sourcesContent":["\n\nexport const index = 1;\nlet component_cache;\nexport const component = async () => component_cache ??= (await import('../entries/fallbacks/error.svelte.js')).default;\nexport const imports = [\"_app/immutable/nodes/1.75a4e9e9.js\",\"_app/immutable/chunks/scheduler.4b6b5798.js\",\"_app/immutable/chunks/index.7f0074cb.js\",\"_app/immutable/chunks/singletons.ff6fb23c.js\",\"_app/immutable/chunks/index.addbbfd3.js\"];\nexport const stylesheets = [];\nexport const fonts = [];\n"],"names":[],"mappings":"AAEY,MAAC,KAAK,GAAG,EAAE;AACvB,IAAI,eAAe,CAAC;AACR,MAAC,SAAS,GAAG,YAAY,eAAe,KAAK,CAAC,MAAM,OAAO,4BAAsC,CAAC,EAAE,QAAQ;AAC5G,MAAC,OAAO,GAAG,CAAC,oCAAoC,CAAC,6CAA6C,CAAC,yCAAyC,CAAC,8CAA8C,CAAC,yCAAyC,EAAE;AACnO,MAAC,WAAW,GAAG,GAAG;AAClB,MAAC,KAAK,GAAG;;;;"}
{"version":3,"file":"1-437b1c00.js","sources":["../../../.svelte-kit/adapter-node/nodes/1.js"],"sourcesContent":["\n\nexport const index = 1;\nlet component_cache;\nexport const component = async () => component_cache ??= (await import('../entries/fallbacks/error.svelte.js')).default;\nexport const imports = [\"_app/immutable/nodes/1.b0fef6e1.js\",\"_app/immutable/chunks/scheduler.4b6b5798.js\",\"_app/immutable/chunks/index.7f0074cb.js\",\"_app/immutable/chunks/singletons.758dd10d.js\",\"_app/immutable/chunks/index.addbbfd3.js\"];\nexport const stylesheets = [];\nexport const fonts = [];\n"],"names":[],"mappings":"AAEY,MAAC,KAAK,GAAG,EAAE;AACvB,IAAI,eAAe,CAAC;AACR,MAAC,SAAS,GAAG,YAAY,eAAe,KAAK,CAAC,MAAM,OAAO,4BAAsC,CAAC,EAAE,QAAQ;AAC5G,MAAC,OAAO,GAAG,CAAC,oCAAoC,CAAC,6CAA6C,CAAC,yCAAyC,CAAC,8CAA8C,CAAC,yCAAyC,EAAE;AACnO,MAAC,WAAW,GAAG,GAAG;AAClB,MAAC,KAAK,GAAG;;;;"}

View File

@@ -59,12 +59,12 @@ var _page_server = /*#__PURE__*/Object.freeze({
const index = 4;
let component_cache;
const component = async () => component_cache ??= (await import('./_page.svelte-2946da1d.js')).default;
const component = async () => component_cache ??= (await import('./_page.svelte-c0d02f91.js')).default;
const universal_id = "src/routes/incident/[id]/+page.js";
const server_id = "src/routes/incident/[id]/+page.server.js";
const imports = ["_app/immutable/nodes/4.a8ec1f93.js","_app/immutable/chunks/scheduler.4b6b5798.js","_app/immutable/chunks/index.7f0074cb.js","_app/immutable/chunks/separator.dedbaf4a.js","_app/immutable/chunks/index.df12faee.js","_app/immutable/chunks/index.addbbfd3.js"];
const imports = ["_app/immutable/nodes/4.5b0aeb45.js","_app/immutable/chunks/scheduler.4b6b5798.js","_app/immutable/chunks/index.7f0074cb.js","_app/immutable/chunks/separator.dedbaf4a.js","_app/immutable/chunks/index.df12faee.js","_app/immutable/chunks/index.addbbfd3.js"];
const stylesheets = [];
const fonts = [];
export { component, fonts, imports, index, _page_server as server, server_id, stylesheets, _page as universal, universal_id };
//# sourceMappingURL=4-33610416.js.map
//# sourceMappingURL=4-94a2f261.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -358,7 +358,7 @@ const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => {
}
})} ${validate_component(Card_content, "Card.Content").$$render($$result, {}, {}, {
default: () => {
return `<div class="prose prose-stone dark:prose-invert max-w-none prose-code:bg-gray-200 prose-code:px-[0.3rem] prose-code:py-[0.2rem] prose-code:font-mono prose-code:text-sm prose-code:rounded"><!-- HTML_TAG_START -->${incident.body}<!-- HTML_TAG_END --></div> ${incident.comments.length > 0 ? `<div class="ml-4 mt-8"><ol class="relative border-s border-secondary">${each(incident.comments, (comment) => {
return `<div class="prose prose-stone dark:prose-invert max-w-none prose-code:px-[0.3rem] prose-code:py-[0.2rem] prose-code:font-mono prose-code:text-sm prose-code:rounded"><!-- HTML_TAG_START -->${incident.body}<!-- HTML_TAG_END --></div> ${incident.comments.length > 0 ? `<div class="ml-4 mt-8"><ol class="relative border-s border-secondary">${each(incident.comments, (comment) => {
return `<li class="mb-10 ms-4"><div class="absolute w-3 h-3 rounded-full mt-1.5 -start-1.5 border bg-secondary border-secondary"></div> <time class="mb-1 text-sm font-normal leading-none text-muted-foreground">${escape(moment(comment.created_at).format("MMMM Do YYYY, h:mm:ss a"))}</time> <div class="mb-4 text-base font-normal wysiwyg dark:prose-invert prose prose-stone max-w-none prose-code:px-[0.3rem] prose-code:py-[0.2rem] prose-code:font-mono prose-code:text-sm prose-code:rounded"><!-- HTML_TAG_START -->${comment.body}<!-- HTML_TAG_END --></div> </li>`;
})}</ol> </div>` : ``} `;
}
@@ -394,8 +394,8 @@ const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => {
default: () => {
return `${validate_component(Card_content, "Card.Content").$$render($$result, {}, {}, {
default: () => {
return `<div class="prose prose-stone dark:prose-invert max-w-none prose-code:bg-gray-200 prose-code:px-[0.3rem] prose-code:py-[0.2rem] prose-code:font-mono prose-code:text-sm prose-code:rounded"><!-- HTML_TAG_START -->${incident.body}<!-- HTML_TAG_END --></div> ${incident.comments.length > 0 ? `<div class="ml-4 mt-8"><ol class="relative border-s border-secondary">${each(incident.comments, (comment) => {
return `<li class="mb-10 ms-4"><div class="absolute w-3 h-3 rounded-full mt-1.5 -start-1.5 border border-secondary bg-secondary"></div> <time class="mb-1 text-sm font-normal leading-none text-muted-foreground">${escape(moment(comment.created_at).format("MMMM Do YYYY, h:mm:ss a"))}</time> <div class="mb-4 wysiwyg text-base font-normal prose prose-stone max-w-none prose-code:bg-gray-200 prose-code:px-[0.3rem] prose-code:py-[0.2rem] prose-code:font-mono prose-code:text-sm prose-code:rounded"><!-- HTML_TAG_START -->${comment.body}<!-- HTML_TAG_END --></div> </li>`;
return `<div class="prose prose-stone dark:prose-invert max-w-none prose-code:px-[0.3rem] prose-code:py-[0.2rem] prose-code:font-mono prose-code:text-sm prose-code:rounded"><!-- HTML_TAG_START -->${incident.body}<!-- HTML_TAG_END --></div> ${incident.comments.length > 0 ? `<div class="ml-4 mt-8"><ol class="relative border-s border-secondary">${each(incident.comments, (comment) => {
return `<li class="mb-10 ms-4"><div class="absolute w-3 h-3 rounded-full mt-1.5 -start-1.5 border border-secondary bg-secondary"></div> <time class="mb-1 text-sm font-normal leading-none text-muted-foreground">${escape(moment(comment.created_at).format("MMMM Do YYYY, h:mm:ss a"))}</time> <div class="mb-4 wysiwyg text-base font-normal prose dark:prose-invert prose-stone max-w-none prose-code:px-[0.3rem] prose-code:py-[0.2rem] prose-code:font-mono prose-code:text-sm prose-code:rounded"><!-- HTML_TAG_START -->${comment.body}<!-- HTML_TAG_END --></div> </li>`;
})}</ol> </div>` : ``} `;
}
})} `;
@@ -409,4 +409,4 @@ const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => {
});
export { Page as default };
//# sourceMappingURL=_page.svelte-2946da1d.js.map
//# sourceMappingURL=_page.svelte-c0d02f91.js.map

File diff suppressed because one or more lines are too long

View File

@@ -4,15 +4,15 @@ import { p as public_env } from './shared-server-58a5f352.js';
import moment from 'moment';
import Randomstring from 'randomstring';
const WEBHOOK_TOKEN = process.env.WEBHOOK_TOKEN;
const WEBHOOK_IP = process.env.WEBHOOK_IP;
const API_TOKEN = process.env.API_TOKEN;
const API_IP = process.env.API_IP;
const store = function(data, authHeader, ip) {
const tag = data.tag;
const authToken = authHeader.replace("Bearer ", "");
if (authToken !== WEBHOOK_TOKEN) {
if (authToken !== API_TOKEN) {
return { error: "invalid token", status: 401 };
}
if (WEBHOOK_IP !== void 0 && ip != "" && ip !== WEBHOOK_IP) {
if (API_IP !== void 0 && ip != "" && ip !== API_IP) {
return { error: "invalid ip", status: 401 };
}
const resp = {};
@@ -77,4 +77,4 @@ async function POST({ request }) {
}
export { POST };
//# sourceMappingURL=_server-fa78ed53.js.map
//# sourceMappingURL=_server-315e3406.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -171,7 +171,7 @@ const options = {
<div class="error">
<span class="status">` + status + '</span>\n <div class="message">\n <h1>' + message + "</h1>\n </div>\n </div>\n </body>\n</html>\n"
},
version_hash: "1j67nna"
version_hash: "1cnvd0d"
};
function get_hooks() {
return {};

File diff suppressed because one or more lines are too long

View File

@@ -7,16 +7,16 @@ function __memo(fn) {
return {
appDir: "_app",
appPath: "_app",
assets: new Set([".DS_Store","confetti.gif","favicon.png","google.png","issue.png","kener/cashfree-payments-day-json.json","kener/cashfree-payments.90day.json","kener/google-search-day-json.json","kener/google-search.90day.json","kener/monitors.json","kener/site.json","kener/svelte-website-day-json.json","kener/svelte-website.90day.json","kener/webhook-only-day-json.json","kener/webhook-only.90day.json","kener.png","logo.svg","logo_hero.png","robots.txt","ss.png","ss2.png","ss3.png","svelte.svg"]),
assets: new Set([".DS_Store","confetti.gif","favicon.png","google.png","issue.png","kener/cashfree-payments-day-json.json","kener/cashfree-payments.90day.json","kener/google-search-day-json.json","kener/google-search.90day.json","kener/monitors.json","kener/site.json","kener/svelte-website-day-json.json","kener/svelte-website.90day.json","kener/vrs-day-json.json","kener/vrs.90day.json","kener/webhook-only-day-json.json","kener/webhook-only.90day.json","kener.png","logo.svg","logo_hero.png","robots.txt","ss.png","ss2.png","ss3.png","svelte.svg"]),
mimeTypes: {".gif":"image/gif",".png":"image/png",".json":"application/json",".svg":"image/svg+xml",".txt":"text/plain"},
_: {
client: {"start":"_app/immutable/entry/start.8764aee0.js","app":"_app/immutable/entry/app.1cbce177.js","imports":["_app/immutable/entry/start.8764aee0.js","_app/immutable/chunks/scheduler.4b6b5798.js","_app/immutable/chunks/singletons.ff6fb23c.js","_app/immutable/chunks/index.addbbfd3.js","_app/immutable/entry/app.1cbce177.js","_app/immutable/chunks/scheduler.4b6b5798.js","_app/immutable/chunks/index.7f0074cb.js"],"stylesheets":[],"fonts":[]},
client: {"start":"_app/immutable/entry/start.8fdc56df.js","app":"_app/immutable/entry/app.2ff0ba4c.js","imports":["_app/immutable/entry/start.8fdc56df.js","_app/immutable/chunks/scheduler.4b6b5798.js","_app/immutable/chunks/singletons.758dd10d.js","_app/immutable/chunks/index.addbbfd3.js","_app/immutable/entry/app.2ff0ba4c.js","_app/immutable/chunks/scheduler.4b6b5798.js","_app/immutable/chunks/index.7f0074cb.js"],"stylesheets":[],"fonts":[]},
nodes: [
__memo(() => import('./chunks/0-14c42655.js')),
__memo(() => import('./chunks/1-bdc90f37.js')),
__memo(() => import('./chunks/1-437b1c00.js')),
__memo(() => import('./chunks/2-771a8b67.js')),
__memo(() => import('./chunks/3-f2587af2.js')),
__memo(() => import('./chunks/4-33610416.js'))
__memo(() => import('./chunks/4-94a2f261.js'))
],
routes: [
{
@@ -31,7 +31,7 @@ return {
pattern: /^\/api\/post\/?$/,
params: [],
page: null,
endpoint: __memo(() => import('./chunks/_server-fa78ed53.js'))
endpoint: __memo(() => import('./chunks/_server-315e3406.js'))
},
{
id: "/api/today",

File diff suppressed because one or more lines are too long

10
docs.md
View File

@@ -397,4 +397,12 @@ Create an issue with two labels `your-monitor-tag` and `status`
- Add comments and it will show up in kener.
# API
Kener also gives APIs to push data and create incident. Before you use kener apis you will have to set an authorization token called `WEBHOOK_TOKEN`. This also has to be set as an environment variable.
Kener also gives APIs to push data and create incident. Before you use kener apis you will have to set an authorization token called `API_TOKEN`. This also has to be set as an environment variable.
```shell
export API_TOKEN=some-token-set-by-you
```
Additonally you can set IP whitelisting by setting another environment token called `API_IP`
```shell
export API_IP=127.0.0.1
```

View File

@@ -9,7 +9,6 @@ const apiQueue = new Queue({
timeout: 10000, // Timeout in ms after which a task will be considered as failed (optional)
autostart: true, // Automatically start the queue (optional)
});
function replaceAllOccurrences(originalString, searchString, replacement) {
const regex = new RegExp(`\\${searchString}`, "g");
@@ -19,7 +18,6 @@ function replaceAllOccurrences(originalString, searchString, replacement) {
const Kener_folder = process.env.PUBLIC_KENER_FOLDER;
const apiCall = async (envSecrets, url, method, headers, body, timeout, monitorEval) => {
let axiosHeaders = {};
axiosHeaders["User-Agent"] = "Kener/0.0.1";
axiosHeaders["Accept"] = "*/*";
@@ -57,13 +55,12 @@ const apiCall = async (envSecrets, url, method, headers, body, timeout, monitorE
let statusCode = 500;
let latency = 0;
let resp = "";
let timeoutError = false;
let timeoutError = false;
try {
let data = await axios(url, options);
statusCode = data.status;
resp = data.data;
} catch (err) {
if (err.message.startsWith("timeout of") && err.message.endsWith("exceeded")) {
timeoutError = true;
}
@@ -110,9 +107,9 @@ const apiCall = async (envSecrets, url, method, headers, body, timeout, monitorE
if (evalResp.type !== undefined && evalResp.type !== null) {
toWrite.type = evalResp.type;
}
if(timeoutError){
toWrite.type = "timeout";
}
if (timeoutError) {
toWrite.type = "timeout";
}
return toWrite;
};
const getWebhookData = async (monitor) => {
@@ -187,7 +184,6 @@ const update90DayData = async (mergedData, startOfMinute, monitor) => {
fs.writeFileSync(_90File, JSON.stringify({}));
}
let dayISO = moment(startOfMinute).startOf("day").toISOString();
//calculat 90day data from mergedData
let up = 0,
degraded = 0,
@@ -196,7 +192,7 @@ const update90DayData = async (mergedData, startOfMinute, monitor) => {
for (const timestampISO in mergedData) {
//only consider data from last today
if (!moment(timestampISO).isAfter(moment(dayISO))) {
if (moment(timestampISO).isBefore(moment(dayISO))) {
continue;
}
const element = mergedData[timestampISO];
@@ -234,17 +230,17 @@ const update90DayData = async (mergedData, startOfMinute, monitor) => {
fs.writeFileSync(_90File, JSON.stringify(sorted90Day, null, 2));
};
const Minuter = async (envSecrets, monitor) => {
console.log("Queue length is " + apiQueue.length);
if (apiQueue.length > 0) console.log("Queue length is " + apiQueue.length);
let apiData = {};
let webhookData = {};
const startOfMinute = moment().startOf("minute").toISOString();
let dayData = {};
if (monitor.hasAPI) {
let apiResponse = await apiCall(envSecrets, monitor.url, monitor.method, JSON.stringify(monitor.headers), monitor.body, monitor.timeout, monitor.eval);
apiData[startOfMinute] = apiResponse;
if(apiResponse.type === "timeout"){
console.log("Retrying api call")
//retry
apiData[startOfMinute] = apiResponse;
if (apiResponse.type === "timeout") {
console.log("Retrying api call");
//retry
apiQueue.push(async (cb) => {
apiCall(envSecrets, monitor.url, monitor.method, JSON.stringify(monitor.headers), monitor.body, monitor.timeout, monitor.eval).then(async (data) => {
let day0 = {};
@@ -254,9 +250,8 @@ const Minuter = async (envSecrets, monitor) => {
});
});
}
// apiData[startOfMinute] = await apiCall(envSecrets, startOfMinute, monitor.url, monitor.method, JSON.stringify(monitor.headers), monitor.body, monitor.timeout, monitor.eval);
}
// apiData[startOfMinute] = await apiCall(envSecrets, startOfMinute, monitor.url, monitor.method, JSON.stringify(monitor.headers), monitor.body, monitor.timeout, monitor.eval);
}
webhookData = await getWebhookData(monitor);
dayData = await getDayData(monitor);

View File

@@ -9,7 +9,7 @@ import fs from "fs-extra";
import yaml from "js-yaml";
import { Cron } from "croner";
import { FOLDER, FOLDER_MONITOR, FOLDER_SITE, API_TIMEOUT } from "./constants.js";
import { IsValidURL, IsValidHTTPMethod, LoadMonitorsPath, LoadSitePath } from "./tool.js";
import { IsValidURL, IsValidHTTPMethod, LoadMonitorsPath, LoadSitePath, GetAllGHLabels, CreateGHLabel } from "./tool.js";
import { Minuter } from "./cron-minute.js";
let monitors = [];
let site = {};
@@ -67,7 +67,8 @@ const Startup = async () => {
console.log(error);
process.exit(1);
}
// Use the 'monitors' array of JSON objects as needed
//check if each object has name, url, method
//if not, exit with error
@@ -138,7 +139,7 @@ const Startup = async () => {
}
}
}
if (checkIfDuplicateExists(monitors.map((monitor) => monitor.folderName)) === true) {
console.log("duplicate monitor detected");
process.exit(1);
@@ -159,6 +160,27 @@ const Startup = async () => {
process.exit(1);
}
if (!!site.github && !!site.github.owner && !!site.github.repo) {
const ghowner = site.github.owner;
const ghrepo = site.github.repo;
const ghlabels = await GetAllGHLabels(ghowner, ghrepo);
const tagsAndDescription = monitors.map((monitor) => {
return { tag: monitor.tag, description: monitor.name };
});
//add status label if does not exist
if (ghlabels.indexOf("status") === -1) {
await CreateGHLabel(ghowner, ghrepo, "status", "Status of the site");
}
//add tags if does not exist
for (let i = 0; i < tagsAndDescription.length; i++) {
const tag = tagsAndDescription[i].tag;
const description = tagsAndDescription[i].description;
if (ghlabels.indexOf(tag) === -1) {
await CreateGHLabel(ghowner, ghrepo, tag, description);
}
}
}
// init monitors
for (let i = 0; i < monitors.length; i++) {
const monitor = monitors[i];

View File

@@ -1,11 +1,18 @@
import { MONITOR, SITE} from "./constants.js";
import { MONITOR, SITE } from "./constants.js";
import axios from "axios";
const GH_TOKEN = process.env.GH_TOKEN;
const IsValidURL = function (url) {
return /^(http|https):\/\/[^ "]+$/.test(url);
};
const IsValidHTTPMethod = function (method) {
return /^(GET|POST|PUT|DELETE|HEAD|OPTIONS|PATCH)$/.test(method);
};
function generateRandomColor() {
var randomColor = Math.floor(Math.random() * 16777215).toString(16);
return randomColor;
//random color will be freshly served
}
const LoadMonitorsPath = function () {
const argv = process.argv;
@@ -20,7 +27,7 @@ const LoadMonitorsPath = function () {
}
}
return MONITOR;
return MONITOR;
};
const LoadSitePath = function () {
const argv = process.argv;
@@ -36,6 +43,51 @@ const LoadSitePath = function () {
}
}
return SITE;
return SITE;
};
export { IsValidURL, IsValidHTTPMethod, LoadMonitorsPath, LoadSitePath };
const GetAllGHLabels = async function (owner, repo) {
const options = {
method: "GET",
url: `https://api.github.com/repos/${owner}/${repo}/labels`,
headers: {
Accept: "application/vnd.github+json",
Authorization: "Bearer " + GH_TOKEN,
"X-GitHub-Api-Version": "2022-11-28",
},
};
let labels = [];
try {
const response = await axios.request(options);
labels = response.data.map((label) => label.name);
} catch (error) {
console.log(error.response.data);
return [];
}
return labels;
};
const CreateGHLabel = async function (owner, repo, label, description) {
const options = {
method: "POST",
url: `https://api.github.com/repos/${owner}/${repo}/labels`,
headers: {
Accept: "application/vnd.github+json",
Authorization: "Bearer " + GH_TOKEN,
"X-GitHub-Api-Version": "2022-11-28",
},
data: {
name: label,
color: generateRandomColor(),
description: description,
},
};
try {
const response = await axios.request(options);
return response.data;
} catch (error) {
console.log(error.response.data);
return null;
}
}
export { IsValidURL, IsValidHTTPMethod, LoadMonitorsPath, LoadSitePath, GetAllGHLabels, CreateGHLabel };

View File

@@ -75,7 +75,16 @@ async function getCommentsForIssue(issueID, githubConfig) {
return [];
}
}
/*
{
incident_type: "incident",
start_time: "identified", //required
end_time: "resolved",
title: "title",
description: "description",
status:"degraded, down"
}
*/
export { activeIncident, hasActiveIncident, getCommentsForIssue, pastIncident };

View File

@@ -3,18 +3,18 @@ import fs from "fs-extra"
import { env } from "$env/dynamic/public";
import moment from "moment";
import Randomstring from "randomstring";
const WEBHOOK_TOKEN = process.env.WEBHOOK_TOKEN;
const WEBHOOK_IP = process.env.WEBHOOK_IP;
const API_TOKEN = process.env.API_TOKEN;
const API_IP = process.env.API_IP;
const store = function(data, authHeader, ip){
const tag = data.tag;
//remove Bearer from start in authHeader
const authToken = authHeader.replace("Bearer ", "");
if (authToken !== WEBHOOK_TOKEN) {
if (authToken !== API_TOKEN) {
return { error: "invalid token", status: 401 };
}
if (WEBHOOK_IP !== undefined && ip != "" && ip !== WEBHOOK_IP) {
if (API_IP !== undefined && ip != "" && ip !== API_IP) {
return { error: "invalid ip", status: 401 };
}
const resp = {};