Git Product home page Git Product logo

node-monkey's People

Contributors

billbogaiv avatar clayzermk1 avatar johnnycrab avatar jwarkentin avatar roundrobin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-monkey's Issues

Client JS paths should be more dynamic

If I have a project that uses Socket.IO, Underscore, and (as a devDep) node-monkey, the libraries will be at the same directory level as node-monkey and not within node-monkey's node_modules.

Furthermore, if I am running Socket.IO from a resource path other than the default (behind a reverse proxy for example), the standard socket.io/socket.io path will not work.

It would be best if these files were found more dynamically.

Monkey is noisy

Chrome console reports the following when loading JS files:
Resource interpreted as Script but transferred with MIME type text/plain: "http://127.0.0.1:8888/lodash.js".
Resource interpreted as Script but transferred with MIME type text/plain: "http://127.0.0.1:8888/cycle.js".
Resource interpreted as Script but transferred with MIME type text/plain: "http://127.0.0.1:8888/client.js".

This can be fixed by sending a res.setHeader('Content-Type', 'text/javascript'); before res.end() during httpServer.createServer().

Also there is no need to say "Welcome to NodeMonkey" everytime the JS loads, it bloats the console. This should be removed from connection.on('connect').

Also within NodeJS console reports: "info: socket.io started", this can be disabled by updating index.js line 225 to read: this.iosrv = socketIO.listen(this.srv, {log: false});

Perhaps a "quiet" mode by default?

Logging improvements

I've still been thinking about the log filtering problem discussed here. After spending a lot of time recently using Log4J with Kotlin I think there are some important design concepts there. In particular I'm thinking about the way appenders and filters work, the context-based cascading and the declarative config for managing it all.

Importantly, this can't be complex like Log4J. It needs to work out of the box, be simple to understand and configure and allow enough flexibility to be generally useful. It should also be able to improve logging performance when running in production mode, not hurt it.

It might be worth re-thinking Node Monkey as a true logging system first and foremost, with one appender being a browser console appender or something. I'm not sure how the SSH stuff would fit into this but it probably doesn't. Most likely, that will have to move to its own project.

'guest' auth fails

Hi,

I'm running a simple Express ES6 server which uses babel-node.

I'm trying to get node-monkey up and running with its own (default) configuration. I can hit the server just fine, and am prompted for authentication. I enter the default username: guest, password: guest, but it just repeatedly asks me for my login. An empty object is logged to the console with a "Auth failed" message.

Is there any additional config required? All I've done is included this line in my server.js:

monkey = require('node-monkey')();

Re-enable gzip compression for Windows

This is a reminder that when socketio/socket.io#932 is fixed we should set that version as the minimum version in the dependencies and re-enable gzip compression for Windows. For now, I'm going to make a small change to disable gzip compression on the Windows platform to resolve #8.

Using nodemonkey on production

Hey,

First of all, thanks for developing nodemonkey. I just stumbled onto this, and I am really excited to use this in our apps.

I want to use this in some of our production apps, and for that I think we will need the changes listed below. I am just about to fork this project and work on it myself. I just wanted your input on these. Do these changes make sense to you? Will you be interested in merging them back if I send PR?

Changes

Use socketio-auth for security

https://www.npmjs.com/package/socketio-auth

User can maybe provide some options like this:

{
    "users": [
        {
            "user": "userid",
            "password": "password"
        }
    ]    
}

Then the page that hosts debugger (client.html or custom page), will need to provide user and password to use (window.nomoUser, window.nomoPassword). client.js will use this user and password to authenticate socket.io.

Allow for light weight start() and stop() functions

User will want to enable debugger dynamically in production. No point in running debugger when you are not using it.

I, for example, would want to create some endpoint like this in my server:

POST /debugger
headers:
enable: 0/1
token: "some predetermined token"

this will call nomo.start or stop

For above reasons, lightweight version of start will be needed.

Current start():

  • uses fs.readFileSync variants to read files for serving them
  • generates template for client.js from provided options

Need to divide that into two functions.

init():

  • sets config
  • reads client.js. uses template and options to dynamically generate client.out.js

start():

  • uses fs.readFile variants to serve needed files
  • uses client.out.js instead of client.js
  • adds proper cache headers for all js files, except client.out.js
  • starts server and io. and do the rest

