Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Home page getting blank #8

Open
subhrajyotiw5rtc opened this issue Nov 1, 2014 · 4 comments
Open

Home page getting blank #8

subhrajyotiw5rtc opened this issue Nov 1, 2014 · 4 comments

Comments

@subhrajyotiw5rtc
Copy link

I used this app.js file and made my own app using angular.js.when i typed the my url name on the browser address bar the home page should loaded but in my case i am getting the home page as blank looks like white page.when i saw console i got one error after some second "http://localhost:8888/model" not found.Can you please help me for getting my full home page. Actually i am getting the following error in .
Unhandled document message:[c:null,d:null]
My App.js file is given below.
var racer = require('racer'),
express = require('express'),
cookieParser = require('cookie-parser'),
redis = require("redis").createClient(6379,'127.0.0.1'),
bodyParser = require('body-parser'),
user = require("redis").createClient(6379,'127.0.0.1'),
session = require('express-session'),
RedisStore = require('connect-redis')(session),
app = express();
var mongo = require('mongojs');
db = 'entries',
collections = ['admin,entries'],
db = mongo.connect('127.0.0.1:27017/'+db, collections);
htpp = require('http'),
server = htpp.createServer(app);
//Create Store for redis and mongodb
var store = racer.createStore({
server: server,
db: require('livedb-mongo')('127.0.0.1:27017/test?auto_reconnect', {
safe: true
}),
redis: require('redis-url').connect('redis://127.0.0.1: 6379')
});

console.log('store',store);

//MiddleWare
app.use(express.static(__dirname + '/public'));
app.use(express.static(__dirname));
app.use(require('racer-browserchannel')(store));
app.use(bodyParser.json({
limit: '50mb'
}));
app.use(bodyParser.urlencoded({
limit: '50mb',
extended: true
}));
app.use(cookieParser());
app.use(session({
secret: "kqsdjfmlksdhfhzirzeoibrzecrbzuzefcuercazeafxzeokwdfzeijfxcerig",
store: new RedisStore({
host: '127.0.0.1',
port: 6379,
client: redis
})
}));

app.get('/',function(req,res){
res.sendfile('views/home.html');
});

app.get('/model', function (req, res) {
var model = store.createModel();
model.subscribe('entries', function (err, entries) {
if (err) {
res.status(500);
res.send(err);
} else {
model.bundle(function (err, bundle) {
res.send(JSON.stringify(bundle));
});
}
});
});

store.bundle(__dirname + '/client.js', function (err, js) {
app.get('/script.js', function (req, res) {
res.type('js');
res.send(js);
});
});
server.listen(8888);
console.log('server listening at the port'+8888);
Please help me for the solution.

@Sebmaster
Copy link
Owner

This example hasn't been updated for a long time. I think racer has had a few API changes which most likely broke it, but I just made this as an example so I probably won't have any time to update this to a new version, sorry.

@subhrajyotiw5rtc
Copy link
Author

But i guess the problem is in mongodb . using this example i have already made one app.but in one app when server providing the home page,the home is loaded but looks blank.Can you please say why the below error arises.
Unhandled document message:[c:null,d:null]
Actually i am getting this error when the below code snippet started executing.

model.subscribe('entries', function (err, entries) {
if (err) {
res.status(500);
res.send(err);
} else {
model.bundle(function (err, bundle) {
res.send(JSON.stringify(bundle));
});
}
});

@raineorshine
Copy link

I'm also trying to get this to work. The official examples disappeared after racer 0.5.14. Can't get past "Unhandled document message:[c:null,d:null]".

@raineorshine
Copy link

Aha! https://github.com/derbyjs/racer-examples works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants