GithubHelp home page GithubHelp logo

ngnjs / ngn Goto Github PK

View Code? Open in Web Editor NEW
61.0 7.0 16.0 6.67 MB

A systems development platform. A revamped portal is coming soon at:

Home Page: https://ngn.js.org

License: MIT License

JavaScript 100.00%
javascript nodejs deno browser web eventemitter middleware queue data data-model

ngn's People

Contributors

aylusltd avatar coreybutler avatar gbdrummer 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngn's Issues

2 webserver issues (alpha.17+)

I see at least one issue, and one potential issue involving a small program I have written.

There are three files involved: eventionary.js, root.js (included in the correct subfolder), and index.jade. This worked on previous versions (up to and including 16), and now when visiting localhost:3000 I simply get a "Not Found" at the top of the screen.

eventionary.js

  var web = new NGN.web.Server ({
              id:            'mongo',
              routes:        './routes/mongo',
              port:          port,
              autoStart:     false,
              viewengine: 'jade',
              views: './views',
              processors:      new NGNX.web.WebRequestHelper() 
          });

root.js

  module.exports = {
          '/':{
                get: function(req,res){
              res.render('index.jade', { title: 'Welcome to the Eventionary' });
              }}}

Also, another potential issue I see is that in res.render, I have to type in ".jade" even though I've specified jade in the "viewengine" portion of the web server declaration. Is this normal behavior? When I try plain "res.render('index')" I get the following:

  Error: Failed to lookup view "index"
  at Function.app.render (node_modules\NGN\node_modules\express\lib\application.js:493:17)

Add sync or mirror functionality to data store

From ngn-core created by gbdrummer : ngnjs/ngn-core#1

We currently don't have an automated way to relay events from one store to another. For example, if I am storing different pieces of data about a particular UI element in multiple different stores, we now have to manually track down the data in each store and update it.

It would be nice to have a way to link different bits of data in different stores.

Cannot read property 'myapp' of undefined

When using NGN.define to create an extended API, it fails to load the namespace properly.

node_modules/ngn/lib/NGN.js:376
            if (pkg[ns[i].trim()] == undefined)
                   ^
TypeError: Cannot read property 'myapp' of undefined

proxy cache optional, but throws error when not specified

Running the simplest of proxies gives me an error re: optional field "cache."

Running NGN v0.0.1-alpha.20
  proxy.js

  require('NGN');
        var proxy = new NGNX.web.Proxy();

>node proxy.js

  =====================================================================
  Error: Cannot find module '\node_modules\NGN\lib\ngnx\web\cache.json'
  =====================================================================

ProxyController fails to load target on POST /proxy/host

When doing a POST /proxy/host with the proper JSON, the target is not actually added to the cache or the proxy server. The only way to make it work is to add the target using the POST /proxy/from/<server.com>/<port>/to/<destination.com>/<destination_port> endpoint.

defining assets on webserver gives deprecated warning

var web = new NGN.web.Server ({

            assets:     './public',

        });

defining assets inside of a web server gives the following warning while running:

node eventionary.js
Running NGN v0.0.1-alpha.21
The server is ready & waiting on port 3000
connect.staticCache() is deprecated and will be removed in 3.0
use varnish or similar reverse proxy caches.

Cannot call method 'on' of undefined

When extending NGN.core, the following error is thrown when trying to listen to an event.

ngn/lib/NGN.core.js:128
                        this._emitter.on(eventName, callback || function(){});
                                      ^
TypeError: Cannot call method 'on' of undefined

proxy cache optional, but throws error when not specified

Running the simplest of proxies gives me an error re: what i assume is about optional field "cache."

Running NGN v0.0.1-alpha.20
  proxy.js
  -----------
  require('NGN');
        var proxy = new NGNX.web.Proxy();

>node proxy.js

  =====================================================================
  Error: Cannot find module '\node_modules\NGN\lib\ngnx\web\cache.json'
  =====================================================================