Allow for limits on msgbuffer array in server side

Currently it will keep growing if no active sockets are there. We can provide option "serverMaxBuffer" and use it to maintain msgbuffer size.

An optional enhancement in client.js

It will be helpful if we can filter messages to be logged in browser's console. For example, in our apps we have dedicated debugger functions for different modules. They emebed moduleId along with current date to all the logged messages.

If we can provide a filter function to client.js, each developer will be able to see just the messages that they are interested in.

client.js can check if window.nomoFilterMessages function exists, and use it to filter messages.

Make it easier to tinker with internals inside of a node_modules directory

Since everything is built with webpack right now, it's difficult to tinker with the code as a dependency of another project. I don't like this. It should be trivial to get up and going for development on Node Monkey or to just tinker when needed. At the same time, I don't want to lose the benefits of Webpack such as being able to use newer ES features, build optimizations, the ability to easily recompile and target different platforms or the ability to inject configuration into builds.

It might be possible to provide a simple script that can be run to set it up and start watching for changes. Would it also be possible to easily notify users dabbling in the code that they need to run the command for their changes to take effect?

Another interesting possibility could be to monitor the source files from Node Monkey itself when NODE_ENV is not set to production and if it sees changes it could post a notice to the console at the very least and maybe even automatically recompile.

output to app console

"As an alternative to viewing output through this page, you can also view output in the console of your own web application by including the following lines (adjust the host and port as necessary, this is based on the defaults)"

<script type="text/javascript" src="http://0.0.0.0:50500/socket.io/socket.io.js"></script> <script type="text/javascript" src="http://0.0.0.0:50500/lodash.js"></script> <script type="text/javascript" src="http://0.0.0.0:50500/cycle.js"></script> <script type="text/javascript" src="http://0.0.0.0:50500/client.js"></script>

So it seems I need to add this code somewhere to my server.js file, but when I call

$ node server.js
^

SyntaxError: Unexpected token <
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)
at node.js:951:3

of course this makes sense, but I don't really know how to do this in nodejs.
Can you help with a simple example?
Thanks

Rename?

I feel like Node Monkey is both awkward and nondescript. I could settle for either but I don't like both. Thoughts? Name suggestions?

crash with leatest lodash 3.*

Please change dependencies in package.json:
from

"dependencies": {
    "lodash": "*",
    "socket.io": "0.9.x"
},

to

"dependencies": {
    "lodash": "2.4.1",
    "socket.io": "0.9.x"
},

crash appear after invoke http://127.0.0.1:50500 in browser, and log is:

/www/node/test/nomo$ node app.js 
   info  - socket.io started
------------------
NodeMonkey started
To inspect output, open a browser to: http://127.0.0.1:50500
------------------


http.js:977
      throw new TypeError('first argument must be a string or Buffer');
            ^
TypeError: first argument must be a string or Buffer
    at ServerResponse.OutgoingMessage.end (http.js:977:13)
    at Server.<anonymous> (/www/node/test/nomo/node_modules/node-monkey/index.js:205:13)
    at Manager.handleRequest (/www/node/test/nomo/node_modules/node-monkey/node_modules/socket.io/lib/manager.js:588:28)
    at Server.<anonymous> (/www/node/test/nomo/node_modules/node-monkey/node_modules/socket.io/lib/manager.js:119:10)
    at Server.EventEmitter.emit (events.js:98:17)
    at HTTPParser.parser.onIncoming (http.js:2108:12)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
    at Socket.socket.ondata (http.js:1966:22)
    at TCP.onread (net.js:525:27)

RangeError: Maximum call stack size exceeded

my code is simple:

const nodeMonkey = require('node-monkey');
const Koa = require('koa');
nodeMonkey();
const app = new Koa();
app.use((ctx) => {
    let url = ctx.request.url;
    ctx.body = url;
    console.log(ctx);
});
app.listen(3000);

i want to log 'ctx' in chrome.
but i got this problem:

