@nimuthu/check-website-status 1.0.0

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.
Files changed (2) hide show
  1. package/index.js +31 -0
  2. package/package.json +8 -0
package/index.js ADDED
@@ -0,0 +1,31 @@
1
+ const axios = require('axios');
2
+
3
+ class SiteMonitor {
4
+ constructor(config) {
5
+ this.siteName = config.siteName;
6
+ this.apiKey = config.apiKey;
7
+ }
8
+
9
+ // මෙය ඔබේ වෙබ් අඩවියේ API route එකක භාවිතා කළ යුතු middleware එකයි
10
+ handleRequest(req, res) {
11
+ // ආරක්ෂාව: dashboard එකෙන් එන key එක පරීක්ෂා කරන්න
12
+ const incomingKey = req.headers['x-api-key'];
13
+
14
+ if (incomingKey !== this.apiKey) {
15
+ return res.status(403).json({ error: 'Unauthorized' });
16
+ }
17
+
18
+ // දත්ත යැවීම
19
+ const statusReport = {
20
+ siteName: this.siteName,
21
+ status: 'online',
22
+ uptime: process.uptime(), // server එක කොපමණ වෙලාවක් up ද
23
+ memoryUsage: process.memoryUsage().heapUsed / 1024 / 1024, // RAM භාවිතය
24
+ timestamp: new Date().toISOString()
25
+ };
26
+
27
+ return res.status(200).json(statusReport);
28
+ }
29
+ }
30
+
31
+ module.exports = SiteMonitor;
package/package.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@nimuthu/check-website-status",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "dependencies": {
6
+ "axios": "^1.7.0"
7
+ }
8
+ }