Module Freeze

Need to shrinkwrap or freeze modules to avoid update conflicts.

"message": "Object [object Object] has no method 'addRewriteRule'"

Running NGN v0.0.1-alpha.21

Staring with a fresh cache.json template (see previous issue), I attempted POSTing the following json

    {
            "hostname": "localhost",
            "port": 8677,
            "rules": {
                "GET": [
                    {
                        "pattern": {},
                        "substitute": "api.cfm?v=1&fn=$1",
                        "path": null,
                        "last": false,
                        "rewritten": false,
                        "acceptMethod": [
                            "GET",
                            "POST",
                            "PUT",
                            "DELETE",
                            "HEAD",
                            "TRACE"
                        ]
                    },
                    {
                        "pattern": {},
                        "substitute": "api.cfm?v=2&fn=$1",
                        "path": null,
                        "last": false,
                        "rewritten": false,
                        "acceptMethod": [
                            "GET",
                            "POST",
                            "PUT",
                            "DELETE",
                            "HEAD",
                            "TRACE"
                        ]
                    }
                ],
                "ALL": [
                    {
                        "pattern": {},
                        "substitute": "api.cfm?v=3&fn=$1",
                        "path": null,
                        "last": false,
                        "rewritten": false,
                        "acceptMethod": [
                            "GET",
                            "POST",
                            "PUT",
                            "DELETE",
                            "HEAD",
                            "TRACE"
                        ]
                    },
                    {
                        "pattern": {},
                        "substitute": "api.cfm?path=$1",
                        "path": null,
                        "last": false,
                        "rewritten": false,
                        "acceptMethod": [
                            "GET",
                            "POST",
                            "PUT",
                            "DELETE",
                            "HEAD",
                            "TRACE"
                        ]
                    }
                ]
            },
            "target": [
                "localhost:8383"
            ],
            "alias": [
                "127.0.0.1"
            ]
        }

I received a 500 (Internal server) error stating the following:

"message": "Object [object Object] has no method 'addRewriteRule'"

cache.json was still updated, and currently looks like this:

{
    "remote": null,
    "cache": [
        {
            "hostname": "localhost",
            "port": 8677,
            "alias": [
                "127.0.0.1"
            ],
            "target": [],
            "rules": {}
        }
    ]
}

Node did not crash.

route processing no longer functioning correctly

alpha.21

in previous versions, the following root.js file would function correctly

module.exports = {

        '/':{

            get: function(req,res){

    res.render('index.jade', { title: 'Welcome to the Eventionary' });

            }
        },

        '/errCodes':{
            get: function(req, res){


            res.render('errCodes', {title : 'The Eventionary', entry: doc});
        }
}
}

using a webserver such as this

        var web = new NGN.web.Server ({
            id:            'mongo',
            routes:        './routes/mongo',
            port:          port,
            autoStart:     false,
            assets:     './public',
            viewengine: 'jade',
            views: './views',
            processors:    new NGNX.web.WebRequestHelper()
        });

when I plug localhost:3000 into the browser, I receive a "Not Found" at the top. Same for every page I try to load. Removing the "processors" line from the web server declaration allows me to view localhost:3000, but I still get a "Not Found" when trying to go to /errCodes.

Declaring assets in webserver results in ReferenceError: fs is not defined

Using alpha.18

When entering anything but a blank ' ' in the assets declaration of a new webserver, I am presented with the following error, even with directories that exist. Line 36 of eventionary.js is the web.start(); function --

      ========================================
      ReferenceError: fs is not defined
      ========================================

      On line #366, column #11
      node_modules\NGN\lib\web\Server.js
      Function: Base.extend.start

      On line #36, column #13
      C:\Users\Kevin\workspace\four\eventionary.js
      Function:

      On line #449, column #26
      module.js
      Function: Module._compile

      On line #467, column #10
      module.js
      Function: Object.Module._extensions..js

      On line #356, column #32
      module.js
      Function: Module.load

      On line #312, column #12
      module.js
      Function: Function.Module._load

      On line #492, column #10
      module.js
      Function: Module.runMain

      On line #244, column #9
      node.js
      Function: process.startup.processNextTick.process._tickCallback

      events.js:66
              throw arguments[1]; // Unhandled 'error' event