RangeError: Maximum call stack size exceeded
      at ServerResponse.get (_http_outgoing.js:114:16)
      at ServerResponse.getHeaders (/Users/cyw/Desktop/learnByself/koa2-gitbook-node/node_modules/restify/lib/response.js:177:17)
      at ServerResponse.get (_http_outgoing.js:115:17)
      at ServerResponse.getHeaders (/Users/cyw/Desktop/learnByself/koa2-gitbook-node/node_modules/restify/lib/response.js:177:17)
      at ServerResponse.get (_http_outgoing.js:115:17)
      at ServerResponse.getHeaders (/Users/cyw/Desktop/learnByself/koa2-gitbook-node/node_modules/restify/lib/response.js:177:17)
      at ServerResponse.get (_http_outgoing.js:115:17)
      at ServerResponse.getHeaders (/Users/cyw/Desktop/learnByself/koa2-gitbook-node/node_modules/restify/lib/response.js:177:17)
      at ServerResponse.get (_http_outgoing.js:115:17)
      at ServerResponse.getHeaders (/Users/cyw/Desktop/learnByself/koa2-gitbook-node/node_modules/restify/lib/response.js:177:17)

there is no recursive call in my code, how this happen?

this.iosrv: Object #<Server> has no method 'enable'

I'm running on OSX (I'm not sure if that's the reason) and I get this error:

Option log level is not valid. Please refer to the README.

.../node_modules/node-monkey/index.js:215
    this.iosrv.enable('browser client minification');
               ^
TypeError: Object #<Server> has no method 'enable'
    at NodeMonkey._.extend.start (.../node_modules/node-monkey/index.js:215:16)
    at Object.<anonymous> (.../bin/www:3:35)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

Changing the host and port makes no difference:

var nomo = require('node-monkey').start({host:'127.0.0.1', port: 3333});
var nomo = require('node-monkey').start({host:'127.0.0.1', port: 49151});

DeprecationWarning: process.EventEmitter

Running Node 6.1.0, I'm seeing the following warning on each reload. Is there a way to suppress or correct it?

(node:3684) DeprecationWarning: process.EventEmitter is deprecated. Use require('events') instead.  -- Called from internal/process/warning.js:24:17(function process.on)

image

With NodeMonkey service Express Router() Object is not showing query(Query Parameters) in request object

After Adding NodeMonkey debugging service, I am not getting Request Object Query String of query property in Request Object of Express Route(). I know it looks kind a strange but half day of strange debugging and issue solving results as NodeMonkey service is somehow not enabling query object to be generated in express route

I tested with express generated hello world ejs app & nodejs rest API app with express too. Here is the example when i tried to fire the request with postman

screenshot from 2018-01-21 16-00-53

And i have one more question. Previously (6 or 7 months before) i used the same kind of node-monkey module from npm. At that time that node-monkey is not a stable version, So i was depended on version 0.1.26 or something around 0. . Such an extent it used to work well and restart automatically when npm start triggers and it works well as like this on port number 50500. the way i used to integrate that is like this

eg: require(node-monkey).start({host:'localhost', port: 50500});
So is this repository is the one which i used previously ?

Auth failed: User 'guest' does not exist

when i start as per documentation:

let monkey = require('node-monkey')({});
monkey.attachConsole();

i see the message:
[WARN] No users detected. You can login with default user 'guest' and password 'guest' when prompted. This user will be disabled when you create a user account.

but when i try to log in as guest with guest the console gives:
Auth failed: User 'guest' does not exist

node-monkey: ^1.0.0-beta.4
node: 6.3.0
npm: 3.10.3

scripts not found

info - socket.io started

NodeMonkey started

To inspect output, open a browser to: http://localhost:5000

GET /socket.io/socket.io.js HTTP/1.1
Host: localhost:5000
Connection: keep-alive
Cache-Control: max-age=0
Accept: /
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36
DNT: 1
Referer: http://localhost:5000/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,pt;q=0.6
Cookie: io=9XZZK95WyrJvPVURAAAA; session_id=e466c802-9dc6-4ce4-af00-8bb1910da78a

Response headers: HTTP/1.1 404 Not Found
X-Powered-By: Express
Content-Type: text/html
Date: Thu, 26 Nov 2015 21:03:06 GMT
Connection: keep-alive
Content-Length: 35

It's looking for the file in:
http://localhost:5000/socket.io/socket.io.js

from the root of the filesystem directory: /node_modules/node-monkey/node_modules/socket.io/lib/socket.io.js

Not working on osx?

