Skip to content

Commit

Permalink
added configurable title
Browse files Browse the repository at this point in the history
  • Loading branch information
capaj committed Aug 21, 2016
1 parent 07ccf48 commit 36afa76
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Server Status</title>
<title>{{title}} status</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.2.1/Chart.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.5/socket.io.min.js"></script>
<style>
Expand Down Expand Up @@ -75,7 +75,7 @@
<body>
<div style="width: 600px; margin: auto">
<div class="header">
<b>Server Status</b>
<b>{{title}} Status</b>
<div id="span-controls" class="span-controls">
</div>
</div>
Expand Down
19 changes: 7 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ const send = require('koa-send')
const pidusage = require('pidusage')
const handlebars = require('handlebars')
let io
let appName
try {
appName = require('../../package.json').name
} catch (err) {}

const defaultConfig = {
path: '/status',
title: appName,
spans: [{
interval: 1,
retention: 60
Expand Down Expand Up @@ -63,18 +68,8 @@ const sendMetrics = (span) => {

const middlewareWrapper = (app, config) => {
io = require('socket.io')(app)

if (config === null || config === undefined) {
config = defaultConfig
}

if (config.path === undefined || !config instanceof String) {
config.path = defaultConfig.path
}

if (config.spans === undefined || !config instanceof Array) {
config.spans = defaultConfig.spans
}
Object.assign(defaultConfig, config)
config = defaultConfig
const indexHtml = fs.readFileSync('index.html', {'encoding': 'utf8'})
const template = handlebars.compile(indexHtml)

Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koa-monitor",
"version": "0.1.0",
"description": "Monitoring for koa-based Node applications",
"version": "0.1.1",
"description": "Realtime monitoring for koa-based Node applications",
"main": "index.js",
"keywords": [
"node",
Expand All @@ -12,6 +12,10 @@
],
"author": "Jiri Spac capajj@gmail.com",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/capaj/koa-monitor.git"
},
"dependencies": {
"handlebars": "^4.0.5",
"koa-send": "^3.2.0",
Expand Down

0 comments on commit 36afa76

Please sign in to comment.