Simplified Clients & Common Servers

Desired:

  • NGN.ftp.Server
  • NGN.ftp.Client
  • NGN.dns.Server
  • NGN.web.Socket

Web Auth Strategies for:

  • OAuth
  • Facebook
  • etc...

Currently considering the passport module for this.

Add ngn -v

A command shortcut for version information. This should include the versions of each installed module.

Reserved Words

From ngn-core created by coreybutler : ngnjs/ngn-core#2

The reserved words of the model are throwing an error. There should be a warning that the reserved cannot be used in the model.

Use case: I tried to define an attribute called modified, which failed because there is a reserved attribute of the same name on the model.

NGN.NullIf

From ngn-core created by coreybutler : ngnjs/ngn-core#10

It would be nice to have a method similar to SQL's NULLIF method that returns null for blank strings.

if (NGN.NullIf(myvar, 'value') === null) {
  console.log('Variable had a value of "value", which is considered null')
}

// or

if (NGN.NullIfEmpty(myvar) === null) {
  console.log('Empty variable whose trimmed length is 0')
}

// or just

if (NGN.NullIf(myvar) === null) {
  console.log('Empty variable whose trimmed length is 0')
}

This method could be used on namespaced objects as well, so my.nonexistant.scope doesn't throw an error but instead returns null.

This would also be helpful in coalesce statements that are looking for defined, non-null, & non-blank values. Perhaps a NGN.coalesceb() (b for blank) would make it simpler to wrap a nullif around each argument.

NGN.net.Connection

A common class to simplify server to server network communications. Should offer a higher level capability to use sockets & such.

Links to documentation etc. not working

When following the link in this project's description to ngn.js.org, neither the GitHub link (which, I guess, should link back here) nor the documentation link are working.

Where to find documentation/examples?

API Server Errors

alpha.19

while attempting to start the most basic of API servers, I get the following errors (note I tried different port numbers on first error):

with port declared
  var port = 8080;

  var web = new NGN.web.API({
  port: port,
  });

  web.start(
        console.log('The server is ready & waiting on port '.green+port.toString().green.bold)
  );

>node eventionary.js

  Running NGN v0.0.1-alpha.19
  The server is ready & waiting on port 8080

  events.js:66
        throw arguments[1]; // Unhandled 'error' event
                                         ^
  Error: listen EADDRINUSE
      at errnoException (net.js:776:11)
      at Server._listen2 (net.js:915:14)
      at listen (net.js:942:10)
      at Server.listen (net.js:1000:9)
      at dns.js:71:18
      at process.startup.processNextTick.process._tickCallback (node.js:244:9)

without port declared (should default)

>node eventionary.js

      Running NGN v0.0.1-alpha.19
      //commented line out about
      //listening on port xxx, since no port defined, otherwise this will fail as well

      events.js:66
              throw arguments[1]; // Unhandled 'error' event
                                              ^
      Error: listen EACCES
          at errnoException (net.js:776:11)
          at Server._listen2.self._handle.onconnection (net.js:900:28)
          at process.startup.processNextTick.process._tickCallback (node.js:244:9)

new web proxy fails

I'm 99% sure this worked in alpha 31.

however, with the latest changes, I receive the following error when running

