YouHusam / hanx.js

Full-stack Javascript boilerplate with NodeJS, HapiJS, PostgreSQL and AngularJS
Other
23 stars 5 forks source link

signup issue #5

Closed saurabhghewari closed 8 years ago

saurabhghewari commented 8 years ago

Hi, I am new to hapijs and hnax.js boilerplate. I have configured the hanx.js on my system. Pages are visible in browser, but when i hit signup button by filling the details, it gives me error as "cannot read property of undefined user", "request.colletions.user" . This is the complete error stack:-

TypeError: Uncaught error: Cannot read property 'user' of undefined at exports.signup (/home/saurabh/NodeProjects/HapiExamples/hanx.js/app/controllers/users/users.authentication.server.controller.js:32:33) at Object.internals.handler (/home/saurabh/NodeProjects/HapiExamples/hanx.js/node_modules/hapi/lib/handler.js:93:36) at /home/saurabh/NodeProjects/HapiExamples/hanx.js/node_modules/hapi/lib/handler.js:28:23 at internals.Protect.run (/home/saurabh/NodeProjects/HapiExamples/hanx.js/node_modules/hapi/lib/protect.js:56:5) at exports.execute (/home/saurabh/NodeProjects/HapiExamples/hanx.js/node_modules/hapi/lib/handler.js:22:22) at /home/saurabh/NodeProjects/HapiExamples/hanx.js/node_modules/hapi/lib/request.js:377:13 at iterate (/home/saurabh/NodeProjects/HapiExamples/hanx.js/node_modules/hapi/node_modules/items/lib/index.js:35:13) at done (/home/saurabh/NodeProjects/HapiExamples/hanx.js/node_modules/hapi/node_modules/items/lib/index.js:27:25) at /home/saurabh/NodeProjects/HapiExamples/hanx.js/node_modules/hapi/node_modules/hoek/lib/index.js:849:22 at nextTickCallbackWith0Args (node.js:419:9) at process._tickDomainCallback (node.js:389:13)

I have made some changes in db connetion. Instead of using PG used mysql with sails-mysql adapter. I have just replaced require('sails-postgre') to ('sails-mysql'). Nothing else have been changed, variables are as they are.

I am unable to get, how collections are attached with request object?

Please, help!!!

YouHusam commented 8 years ago

Hi, looks like your problem is a configuration problem, a good place to start is in the Dogwater and Waterline-ORM documentation.

https://github.com/devinivy/dogwater

saurabhghewari commented 8 years ago

Thanks for the quick reply. I executed the Dogwater example and its fine. But still I didnt find in hanx.js, why request object is not getting collections object. request.collections shows undefined when consoled. can you please take a look into the code. Below is the code, what i have tried file:- users.authentication.server.controller { path: '/auth/signup', method: 'POST', handler: fucntion(request, reply){ console.log(request.collections);// prints undefined }//users.signup },

As per the dogwater docs, request.collections should work atleast in route file. Some how the refrence is missing somewhere, and I am unable to find it.

Please, can you help me sorting this out.

saurabhghewari commented 8 years ago

Ok, After digging into the code, I got it. server.register(plugins, function(err){}) is not registering all the plugins. just console.log(server.plugins) which ptints

{ bell: { oauth: { v1: [Function], v2: [Function], Client: [Object] } }, inert: { _etags: LRUCache { _max: 1000, _lengthCalculator: [Function: naiveLength], _allowStale: false, _maxAge: null, _dispose: undefined, _cache: {}, _lruList: {}, _mru: 0, _lru: 0, _length: 0, _itemCount: 0 }, _pendings: {} } } and nothing else.

Note:- I get this firing grunt, Segmentation fault (core dumped) right below above plugin.

Is that stopping server to register more plugins?

saurabhghewari commented 8 years ago

Hi, I found the answer for my question. Actually, having ID as text in models was creating an error. I turned the autoPK to true and removed the ID from attributes of models. Error resolved and plugin also loaded successfully. Thank you for your reply. Also thank you for HANX.js team making the folder architecture available. Great work and architecture.

YouHusam commented 8 years ago

Great news. Thank you and good luck with your project