Giter VIP home page Giter VIP logo

racer-example's People

Contributors

sebmaster avatar

Stargazers

 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

racer-example's Issues

Error in script.js page

Hello,I was testing this Github example ,When i checked that check box ,the "ng-change="save(data)" statement will excute,but i while running i am getting the following error.Can you try to resolve this error or find out anything i am missing.

Error:
TypeError: Cannot read property 'constructor' of null
at extendObject (http://localhost:8888/script.js:6:11)
at extendObject (http://localhost:8888/script.js:23:15)
at extendObject (http://localhost:8888/script.js:28:11)
at extendObject (http://localhost:8888/script.js:23:15)
at extendObject (http://localhost:8888/script.js:28:11)
at extendObject (http://localhost:8888/script.js:23:15)
at extendObject (http://localhost:8888/script.js:28:11)
at Model.model.get (http://localhost:8888/script.js:52:20)
at Object.TodoCtrl.$scope.save (http://localhost:8888/app.js:21:32)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js:74:98

How to run the example?

I finally got around to wanting to see this example running and polishing it up with some refactoring and adding validation and authorization logic etc. However, having trouble running it...

The README is very brief on this.

$ node app.js
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
$ redis-server
[20051] 16 Nov 11:38:18.628 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
[20051] 16 Nov 11:38:18.632 * Max number of open files set to 10032
[20051] 16 Nov 11:38:18.632 # Opening port 6379: bind: Address already in use
$ mongod
Sat Nov 16 11:41:30 [initandlisten] MongoDB starting : pid=20086 port=27017 dbpath=/usr/local/var/mongodb 64-bit host=kristiadrupsair
Sat Nov 16 11:41:30 [initandlisten]
Sat Nov 16 11:41:30 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Sat Nov 16 11:41:30 [initandlisten] db version v2.2.3, pdfile version 4.5
Sat Nov 16 11:41:30 [initandlisten] git version: f570771a5d8a3846eb7586eaffcf4c2f4a96bf08
Sat Nov 16 11:41:30 [initandlisten] build info: Darwin bs-osx-106-x86-64-1.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_49
Sat Nov 16 11:41:30 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/usr/local/etc/mongod.conf", dbpath: "/usr/local/var/mongodb" }
Sat Nov 16 11:41:30 [initandlisten] exception in initAndListen: 10310 Unable to lock file: /usr/local/var/mongodb/mongod.lock. Is a mongod instance already running?, terminating

So both mongod and redis db servers are clearly running locally.

I go to http://localhost:8081/ enter a value in the input like hello and press ENTER or submit and nothing happens :(

I made a small change in the code to use the local mongo and redis databases. Shouldn't this work? What am I missing? Please update the README to give more details for running it. Thanks Seb :)

var racer = require('racer');
var express = require('express');

var app = express();
var http = require('http');
var server = http.createServer(app);

var livedb_mongo = require('livedb-mongo')
var livedb = livedb_mongo('localhost:27017/test?auto_reconnect', {safe:true});
var redis = require('redis-url').connect();

var store = racer.createStore({
    server: server,
    db:         livedb,
  redis:    redis
});

racer init magic :O

Hi Sebastian,

I'm still trying to wrap my head around your magic code. This part is still very much magic to me!

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));
                        });
                }
        });
});

// huh!?
store.bundle(__dirname + '/client.js', function (err, js) {
        app.get('/script.js', function (req, res) {
                res.type('js');
                res.send(js);
        });
});

And on the client you init racer using:

                $http.get('/model').success(function (data) {
                        racer.init(data);
                });

How does this all work? Especially the last part: store.bundle is very cryptic!
Looks like you are sending a complete script.js file back to the client. Does this file contain the whole racer model as json, which is then evaluated on the client and stored as the local racer model on first connect? Wauw!

I would like to achieve the same kind of magic using socket.io. Could you help me achieve this perhaps?
Thanks :)

Provide LocalHost configurations

