chore(tools): add biomejs, apply lint+formatting fixes
This commit is contained in:
parent
44a9c52c78
commit
c63fa19035
4 changed files with 174 additions and 54 deletions
22
biome.json
Normal file
22
biome.json
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://biomejs.dev/schemas/1.6.1/schema.json",
|
||||||
|
"organizeImports": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"linter": {
|
||||||
|
"enabled": true,
|
||||||
|
"rules": {
|
||||||
|
"recommended": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"formatter": {
|
||||||
|
"enabled": true,
|
||||||
|
"lineWidth": 120
|
||||||
|
},
|
||||||
|
"javascript": {
|
||||||
|
"formatter": {
|
||||||
|
"semicolons": "asNeeded",
|
||||||
|
"quoteStyle": "single"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,12 @@
|
||||||
"author": "Marc Cataford <mcat@riseup.net>",
|
"author": "Marc Cataford <mcat@riseup.net>",
|
||||||
"private": true,
|
"private": true,
|
||||||
"packageManager": "yarn@4.1.1",
|
"packageManager": "yarn@4.1.1",
|
||||||
|
"scripts": {
|
||||||
|
"lint": "biome lint .; biome format .",
|
||||||
|
"lint:fix": "biome lint . --apply; biome format . --write"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@biomejs/biome": "^1.6.1",
|
||||||
"@types/node": "^20.11.27",
|
"@types/node": "^20.11.27",
|
||||||
"typescript": "^5.4.2"
|
"typescript": "^5.4.2"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import { readFile } from 'node:fs/promises'
|
|
||||||
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { getStore } from '@netlify/blobs'
|
import { getStore } from '@netlify/blobs'
|
||||||
import type { Context } from '@netlify/functions'
|
import type { Context } from '@netlify/functions'
|
||||||
|
@ -36,13 +34,13 @@ async function pingEndpoint(endpoint: Endpoint): Promise<EndpointReport> {
|
||||||
return {
|
return {
|
||||||
...endpoint,
|
...endpoint,
|
||||||
status: response.status,
|
status: response.status,
|
||||||
healthy: true
|
healthy: true,
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
return {
|
return {
|
||||||
...endpoint,
|
...endpoint,
|
||||||
healthy: false,
|
healthy: false,
|
||||||
status: e.response.status
|
status: e.response.status,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,9 +52,8 @@ async function pingEndpoint(endpoint: Endpoint): Promise<EndpointReport> {
|
||||||
*/
|
*/
|
||||||
function formatReport(endpointReports: EndpointReport[]): string {
|
function formatReport(endpointReports: EndpointReport[]): string {
|
||||||
const endpointStatuses = endpointReports.map((report: EndpointReport): string => {
|
const endpointStatuses = endpointReports.map((report: EndpointReport): string => {
|
||||||
if (report.healthy)
|
if (report.healthy) return `✅ ${report.name} is healthy (${report.status})`
|
||||||
return `✅ ${report.name} is healthy (${report.status})`
|
|
||||||
else
|
|
||||||
return `🔥 ${report.name} did not respond normally (${report.status})`
|
return `🔥 ${report.name} did not respond normally (${report.status})`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -73,12 +70,16 @@ function formatReport(endpointReports: EndpointReport[]): string {
|
||||||
export default async (request: Request, context: Context) => {
|
export default async (request: Request, context: Context) => {
|
||||||
//const conf: Configuration = require("../config.json")
|
//const conf: Configuration = require("../config.json")
|
||||||
const configurationStore = getStore('functions')
|
const configurationStore = getStore('functions')
|
||||||
const conf: Configuration = await configurationStore.get('config', { type: 'json' })
|
const conf: Configuration = await configurationStore.get('config', {
|
||||||
|
type: 'json',
|
||||||
|
})
|
||||||
|
|
||||||
const pings = await Promise.all(conf.endpoints.map(pingEndpoint))
|
const pings = await Promise.all(conf.endpoints.map(pingEndpoint))
|
||||||
|
|
||||||
const report = formatReport(pings)
|
const report = formatReport(pings)
|
||||||
const webhook_url = conf.webhook_url.replace('$DISCORD_WEBHOOK_ID', process.env.DISCORD_WEBHOOK_ID).replace('$DISCORD_WEBHOOK_TOKEN', process.env.DISCORD_WEBHOOK_TOKEN)
|
const webhook_url = conf.webhook_url
|
||||||
|
.replace('$DISCORD_WEBHOOK_ID', process.env.DISCORD_WEBHOOK_ID)
|
||||||
|
.replace('$DISCORD_WEBHOOK_TOKEN', process.env.DISCORD_WEBHOOK_TOKEN)
|
||||||
await axios.post(webhook_url, { content: report })
|
await axios.post(webhook_url, { content: report })
|
||||||
|
|
||||||
return new Response()
|
return new Response()
|
||||||
|
|
92
yarn.lock
92
yarn.lock
|
@ -5,6 +5,97 @@ __metadata:
|
||||||
version: 8
|
version: 8
|
||||||
cacheKey: 10c0
|
cacheKey: 10c0
|
||||||
|
|
||||||
|
"@biomejs/biome@npm:^1.6.1":
|
||||||
|
version: 1.6.1
|
||||||
|
resolution: "@biomejs/biome@npm:1.6.1"
|
||||||
|
dependencies:
|
||||||
|
"@biomejs/cli-darwin-arm64": "npm:1.6.1"
|
||||||
|
"@biomejs/cli-darwin-x64": "npm:1.6.1"
|
||||||
|
"@biomejs/cli-linux-arm64": "npm:1.6.1"
|
||||||
|
"@biomejs/cli-linux-arm64-musl": "npm:1.6.1"
|
||||||
|
"@biomejs/cli-linux-x64": "npm:1.6.1"
|
||||||
|
"@biomejs/cli-linux-x64-musl": "npm:1.6.1"
|
||||||
|
"@biomejs/cli-win32-arm64": "npm:1.6.1"
|
||||||
|
"@biomejs/cli-win32-x64": "npm:1.6.1"
|
||||||
|
dependenciesMeta:
|
||||||
|
"@biomejs/cli-darwin-arm64":
|
||||||
|
optional: true
|
||||||
|
"@biomejs/cli-darwin-x64":
|
||||||
|
optional: true
|
||||||
|
"@biomejs/cli-linux-arm64":
|
||||||
|
optional: true
|
||||||
|
"@biomejs/cli-linux-arm64-musl":
|
||||||
|
optional: true
|
||||||
|
"@biomejs/cli-linux-x64":
|
||||||
|
optional: true
|
||||||
|
"@biomejs/cli-linux-x64-musl":
|
||||||
|
optional: true
|
||||||
|
"@biomejs/cli-win32-arm64":
|
||||||
|
optional: true
|
||||||
|
"@biomejs/cli-win32-x64":
|
||||||
|
optional: true
|
||||||
|
bin:
|
||||||
|
biome: bin/biome
|
||||||
|
checksum: 10c0/789580c9aa7e0661a643e82de85f15bcc4ef0c79a099204f234b3769cface5c604b137260a4a60767ab3a692bd7ac19e2de1fc75537ec14e7698f0b6a133cfef
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
|
"@biomejs/cli-darwin-arm64@npm:1.6.1":
|
||||||
|
version: 1.6.1
|
||||||
|
resolution: "@biomejs/cli-darwin-arm64@npm:1.6.1"
|
||||||
|
conditions: os=darwin & cpu=arm64
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
|
"@biomejs/cli-darwin-x64@npm:1.6.1":
|
||||||
|
version: 1.6.1
|
||||||
|
resolution: "@biomejs/cli-darwin-x64@npm:1.6.1"
|
||||||
|
conditions: os=darwin & cpu=x64
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
|
"@biomejs/cli-linux-arm64-musl@npm:1.6.1":
|
||||||
|
version: 1.6.1
|
||||||
|
resolution: "@biomejs/cli-linux-arm64-musl@npm:1.6.1"
|
||||||
|
conditions: os=linux & cpu=arm64 & libc=musl
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
|
"@biomejs/cli-linux-arm64@npm:1.6.1":
|
||||||
|
version: 1.6.1
|
||||||
|
resolution: "@biomejs/cli-linux-arm64@npm:1.6.1"
|
||||||
|
conditions: os=linux & cpu=arm64 & libc=glibc
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
|
"@biomejs/cli-linux-x64-musl@npm:1.6.1":
|
||||||
|
version: 1.6.1
|
||||||
|
resolution: "@biomejs/cli-linux-x64-musl@npm:1.6.1"
|
||||||
|
conditions: os=linux & cpu=x64 & libc=musl
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
|
"@biomejs/cli-linux-x64@npm:1.6.1":
|
||||||
|
version: 1.6.1
|
||||||
|
resolution: "@biomejs/cli-linux-x64@npm:1.6.1"
|
||||||
|
conditions: os=linux & cpu=x64 & libc=glibc
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
|
"@biomejs/cli-win32-arm64@npm:1.6.1":
|
||||||
|
version: 1.6.1
|
||||||
|
resolution: "@biomejs/cli-win32-arm64@npm:1.6.1"
|
||||||
|
conditions: os=win32 & cpu=arm64
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
|
"@biomejs/cli-win32-x64@npm:1.6.1":
|
||||||
|
version: 1.6.1
|
||||||
|
resolution: "@biomejs/cli-win32-x64@npm:1.6.1"
|
||||||
|
conditions: os=win32 & cpu=x64
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@netlify/blobs@npm:^7.0.1":
|
"@netlify/blobs@npm:^7.0.1":
|
||||||
version: 7.0.1
|
version: 7.0.1
|
||||||
resolution: "@netlify/blobs@npm:7.0.1"
|
resolution: "@netlify/blobs@npm:7.0.1"
|
||||||
|
@ -106,6 +197,7 @@ __metadata:
|
||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "healthcheck@workspace:."
|
resolution: "healthcheck@workspace:."
|
||||||
dependencies:
|
dependencies:
|
||||||
|
"@biomejs/biome": "npm:^1.6.1"
|
||||||
"@netlify/blobs": "npm:^7.0.1"
|
"@netlify/blobs": "npm:^7.0.1"
|
||||||
"@netlify/functions": "npm:^2.6.0"
|
"@netlify/functions": "npm:^2.6.0"
|
||||||
"@types/node": "npm:^20.11.27"
|
"@types/node": "npm:^20.11.27"
|
||||||
|
|
Reference in a new issue