require('ngn');
NGN.application(function(){

    var proxy = new NGNX.web.Proxy({
 //       cache: './cache.json' // Optional
    }); 

});
C:\Users\Kevin\workspace\NGN_latest\lib\bootstrap.js:69
Object.defineProperty(global,'NGNX',{
       ^
TypeError: Cannot redefine property: NGNX
    at Function.defineProperty (native)
    at Object.<anonymous> (C:\Users\Kevin\workspace\NGN_latest\lib\bootstrap.js:
69:8)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (C:\Users\Kevin\workspace\NGN_latest\examples\customap
i\EXAMPLE\Person.js:1:63)
    at Module._compile (module.js:449:26)

I'm not sure why the mocha test appears to be running the proxy fine, but a standalone file fails?

NGN.core.MailServer

An extension of the SmtpServer.... essentially a wrapper around the low level transport for the most common use cases.

proxy: unable to create virtual host

alpha.20 -- running the example code with the number comments on http://coreybutler.github.com/NGN/docs/#!/guide/proxycontroller

The REST Client I'm using is cREST in google chrome.

I'm able to GET information about a specific host, and I was also able to DELETE a virtual host, but when I try POSTing a new host, I get the following error:

400 POST http://localhost:3000/proxy/host/ -- "Missing attribute: hostname"

Bear with me, I'm still flopping around the concept of proxy and the syntax of the JSON.

The code I POSTed was this, basically a carbon copy of the JSON I retrieved with a GET, but with a changed port number.

  {
      "hostname": "localhost",
      "port": 2650,
      "alias": [
          "127.0.0.1"
      ],
      "target": [
          "localhost:8383"
      ],
      "rules": {
          "GET": [
              {
                  "/api/v1/(.*)$": "api.cfm?v=1&fn=$1"
              },
              {
                  "/api/v2/(.*)$": "api.cfm?v=2&fn=$1"
              }
          ],
          "ALL": [
              {
                  "/api/v3/(.*)$": "api.cfm?v=3&fn=$1"
              },
              {
                  "(.*)/test": "api.cfm?path=$1"
              }
          ]
      }
  }

no proxy cache specified, EISDIR error

Running NGN v0.0.1-alpha.21

I started a proxy server/controller with no cache specified. When I try to create/POST a virtual host, I get a 201 created error, but node craps out, citing the following error:

>node proxy.js

WARNING: Cannot find module 'C:\Users\Kevin\workspace\proxy\node_modules\ngn\lib
\ngnx\web\cache.json'. Using C:\Users\Kevin\workspace\proxy\cache.json instead.
Proxy Controller is ready

Functioning properly up til this point. The following block comes after the POST request.

========================================
Error: EISDIR, open 'C:\Users\Kevin\workspace\proxy'
========================================

events.js:66
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: EISDIR, open 'C:\Users\Kevin\workspace\proxy'

Also note that no .json file is created.

Add Non-Empty Validator for Data Model Strings

From ngn-core created by coreybutler : ngnjs/ngn-core#7

Add an optional non-empty validator for strings that may be blank. Without this, it's possible to have a zero-length string, which will pass String type validation and meet the requirements of not being null. However; there are enough use cases where a non-empty string are required that it should be part of the core library.

NGN.core.SmtpServer

Common SMTP Server.

Some work has already been done for this. It is possible to send mail using some existing classes in the library (based on node_mailer), as well as some extended classes in NGNX. The goal of a generic SMTP server is to provide a base class that can be used to build custom mail servers capable of sending and receiving messages (i.e. full stack).

This is a lower priority since so much work has already been done with node_mailer. It is also a large undertaking for a use case I don't have to fill right now. This class would really be for library completeness.

NGN.Ajax

A wrapper to provide a familiar way to make AJAX requests.

Example:

NGN.Ajax.get({...})

NGN.Ajax.postt({...})

etc.

ProxyController REST failure for Rules

When POSTing

{
    "ALL": [
        {"/api/v4/(.*)$": "api.cfm?v=4&fn=$1"}
     ]
}

to

http://localhost:3000/proxy/host/localhost/7770/rule

a 400 "Missing attribute: pattern and/or substitute" is returned.

Templating Documentation

The documentation needs a section regarding web templating... specifically noting how the template module must be installed separately from NGN.

NGN.BUS event-based warnings

From ngn-core created by coreybutler : ngnjs/ngn-core#17

Instead of console.warn messages for potential coding issues, classes should fire NGN.WARNING events instead. The debugging version of the app should show these warnings by default, and NGN should have a preference for enabling warnings production (off by default).

Other types of events may be useful as well, such as NGN.PERFORMANCE, NGN.EXPERIMENTAL, NGN.DEPRECATED, etc. They may also have further scope such as NGN.WARNING.DATA.keywordField.

The UI devtools should automatically listen to the BUS for this. The NGN bridge should do something similar for the SDK.

Proxy cache defaults to directory, not file

I am able to successfully create a proxy server while specifying "./cache.json" in the cache file.

In my code, I also console.log the cache path. When I do specify it, it logs like

"path/to/cache/cache.json."

When I comment out the cache line, I receive the following:

WARNING: Cannot find module 'C:\Users\Kevin\workspace\proxy\node_modules\ngn\lib
\ngnx\web\cache.json'. Using C:\Users\Kevin\workspace\proxy\cache.json instead.

C:\Users\Kevin\workspace\proxy <<-----this is the new logged cache path
Proxy Controller is ready

Even though I DO have that cache.json where it says it is "using it instead," it will not run correctly (it looks like it is only pointing to the directory, and not the actual cache file itself).

TypeError: Object [object Object] has no method 'onError'

    x:\\node_modules\NGN\lib\web\Server.js:389
                                    this.onError(e);
                                            ^
    TypeError: Object [object Object] has no method 'onError'

This latest cause of this error is a missing "routes" folder inside an NGN.Web.Server declaration. If the routes folder is nonexistent, this will occur. If the folder is empty but exists, no error occurs.

Please let me know if this is not an issue that warrants putting here.

More Datasource Connectors

More common datasource connectors would be useful. I will only be implementing them as I have a need for them.

  • Generic SQL (may need in next few weeks)
  • MySql (may need in next few weeks)
  • PostgreSql
  • Oracle
  • SqlServer
  • Azure
  • CoundDb
  • Neo4j
  • Cassandra
  • Hadoop

Optional Generic Connectors?

  • Document
  • Graph
  • KeyValue
  • Xml
  • Json
  • Memory

MongoDB -- TypeError: Object [object Object] has no method 'createDatasource'

Running NGN v0.0.1-alpha.21

I have the following code in mongo.js

    var database = new NGN.datasource.MongoDB({
        id: 'event_orm',
        host:       'staff.mongohq.com',
        port:       10010,
        database:   'users',
        username:   'username',
        password:   'password',
    });

When I try running it, I get the following error:

>node mongo.js

C:\Users\Kevin\workspace\four\node_modules\NGN\lib\datasource\Connection.js:232
                __NGN.createDatasource(this._name,this);
                      ^
TypeError: Object [object Object] has no method 'createDatasource'
    at Base.extend.registerAsDatasource (C:\Users\Kevin\workspace\four\node_modu
les\NGN\lib\datasource\Connection.js:232:13)
    at Base.extend.constructor (C:\Users\Kevin\workspace\four\node_modules\NGN\l
ib\datasource\Connection.js:213:14)
    at new Base.extend.constructor (C:\Users\Kevin\workspace\four\node_modules\N
GN\lib\datasource\MongoDB.js:69:33)
    at Object.<anonymous> (C:\Users\Kevin\workspace\four\mongo.js:3:10)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

NOTE: I reverted to alpha.16 and was able to run similar code. I think this error started appearing in .17.

Deployment

Automatically deploy as a node-* background service.

npm uninstall -g ngn leaves addons

after running

npm uninstall -g ngn

the addons are still left behind. here's a screen cap i did after a global uninstall/reinstall:
capture

Granted, it updated the necessary addons, but still, users might want everything removed on uninstall.

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.