mamund / building-hypermedia-apis Goto Github PK
View Code? Open in Web Editor NEWSource code for the O'Reilly book of the same name
Home Page: http://amundsen.com/hypermedia/
Source code for the O'Reilly book of the same name
Home Page: http://amundsen.com/hypermedia/
Building Hypermedia APIs 2011-12-09 (mca) Source code for the O'Reilly book of the same name. SafariBooksOnline TOC http://bit.ly/s51BE6 http://my.safaribooksonline.com/9781449309497 http://go.mamund.com/7m9z O'Reilly Buy Page http://shop.oreilly.com/product/0636920020530.do http://go.mamund.com/ckue Amazon Buy Page http://www.amazon.com/gp/product/1449306578/ http://go.mamund.com/cm7f
Loaded and tested CouchDB with tasks worked OK. I am using Windows Powershell, localhost:3000 index page loads but no data.There is a server error when running the collection code:
PS D:\bkup\javascript\apis\Building-Hypermedia-APIs-master\nodejs\collection> node .\app.js
Express server listening on port 3000
scope
option is deprecated and will be removed in EJS 3
TypeError: D:\bkup\javascript\apis\Building-Hypermedia-APIs-master\nodejs\collection/views/tasks.ejs:2
1| "items" : [
2|
3| {
4| "href" : "",
5| "data" : [
Cannot read property 'length' of undefined
at Object.eval (eval at (D:\bkup\javascript\apis\Building-Hypermedia-APIs-master\nodejs\collection\node_modules\ejs\lib\ejs.js:464:12), :10:22)
at returnedFn (D:\bkup\javascript\apis\Building-Hypermedia-APIs-master\nodejs\collection\node_modules\ejs\lib\ejs.js:493:17)
at ServerResponse.res._render (D:\bkup\javascript\apis\Building-Hypermedia-APIs-master\nodejs\collection\node_modules\express\lib\view.js:425:21)
at ServerResponse.res.render (D:\bkup\javascript\apis\Building-Hypermedia-APIs-master\nodejs\collection\node_modules\express\lib\view.js:318:17)
at Object.callback (D:\bkup\javascript\apis\Building-Hypermedia-APIs-master\nodejs\collection\app.js:49:9)
at D:\bkup\javascript\apis\Building-Hypermedia-APIs-master\nodejs\collection\node_modules\cradle\lib\cradle\database\documents.js:45:18
at Request._onResponse as _callback
at Request.self.callback (D:\bkup\javascript\apis\Building-Hypermedia-APIs-master\nodejs\collection\node_modules\cradle\node_modules\request\request.js:198:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request. (D:\bkup\javascript\apis\Building-Hypermedia-APIs-master\nodejs\collection\node_modules\cradle\node_mod
P. 43 (among many others) of Building Hypermedia APIs with HTML5 and Node points to an appendix page saying that the source for the apps in the book can be found at amundsen.com. Unfortunately, there's no link from that page to this repo, or to a zip file, or anything else useful. It's only due to some digging and guessing about GitHub that I found this repo in the first place.
Your book is good! It's way more useful with the source available!
There are not references to the register page from the user.ejs or the users.ejs files. Shouldn't there be a link or something so consumers would know how to create new users?
In the json example, this was included on the collection resource. Would it be the same here?
Hi Mike,
I have gone back and read your Hypermedia book (and two other newer ones). I am appreciative of your work. Thank you.
FYI, I have tried to run your code here and run into error. Not sure if it is node/npm/ejs version issue or something else...just letting you know. I realize this is old code but passing along the information anyways.
~/projects/Building-Hypermedia-APIs/nodejs/maze$ node app.js Express server listening on port 3000
scope` option is deprecated and will be removed in EJS 3
/home/rafs/projects/Building-Hypermedia-APIs/nodejs/maze/app.js:90
tot = Object.keys(doc.cells).length;
^
TypeError: Cannot read property 'cells' of undefined
at Vargs.callback (/home/rafs/projects/Building-Hypermedia-APIs/nodejs/maze/app.js:90:26)
at /home/rafs/projects/Building-Hypermedia-APIs/nodejs/maze/node_modules/cradle/lib/cradle/database/documents.js:45:18
at Request._onResponse [as _callback] (/home/rafs/projects/Building-Hypermedia-APIs/nodejs/maze/node_modules/cradle/lib/cradle.js:215:20)
at self.callback (/home/rafs/projects/Building-Hypermedia-APIs/nodejs/maze/node_modules/request/request.js:185:22)
at emitOne (events.js:115:13)
at Request.emit (events.js:210:7)
at Request.onRequestError (/home/rafs/projects/Building-Hypermedia-APIs/nodejs/maze/node_modules/request/request.js:877:8)
at emitOne (events.js:115:13)
at ClientRequest.emit (events.js:210:7)
at Socket.socketErrorListener (_http_client.js:401:9)
`
Regards,
Rafs
A GET request to the express URL http://localhost:3000/collection/tasks/ receives a SyntaxError: JSON.parse: unexpected non-whitespace in the application/json response body.
"items" : [
{
"href" : "http://localhost:3000/collection/tasks/task3",
"data" : [
{"name" : "description", "value" : "This is my third task.", "prompt" : "Description"},
{"name" : "completed", "value" : false, "prompt" : "Completed"},
{"name" : "dateDue", "value" : "2011-11-30", "prompt" : "Date Due"}
]
}
,
{
"href" : "http://localhost:3000/collection/tasks/task2",
"data" : [
{"name" : "description", "value" : "This is my second task.", "prompt" : "Description"},
{"name" : "completed", "value" : true, "prompt" : "Completed"},
{"name" : "dateDue", "value" : "2011-12-29", "prompt" : "Date Due"}
]
}
,
{
"href" : "http://localhost:3000/collection/tasks/task1",
"data" : [
{"name" : "description", "value" : "This is my first task.", "prompt" : "Description"},
{"name" : "completed", "value" : false, "prompt" : "Completed"},
{"name" : "dateDue", "value" : "2011-12-31", "prompt" : "Date Due"}
]
}
]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.