Hey! I've tried to get node-monkey working on osx, and it doesn't seem to load in chrome.

I've added it to my app, using:

  var nomo = require('node-monkey').start();

and get the following response:

debugger listening on port 5858
   info  - socket.io started
------------------
NodeMonkey started
To inspect output, open a browser to: http://0.0.0.0:50500
------------------

When I try and load http://0.0.0.0:50500 in Chrome, I get:

Oops! Google Chrome could not connect to 0.0.0.0:50500

Am I missing a step? I'm using node v0.10.17, and osx lion, and I can step through the app using node-inspector fine, but never get anything logged to monkey with console.log(...)....

Thanks!

No access to globals

How can I access global objects?

If I enter the name of a global variable, I get a ReferenceError: ... is not defined.

console.info

Why not supporting also console.info?
It is the only one missing among the filters of webkit console 😃
image

Cannot find module './build/Release/DTraceProviderBindings'

I got this error, when i require it.
const nodeMonkey = require('node-monkey');

error:
{ Error: Cannot find module './build/Release/DTraceProviderBindings' at Function.Module._resolveFilename (module.js:527:15) at Function.Module._load (module.js:476:23) at Module.require (module.js:568:17) at require (internal/module.js:11:18) at Object.<anonymous> (/Users/cyw/Desktop/自学/KOA2-gitbook笔记/node_modules/dtrace-provider/dtrace-provider.js:18:23) at Module._compile (module.js:624:30) at Object.Module._extensions..js (module.js:635:10) at Module.load (module.js:545:32) at tryModuleLoad (module.js:508:12) at Function.Module._load (module.js:500:3) code: 'MODULE_NOT_FOUND' }
my node version is 8.4.
I tried many ways, but it didn't work.

Better support console.trace

For an exception, the stack-trace is shown but the link addresses in the console all point at the console output code rather than where the exception happens.

Doesn't work with BrowserSync

When using BrowserSync, the page won't load -- I just see the spinner going round and round on the tab in Chrome. If I wrap require('node-monkey').start() in setTimeout(). However, that defeats the purpose since it causes node monkey to not start until all the server code has already run (and thus all logs output to Terminal).

Console and terminal styling bugs

  1. Colorizing in the terminal doesn't reset styles at the end of output. It messes up the terminal and requires a reset after to fix it.
  2. At least color styles don't seem to display properly in the built-in Firefox dev console, perhaps because it looks like terminal escape codes might be coming through? Something to investigate and make sure it works in the v0.3.0 branch.