Provide a default of localhost configurations but check for ENV REDISCLOUD_URL and MONGOLAB_URI and if they are set use those instead.

Home page getting blank

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.

Error when running

Hi there,

First off, thanks for putting this example together. I setup a mongolab db and I have a local redis instance running on port 6379.

when i run the node app I am able to browse to the Todo form, however when I try to add an entry Node prints out this error:

Error: Cannot use a writeConcern without a provided callback
at Db.ensureIndex (/Library/WebServer/Documents/racer-example/node_modules/livedb-mongo/node_modules/mongoskin/node_modules/mongodb/lib/mongodb/db.js:1218:11)
at Collection.ensureIndex (/Library/WebServer/Documents/racer-example/node_modules/livedb-mongo/node_modules/mongoskin/node_modules/mongodb/lib/mongodb/collection.js:1094:11)
at EventEmitter. (/Library/WebServer/Documents/racer-example/node_modules/livedb-mongo/node_modules/mongoskin/lib/mongoskin/utils.js:68:23)
at EventEmitter.g (events.js:175:14)
at EventEmitter.emit (events.js:98:17)
at null. (/Library/WebServer/Documents/racer-example/node_modules/livedb-mongo/node_modules/mongoskin/lib/mongoskin/collection.js:129:24)
at Db.collection (/Library/WebServer/Documents/racer-example/node_modules/livedb-mongo/node_modules/mongoskin/node_modules/mongodb/lib/mongodb/db.js:484:44)
at null. (/Library/WebServer/Documents/racer-example/node_modules/livedb-mongo/node_modules/mongoskin/lib/mongoskin/collection.js:119:12)
at SkinDb.open (/Library/WebServer/Documents/racer-example/node_modules/livedb-mongo/node_modules/mongoskin/lib/mongoskin/db.js:79:19)
at SkinCollection.open (/Library/WebServer/Documents/racer-example/node_modules/livedb-mongo/node_modules/mongoskin/lib/mongoskin/collection.js:114:19)

I also see a failed GET request in Chrome console which prints out:

GET http://localhost:8081/channel/test?OSID=5iy6efx9&OAID=2&VER=8&MODE=init&zx=jv5oxj5lng2p&t=1 bcsocket-uncompressed.js:1818

Thanks!

Nolan

Still error: "Modifiers and non-modifiers cannot be mixed"

The error is occurring while I am adding a todo.

Trace: { [MongoError: Modifiers and non-modifiers cannot be mixed]
  name: 'MongoError',
  err: 'Modifiers and non-modifiers cannot be mixed',
  code: 10154,
  n: 0,
  connectionId: 4,
  ok: 1 } at D:\node\racer-example\node_modules\racer\node_modules\share\lib\server\se
ssion.js:591:19 at D:\node\racer-example\node_modules\racer\node_modules\share\lib\server\us
eragent.js:294:23 at D:\node\racer-example\node_modules\racer\node_modules\share\node_modules\
livedb\lib\index.js:511:31 at null.<anonymous> (D:\node\racer-example\node_modules\livedb-mongo\node_mo
dules\mongoskin\node_modules\mongodb\lib\mongodb\collection.js:477:9)
    at g (events.js:175:14) at EventEmitter.emit (events.js:106:17)
    at Server.Base._callHandler (D:\node\racer-example\node_modules\livedb-mongo\node_modules\mongoskin\node_modules\mongodb\lib\mongodb\connection\base.js:130:25) at D:\node\racer-example\node_modules\livedb-mongo\node_modules\mongoskin\node_modules\mongodb\lib\mongodb\connection\server.js:522:20 at MongoReply.parseBody (D:\node\racer-example\node_modules\livedb-mongo\node_modules\mongoskin\node_modules\mongodb\lib\mongodb\responses\mongo_reply.js:132:5) at null.<anonymous> (D:\node\racer-example\node_modules\livedb-mongo\node_mo
dules\mongoskin\node_modules\mongodb\lib\mongodb\connection\server.js:481:22)

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.