express-system-status
Advanced tools
+38
-2
@@ -7,2 +7,37 @@ var express = require('express') | ||
| } | ||
| //var mongoose = require('mongoose') | ||
| // mongoose.Promise = Promise; | ||
| // var options = { | ||
| // // db: { native_parser: true }, | ||
| // // server: { poolSize: 5 }, | ||
| // // replset: { rs_name: 'myReplicaSetName' }, | ||
| // // user: 'myUserName', | ||
| // // pass: 'myPassword' | ||
| // } | ||
| // mongoose.connect('mongodb://localhost/blog', options); | ||
| // var blogSchema = mongoose.Schema({ | ||
| // created: { | ||
| // type: Date, | ||
| // default: Date.now | ||
| // }, | ||
| // title: { | ||
| // type: String, | ||
| // required: true, | ||
| // trim: true | ||
| // }, | ||
| // content: { | ||
| // type: String, | ||
| // required: true, | ||
| // trim: true | ||
| // }, | ||
| // author: { | ||
| // type: String, | ||
| // required: true, | ||
| // trim: true | ||
| // }, | ||
| // }); | ||
| // var Blog = mongoose.model('Blog', blogSchema) | ||
| app.use('/api/v1/system/status', | ||
@@ -15,3 +50,4 @@ status({ | ||
| pass: 'pass', | ||
| extra: {} | ||
| extra: {}, | ||
| //mongoose:mongoose | ||
| }) | ||
@@ -21,3 +57,3 @@ ) | ||
| app.get('/', function (req, res) { | ||
| res.send('This is the index route. You are probably looking for the <a href="/api/v1/system/status">System Status</a> route!') | ||
| res.send('This is the index route. You are probably looking for the <a href="/api/v1/system/status/api">System Status</a> route!') | ||
| }) | ||
@@ -24,0 +60,0 @@ app.listen(3000, function () { |
+71
-88
@@ -31,2 +31,71 @@ 'use strict' | ||
| function createObj (data) { | ||
| var obj = { | ||
| process: { | ||
| versions: process.versions, | ||
| arch: process.arch, | ||
| platform: process.platform, | ||
| argv: process.argv, | ||
| pid: process.pid, | ||
| release: process.release, | ||
| uptime: process.uptime() | ||
| }, | ||
| os: { | ||
| EOL: os.EOL, | ||
| arch: os.arch(), | ||
| cpus: os.cpus(), | ||
| cpuCount: os.cpus().length, | ||
| endianness: os.endianness(), | ||
| freemem: os.freemem() / (1024 * 1024), | ||
| freememPercentage: os.freemem() / os.totalmem(), | ||
| homedir: os.homedir(), | ||
| hostname: os.hostname(), | ||
| loadavg: os.loadavg(), | ||
| networkInterfaces: os.networkInterfaces(), | ||
| platform: os.platform(), | ||
| release: os.release(), | ||
| tmpdir: os.tmpdir(), | ||
| totalmem: os.totalmem() / (1024 * 1024), | ||
| type: os.type(), | ||
| uptime: os.uptime() | ||
| }, | ||
| dns: { | ||
| servers: dns.getServers() | ||
| }, | ||
| global: { | ||
| __dirname: __dirname, | ||
| __filename: __filename | ||
| } | ||
| } | ||
| if (data.extra) { | ||
| obj.extra = data.extra | ||
| } | ||
| if (data.config) { | ||
| obj.config = data.config | ||
| } | ||
| if (data.app) { | ||
| obj.express = { | ||
| settings: data.app.settings, | ||
| locals: data.app.locals | ||
| } | ||
| } | ||
| if (data.mongoose) { | ||
| obj.mongoose = { | ||
| replica: data.mongoose.connection.replica, | ||
| hosts: data.mongoose.connection.hosts, | ||
| host: data.mongoose.connection.host, | ||
| port: data.mongoose.connection.port, | ||
| user: data.mongoose.connection.user, | ||
| options: data.mongoose.connection.options, | ||
| config: data.mongoose.connection.config, | ||
| name: data.mongoose.connection.name, | ||
| models: data.mongoose.modelSchemas, | ||
| readyState: data.mongoose.connection.readyState === 0 ? 0 : 1, | ||
| closeCalled: data.mongoose.connection._closeCalled, | ||
| hasOpened: data.mongoose.connection._hasOpened, | ||
| listening: data.mongoose.connection._listening | ||
| } | ||
| } | ||
| return obj | ||
| } | ||
| // 'darwin', 'freebsd', 'linux', 'sunos' or 'win32' | ||
@@ -49,96 +118,10 @@ module.exports = function (data) { | ||
| status.get('/status.html', function (req, res) { | ||
| var obj = { | ||
| process: { | ||
| versions: process.versions, | ||
| arch: process.arch, | ||
| platform: process.platform, | ||
| argv: process.argv, | ||
| pid: process.pid, | ||
| release: process.release, | ||
| uptime: process.uptime() | ||
| }, | ||
| express: { | ||
| settings: data.app.settings, | ||
| locals: data.app.locals | ||
| }, | ||
| config: data.config || {}, | ||
| os: { | ||
| EOL: os.EOL, | ||
| arch: os.arch(), | ||
| cpus: os.cpus(), | ||
| cpuCount: os.cpus().length, | ||
| endianness: os.endianness(), | ||
| freemem: os.freemem() / (1024 * 1024), | ||
| freememPercentage: os.freemem() / os.totalmem(), | ||
| homedir: os.homedir(), | ||
| hostname: os.hostname(), | ||
| loadavg: os.loadavg(), | ||
| networkInterfaces: os.networkInterfaces(), | ||
| platform: os.platform(), | ||
| release: os.release(), | ||
| tmpdir: os.tmpdir(), | ||
| totalmem: os.totalmem() / (1024 * 1024), | ||
| type: os.type(), | ||
| uptime: os.uptime() | ||
| }, | ||
| dns: { | ||
| servers: dns.getServers() | ||
| }, | ||
| global: { | ||
| __dirname: __dirname, | ||
| __filename: __filename | ||
| }, | ||
| extra: data.extra || {} | ||
| } | ||
| res.render(path.resolve('client/index.html'), { | ||
| obj: obj | ||
| obj: createObj(data) | ||
| }) | ||
| }) | ||
| status.get('/api', function (req, res) { | ||
| var obj = { | ||
| process: { | ||
| versions: process.versions, | ||
| arch: process.arch, | ||
| platform: process.platform, | ||
| argv: process.argv, | ||
| pid: process.pid, | ||
| release: process.release, | ||
| uptime: process.uptime() | ||
| }, | ||
| express: { | ||
| settings: data.app.settings, | ||
| locals: data.app.locals | ||
| }, | ||
| config: data.config || {}, | ||
| os: { | ||
| EOL: os.EOL, | ||
| arch: os.arch(), | ||
| cpus: os.cpus(), | ||
| cpuCount: os.cpus().length, | ||
| endianness: os.endianness(), | ||
| freemem: os.freemem() / (1024 * 1024), | ||
| freememPercentage: os.freemem() / os.totalmem(), | ||
| homedir: os.homedir(), | ||
| hostname: os.hostname(), | ||
| loadavg: os.loadavg(), | ||
| networkInterfaces: os.networkInterfaces(), | ||
| platform: os.platform(), | ||
| release: os.release(), | ||
| tmpdir: os.tmpdir(), | ||
| totalmem: os.totalmem() / (1024 * 1024), | ||
| type: os.type(), | ||
| uptime: os.uptime() | ||
| }, | ||
| dns: { | ||
| servers: dns.getServers() | ||
| }, | ||
| global: { | ||
| __dirname: __dirname, | ||
| __filename: __filename | ||
| }, | ||
| extra: data.extra || {} | ||
| } | ||
| res.status(200).send(obj) | ||
| res.status(200).send(createObj(data)) | ||
| }) | ||
| return status | ||
| } |
+1
-1
| { | ||
| "name": "express-system-status", | ||
| "version": "0.1.0", | ||
| "version": "0.2.0", | ||
| "description": "Add routes to check the env , configs & status of your system", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+24
-7
@@ -1,2 +0,2 @@ | ||
| # express-system-status | ||
| # Express-System-Status | ||
| Add Routes to check the env , configs & status of your system | ||
@@ -27,3 +27,4 @@ | ||
| pass: 'pass', | ||
| extra: {} | ||
| extra: {}, | ||
| mongoose:mongoose //Now Supporting Mongoose | ||
| }) | ||
@@ -67,2 +68,10 @@ ) | ||
| … | ||
| }, | ||
| mongoose: { | ||
| readyState: 1, | ||
| closeCalled: false, | ||
| hasOpened: true, | ||
| listening: false, | ||
| models:{…}, | ||
| … | ||
| } | ||
@@ -78,3 +87,12 @@ } | ||
| - Refactor | ||
| - Update Tests | ||
| Change Log | ||
| --------------------------------- | ||
| ### 0.1.0 | ||
| - Init Release | ||
| ### 0.2.0 | ||
| - Added Mongoose Support | ||
| License | ||
@@ -110,9 +128,8 @@ --------------------------------- | ||
| Support and contributions from the open source community are essential for keeping | ||
| Mean Stack JS up to date. We are always looking for the quality contributions and | ||
| express-system-status up to date. We are always looking for the quality contributions and | ||
| will be happy to accept your Pull Requests as long as those adhere to some basic rules: | ||
| * Please make sure that your contribution fits well in the project's style & concept: | ||
| * JS Standard | ||
| * John Papa angular style guide | ||
| * Pass All Test ( once testing has been fully implement) | ||
| * JS Standard | ||
| * Pass All Test ( once testing has been fully implement) | ||
@@ -122,3 +139,3 @@ ### Creating an Issue | ||
| Before you create a new Issue: | ||
| * Check the [Issues](https://github.com/GreenPioneer/meanstackjs/issues) on Github to ensure one doesn't already exist. | ||
| * Check the [Issues](https://github.com/greenpioneersolutions/express-system-status/issues) on Github to ensure one doesn't already exist. | ||
| * Place use one of these topics in the beginning of your issue title- Contrib, Hotfix, Error, Help or Feature. | ||
@@ -125,0 +142,0 @@ * Clearly describe the issue, including the steps to reproduce the issue. |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
15144
4.88%189
9.25%154
12.41%