export a railwaysjs as a module

15 views
Skip to first unread message

revington

unread,
Oct 23, 2012, 6:04:45 AM10/23/12
to rail...@googlegroups.com
Hi there,

I want to export a website builded with railwaysjs as a module.

index.js-----
var  app, hbs = require('hbs'),
    helpers = require('./app/helpers/Global_helper');
    app = module.exports = require('railway');
    helpers(app,hbs);
----

I want to load it with connect as a vhost

var connect = require('connect'),
    mywebsite= require('mywebsite'),
    app = connect(connect.logger());
app.use(connect.vhost('mywebsite.com', mywebsite));

app.listen(3000, function () {
    console.log(' listening');
});

log---
TypeError: Cannot read property 'root' of undefined
    at new ControllerBrigde (/mnt/code/........./node_modules/railway/lib/controller_brid
ge.js:2:28)
    at new Railway (/mnt/code/.........../node_modules/railway/lib/onrailway.js:43:29)
    at Object.initRailway [as init] (/mnt/code/............/node_modules/railway/lib/onrailw
ay.js:102:5)
    at Object.createServer (/mnt/code/............/node_modules/railway/lib/onrailway.js:176
:13)
    at Object.<anonymous> (/mnt/code/........./index.js:4:43)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:32)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)


What I'm doing wrong?

Sorry, I can not post more code. Company rules.

Regards,

Pedro

Anatoliy Chakkaev

unread,
Oct 23, 2012, 6:13:07 AM10/23/12
to rail...@googlegroups.com
Hi man, all you are doing is fine. Railway is not fine. A week ago i've started branch where this issue fixed and you can export/import railway apps as modules, bundle them together, etc. It makes existing API not compatible with new, because it requires eliminating all global variables we're using now. That issue was from the beginning, and finally i've make hard decision to change this API with no backward compatibility in next major release. Release preview of railway will be available by the end of this week (or maybe next).



--
The official community of RailwayJS
 
website: railwayjs.com,
source: https://github.com/1602/express-on-railway,
---
You received this message because you are subscribed to the Google Groups "RailwayJS" group.
To post to this group, send email to rail...@googlegroups.com.
Visit this group at http://groups.google.com/group/railwayjs?hl=en.
 
 



--
Thanks,
Anatoliy Chakkaev

revington

unread,
Oct 23, 2012, 7:04:26 AM10/23/12
to rail...@googlegroups.com
Great!

Thank you Anatoliy.
You saved my day.

Regards,

Pedro

Anatoliy Chakkaev

unread,
Oct 23, 2012, 7:06:18 AM10/23/12
to rail...@googlegroups.com
I hope you come back to us, once I will release something you can play with.
Reply all
Reply to author
Forward
0 new messages