![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
koa-ping-healthcheck
Advanced tools
Make koa apps check internal status and health. Inspired by express-ping
Make koa apps check internal status and health. This project is inspired by express-ping
npm install koa-ping-healthcheck --save
const health = require("koa-ping-healthcheck");
const Koa = require("koa");
const app = new Koa();
app.use(health());
app.listen(3000);
Once you launch your koa application, it will add a new /ping endpoint to check the app status. If you GET http://localhost:3000/ping you will receive the following information:
{
"custom": {},
"timestamp": 1416079378823,
"uptime": 550.219,
"application": {
"name": "koa-ping-healthcheck",
"version": "1.0.0",
"pid": 21149,
"title": "node",
"argv": ["node", "/koa-ping-healthcheck/index.js"],
"versions": {
"http_parser": "2.3",
"node": "0.11.14",
"v8": "3.26.33",
"uv": "1.0.0",
"zlib": "1.2.3",
"modules": "14",
"openssl": "1.0.1i"
}
},
"resources": {
"memory": {
"rss": 26243072,
"heapTotal": 17930752,
"heapUsed": 10810544
},
"loadavg": [4.431640625, 4.572265625, 4.451171875],
"cpu": [
{
"model": "Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz",
"speed": 1300,
"times": {
"user": 43839420,
"nice": 0,
"sys": 24282010,
"idle": 164757040,
"irq": 0
}
},
{
"model": "Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz",
"speed": 1300,
"times": {
"user": 23479990,
"nice": 0,
"sys": 10831830,
"idle": 198556920,
"irq": 0
}
},
{
"model": "Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz",
"speed": 1300,
"times": {
"user": 42303960,
"nice": 0,
"sys": 18350510,
"idle": 172214370,
"irq": 0
}
},
{
"model": "Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz",
"speed": 1300,
"times": {
"user": 23728510,
"nice": 0,
"sys": 9963050,
"idle": 199177080,
"irq": 0
}
}
],
"disk": [
{
"filesystem": "/dev/disk1",
"size": 117286912,
"used": 92423484,
"available": 24607428,
"capacity": 0.79,
"mount": "/"
},
{
"filesystem": "devfs",
"size": 180,
"used": 180,
"available": 0,
"capacity": 1,
"mount": "/dev"
},
{
"filesystem": "map -hosts",
"size": 0,
"used": 0,
"available": 0,
"capacity": 1,
"mount": "/net"
},
{
"filesystem": "map auto_home",
"size": 0,
"used": 0,
"available": 0,
"capacity": 1,
"mount": "/home"
}
],
"nics": {
"lo0": [
{
"address": "::1",
"netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
"family": "IPv6",
"mac": "00:00:00:00:00:00",
"scopeid": 0,
"internal": true
},
{
"address": "127.0.0.1",
"netmask": "255.0.0.0",
"family": "IPv4",
"mac": "00:00:00:00:00:00",
"internal": true
},
{
"address": "fe80::1",
"netmask": "ffff:ffff:ffff:ffff::",
"family": "IPv6",
"mac": "00:00:00:00:00:00",
"scopeid": 1,
"internal": true
}
],
"en0": [
{
"address": "fe80::8638:35ff:fe41:a48c",
"netmask": "ffff:ffff:ffff:ffff::",
"family": "IPv6",
"mac": "84:38:35:41:a4:8c",
"scopeid": 4,
"internal": false
},
{
"address": "192.168.1.100",
"netmask": "255.255.255.0",
"family": "IPv4",
"mac": "84:38:35:41:a4:8c",
"internal": false
}
],
"awdl0": [
{
"address": "fe80::8df:54ff:fe9e:d53b",
"netmask": "ffff:ffff:ffff:ffff::",
"family": "IPv6",
"mac": "0a:df:54:9e:d5:3b",
"scopeid": 7,
"internal": false
}
]
}
},
"system": {
"arch": "x64",
"platform": "darwin",
"type": "Darwin",
"release": "14.0.0",
"hostname": "MyPC",
"uptime": 1802594,
"cores": 4,
"memory": 8589934592
}
}
You don't need to configure anything. By default, a /ping
endpoint will be added to your routes, but you can pass the ping endpoint to the middeware simply doing:
app.use(health.ping({ path: "/custompath" }));
You can also pass a custom checker, use customCheckOnly
option if you want to display only the custom checker's output:
app.use(
healthCheck({
customCheckOnly: false, //set to true to display only the output from custom checker
customCheck: async function customHealthCheck(ctx) {
const start = Date.now();
await pingDatabase();
return {
ua: ctx.request.get("user-agent"),
databaseLatency: `${Date.now() - start} ms`
};
}
})
);
Which will output:
{
"custom": {
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3562.0 Safari/537.36",
"databaseLatency": "22 ms"
},
"timestamp": 1416079378823,
"uptime": 550.219
}
FAQs
Make koa apps check internal status and health. Inspired by express-ping
The npm package koa-ping-healthcheck receives a total of 647 weekly downloads. As such, koa-ping-healthcheck popularity was classified as not popular.
We found that koa-ping-healthcheck demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.