Giter Site home page Giter Site logo

azat-co / rpjs Goto Github PK

View Code? Open in Web Editor NEW
188.0 25.0 118.0 873 KB

Rapid Prototyping with JS examples. Rapid Prototyping with JS is a JavaScript and Node.js book that will teach you how to build mobile and web apps fast.

Home Page: http://rapidprototypingwithjs.com

JavaScript 96.45% HTML 3.54% ApacheConf 0.01% CSS 0.01% PHP 0.01%

rpjs's Introduction

Rapid Prototyping with JS examples

UPDATE: I'm publishing the new, updated and revised version of this book under the new title Fullstack JavaScript. Go to http://github.com/azat-co/fullstack-javascript for more details.

Rapid Prototyping with JS is a JavaScript and Node.js book that will teach you how to build mobile and web apps fast. — Read more at http://rapidprototypingwithjs.com.

Part II — Building Front-End Application

Part III — Building Back-End Application

  • hello

    NodeJS "Hello World" app, ready for deployment

  • test

    Chat back-end: TDD with run-time storage

  • db

    Simple app to test local database connection with MongoDB Native Driver

  • mongo

    Chat back-end: MongoDB storage, ready for deployment

Part IV — Putting it All Together

  • board

    Chat front-end without back end

  • node

    Chat back-end with CORS

Part V — Beyond Core Modules

rpjs's People

Contributors

azat-co avatar cpcerrato avatar fobo66 avatar hudsonpereira avatar zerolinux5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpjs's Issues

$ in tr

var trEl =$('<tr><td>'

        + value.username
        + '</td><td>'
        + value.message +
        '</td></tr>');

"I think you don't need the $ sign in the beginning as we are just constructing an html string literal. Once I removed it, I was able to see the table format of username / message"

' vs. "

On page 9, under the Array object heading:
var arr = ["apple", "orange", 'kiwi"];

'kiwi" has mismatching single and double quotes. It shows up incorrectly colored on the page due to the mismatch.

val()

To obtain the username/message through jQuery 1.10.2, I could not use the recommended syntax -- got "undefined" in the Firebug console:

$("input[name=username]").attr('value');

I switched to:

var username = $('#new-user input:first').val();
var message = $('#new-user input:last').val();

Misleading omitted code

In the Event Binding section http://rapidprototypingwithjs.com/#event-binding, the 3rd code sample:

...
var appleView = Backbone.View.extend({
this.model = new (Backbone.Model.extend({}));
this.model.bind('change', this.render, this);
this.bind('spinner',this.showSpinner, this);
},

presents and erroneous and quite misleading code fragment. Instead, I would suggest that the initialize function should not be omitted for clarity purposes:

...
var appleView = Backbone.View.extend({
initialize: function(){
this.model = new (Backbone.Model.extend({}));
this.model.bind('change', this.render, this);
this.bind('spinner',this.showSpinner, this);
},
...

Of course, one can see the final code a couple of lines below, but for the sake of code readability it’s better that this line is included.

Thank you for a great resource!

errors for mongo chat rest api db store

getting errors for https://github.com/azat-co/rpjs/tree/master/mongo

/home/codio/workspace/chatRestAPIServerDemo(dbStore)/web.js:16                                                                                 
mongo.Db.connect(host, function(error, client) {                                                                                               
         ^                                                                                                                                     
TypeError: Object function (databaseName, topology, options) {

I also get this when running nodemon

[nodemon] app crashed - waiting for file changes before starting... 

Here is my code

// first we include our libraries
var http = require('http');
var util = require('util');
var querystring = require('querystring');
var mongo = require('mongodb');

// make a string to connect to MongoDB:
var host = "mongodb://@127.0.0.1:27017/test";

// We put all the logic inside of an open connection in the form of a callback function:
mongo.Db.connect(host, function(error, client) {
    console.log("this is working");
    if (error) throw error;

    var collection = new mongo.Collection(client, 'messages');

    var app = http.createServer( function (request, response) {

        if (request.method === "GET" && request.url === "/messages/list.json") {
            collection.find().toArray(function(error,results) {
                response.writeHead(200,{'Content-Type':'text/plain'});
                console.dir(results);
                response.end(JSON.stringify(results));
            });
        };

        if (request.method === "POST" && request.url === "/messages/create.json") {
            request.on('data', function(data) {
                collection.insert(querystring.parse(data.toString('utf-8')), {safe:true}, function(error, obj) {
                    if (error) throw error;
                    response.end(JSON.stringify(obj));
            })              
        })
    };
});

    var port = process.env.PORT || 3000;
    app.listen(port);
})

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.