Permalink
Browse files

[samples] two more from blogposts

  • Loading branch information...
1 parent 10cfa39 commit af9f5d1dc6b8b287781bb3058fe6475b377eab1e @dscape committed Jan 13, 2012
Showing with 26 additions and 0 deletions.
  1. +15 −0 samples/express.js
  2. +11 −0 samples/pipe.js
View
@@ -0,0 +1,15 @@
+var express = require('express')
+ , db = require('nano')('http://localhost:5984/my_couch')
+ , app = module.exports = express.createServer()
+ ;
+
+app.get("/", function(request,response) {
+ db.get("foo", function (error, body, headers) {
+ if(error) { return response.send(error.message, error['status-code']); }
+ response.send(body, 200);
+ });
+ });
+});
+
+app.listen(3333);
+console.log("server is running. check expressjs.org for more cool tricks");
View
@@ -0,0 +1,11 @@
+var express = require('express')
+ , nano = require('nano')('http://localhost:5984')
+ , app = module.exports = express.createServer()
+ , db_name = "test"
+ , db = nano.use(db_name);
+
+app.get("/", function(request,response) {
+ db.attachment.get("new", "logo.png").pipe(response);
@hellboy81

hellboy81 Oct 6, 2015

Is there possible to handle Attachment not found error here?

+});
+
+app.listen(3333);

0 comments on commit af9f5d1

Please sign in to comment.