NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

addEventListener("fetch", event => {
const { request } = event
if (request.method === "POST") {
return event.respondWith(handleRequest(request))
}
else if (request.method === "GET") {
return event.respondWith(new Response(`The request was a GET`))
}
})

async function handleRequest(request) {
let pathname = new URL(request.url).pathname
let reqBody;
if(pathname == "/slack"){
reqBody = await slack(request)
}
const retBody = `${JSON.stringify(reqBody)}`
return new Response(retBody)
}

async function slack(request) {
const { headers } = request
const contentType = headers.get("content-type") || ""
let slackJson = {
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ""
}
},
]
}
if (contentType.includes("application/json")) {
let bodyy = JSON.stringify(await request.json())
bodyy = JSON.parse(bodyy)
let url = "https://app.squadcast.com/incident/" + bodyy.id
let title = ""
let serviceName = ""
let alertSource = ""
let text = ""

if (bodyy.event_type == "incident_resolved") {
title = "<" + url + "|*Resolved #" + bodyy.id + "*>n"
}
else if (bodyy.event_type == "incident_reassigned") {
title = "<" + url + "|*Reassigned #" + bodyy.id + "*>n"
}
else if (bodyy.event_type == "incident_acknowledged") {
title = "<" + url + "|*Acknowledged #" + bodyy.id + "*>n"
}
else if (bodyy.event_type == "incident_triggered") {
title = "<" + url + "|*Triggered #" + bodyy.id + "*>n"
}
serviceName = bodyy.service.name
alertSource = bodyy.alert_source.type
let message = bodyy.message
message = message.replace(/n+/g, "")
text = "n-------------------------------------n" + title + message + "n*Description* n" + bodyy.description + "n*Service Name*:" + serviceName + "n*Alert soure*: " + alertSource
text = text.replace(/n+/g, "n")
text = text.replace(/**/g, "")
slackJson.blocks[0].text.text = text
let slackUrl = request.headers.get("slackurl")
const init = {
body: JSON.stringify(slackJson),
method: "POST",
headers: {
"content-type": "application/json;charset=UTF-8",
},
}
if (slackUrl != undefined) {
slackUrl = slackUrl.split(",")
}
for (let url in slackUrl) {
let temp_url = slackUrl[url].trim()
if (temp_url.length > 0) {
await fetch(temp_url, init)
}
}
return slackJson
}
else {
return 'a file';
}
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.