Note that the default terminal coloring should be restored with \033[39m.

Integrating with arbitrary user authentication systems

It would be interesting and useful to be able to integrate with any user authentication system for any application that wants to use node-monkey. This may be possible by allowing users to be authorized through one or two different methods.

Method 1
Allow application to pass in user auth and permission data through the config when initializing. This is somewhat limited because it would require pre-loading all users into the config, even if there are a lot. Additionally, I don't know how password verification would work unless node-monkey just supported a lot of different password authentication schemes. This is likely not the approach to take.

Method 2
Allow the application to pass in an authorize callback which will be passed any credentials when a user desires to have access. It will also be given a callback which must be called with true|false indicating authorization and the list of commands the user has authorization to run, if true. This is likely the best approach and will be used unless something better comes to mind.

Note that any of the above authentication methods would likely only supplement any user accounts added via the official authentication mechanism built in to node-monkey.

Also, this system should play nicely with oauth. I'm not sure it would ever be a problem but it should be considered when developing it.

Not working in FF without Firebug

For console.log calls to be viewed in Firefox, Firebug must be used. The only way around it is to type console.exception = true in the console.

This is because of line 87 of lib/scripts/webconsole.js.

A way around this would be to add an option that allows FF users to specify if they do not wish to use Firebug.

screenshot from 2014-02-07 16 43 12

Server improvements

Things that need to happen:

  • Restify is too bulky for what's needed by default. At this point it's probably best to just use the built-in http module.
  • Files that need serving should exist in their own directory that is safe to serve publicly so it's possible to easily interact with static server middleware. In general they only want a static directory and it's difficult to specify exact files within the directory that should be served.
  • When given a server, we should be able to automatically add the needed routes.
  • There should be middleware available to inject the monkey.js script into the head of any HTML output sent by a provided server.

expose node-monkey stream if app already uses bunyan

It would be really nice if node-monkey expose a bunyan-stream for sending the data to the client web page. That way, if the app already uses bunyan (ours does!), then we can just hook in an additional stream to the bunyan logger.

Thoughts?

nomo.stop() throws error

In short:

this.iosrv.disconnect();
TypeError: undefined is not a function

Full output:

info: socket.io started
------------------
NodeMonkey started
To inspect output, open a browser to: http://127.0.0.1:50500
------------------

/Users/furkantunali/Sites/_Sandbox/NOD-paths/node_modules/node-monkey/index.js:328
    this.iosrv.disconnect();
               ^
TypeError: undefined is not a function
    at NodeMonkey._.extend.stop (/Users/furkantunali/Sites/_Sandbox/NOD-paths/node_modules/node-monkey/index.js:328:16)
    at Object.<anonymous> (/Users/furkantunali/Sites/_Sandbox/NOD-paths/index.js:7:6)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
[Finished in 0.363s]

Disable authentication on development

Is it possible to disable the authentication login during the development (i.e. on localhost) ?
Sometimes you need to restart the server often and nomo asks you for credential at each restart.

attachconsole is not a function

Hello, guys, first of all, awesome package. I don't what would I do without it. But I'm facing a problem and I can't understand what is it that I'm doing wrong since I'm following your documentation. Whenever I run my node application it crashes throwing this error:

monkey.attachConsole();
       ^
TypeError: monkey.attachConsole is not a function
    at Object.<anonymous> (/home/contrive/tawseel-backend/main.js:8:8)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

here is my code which

var monkey = require('node-monkey');
monkey.attachConsole();

production vs development vs debug

Firstly I just wanted to say this is one of the more clever packages for node projects that I've seen to date. Thank you for your continued effort with this.

Secondly to the questions/explanation for a feature enhancement.

Currently we would like to use your package in our site but it needs a little tweaking that seems to be best served in this package so we don't collide with your replaceConsole.

What we are looking for is a config setting that encompasses production, development and native node debug mode and a "null" mode. e.g. send console method messages to the equivalent of /dev/nul output.

I've done a little preliminary research into this and the following conditionals can achieve testing the environment:

// Usually invoked by deployment
var isProduction = process.env.NODE_ENV === 'production';
// Usually invoked by `$ node index.js`
var isDevelopment = process.env.NODE_ENV !== 'production';
// Usually invoked by `$ node debug index.js`
var isDebug = typeof v8debug === 'object';

What I am currently missing is a solid understanding of this project to commit a pull request at this time (this will most likely change hopefully in the near future) and matching some of your styling/naming conventions.

What I'd like to know is if you would be willing to add some variant of these to your options that encompasses all of these? I read the statement you have in the README.md of:

NodeMonkey is primarily designed for debugging and for now should only be used for such.

... which is one of our goals however since you said:

I haven't implemented any sort of authorization to prevent anyone from gaining access to the data that is dumped out.

... this feature request might be a good minimum start.

Please let me know and if I can assist in any additional way within my means. Thank you for the consideration... once again very "kewl" package.

Node monkey crash on browser connection

Hi! I start node, open browser window and get this error:

C:\shared_workspace\NodeAMQPTest>node server.js
   info  - socket.io started
------------------
NodeMonkey started
To inspect output, open a browser to: http://127.0.0.1:1337
------------------

No clients - buffering

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: This socket is closed.
    at Socket._write (net.js:618:19)
    at doWrite (_stream_writable.js:219:10)
    at writeOrBuffer (_stream_writable.js:209:5)
    at Socket.Writable.write (_stream_writable.js:180:11)
    at Socket.write (net.js:596:40)
    at Socket.Writable.end (_stream_writable.js:333:10)
    at Socket.end (net.js:395:31)
    at Static.gzip (C:\shared_workspace\NodeAMQPTest\node_modules\node-monkey\node_modules\socket.io\lib\static.js:207:14)
    at ready (C:\shared_workspace\NodeAMQPTest\node_modules\node-monkey\node_modules\socket.io\lib\static.js:370:14)
    at C:\shared_workspace\NodeAMQPTest\node_modules\node-monkey\node_modules\socket.io\lib\static.js:103:9```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.