ngnjs / ngn Goto Github PK
View Code? Open in Web Editor NEWA systems development platform. A revamped portal is coming soon at:
Home Page: https://ngn.js.org
License: MIT License
A systems development platform. A revamped portal is coming soon at:
Home Page: https://ngn.js.org
License: MIT License
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.
var web = new NGN.web.Server ({
id: 'mongo',
routes: './routes/mongo',
port: port,
autoStart: false,
viewengine: 'jade',
views: './views',
processors: new NGNX.web.WebRequestHelper()
});
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)
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.
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
An event bus or a controller with an event bus to replace NGN.BUS.
Running the simplest of proxies gives me an error re: optional field "cache."
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'
=====================================================================
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.
From ngn-core created by coreybutler : ngnjs/ngn-core#3
The NGN.DATA.Store
has a clear() method, but there is no way to clear or reset a data model/record.
Create a man page and add to the docs site.
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.
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
Running the simplest of proxies gives me an error re: what i assume is about optional field "cache."
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'
=====================================================================
Need to shrinkwrap or freeze modules to avoid update conflicts.
Installing a single feature doesn't provide any feedback on the console.
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.
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.
A common TCP Server.
The ProxyCache is not saving the updated cache.json file after a successful POST /proxy/host
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
Desired:
Web Auth Strategies for:
Currently considering the passport module for this.
A command shortcut for version information. This should include the versions of each installed module.
A generic DNS server.
From ngn-core created by coreybutler : ngnjs/ngn-core#5
To recreate, see the codepen. Change the gender and click the undo button. It will fail. The pen is setup to output the arguments of the field.update
on the record, which shows the new
and old
values being the same.
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.
From ngn-core created by coreybutler : ngnjs/ngn-core#20
The event emitter should have a TTL capability to cleanup unnecessary handlers after a given duration.
A command to update all modules and the core framework.
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.
Common class to support clusters.
A common class to simplify server to server network communications. Should offer a higher level capability to use sockets & such.
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?
while attempting to start the most basic of API servers, I get the following errors (note I tried different port numbers on first error):
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)
>
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)
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?
An extension of the SmtpServer.... essentially a wrapper around the low level transport for the most common use cases.
Common Telnet Server.
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"
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"
}
]
}
}
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.
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.
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.
A wrapper to provide a familiar way to make AJAX requests.
Example:
NGN.Ajax.get({...})
NGN.Ajax.postt({...})
etc.
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.
The documentation needs a section regarding web templating... specifically noting how the template module must be installed separately from NGN.
Common FTP Server.
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.
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).
The installer should attempt to detect permission levels since most of the installation occurs in the npm global directory.
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.
The cache is not being loaded when the proxy server is started.
More common datasource connectors would be useful. I will only be implementing them as I have a need for them.
Optional Generic Connectors?
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.
Automatically deploy as a node-* background service.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.