Permalink
Browse files

and a nested test

  • Loading branch information...
1 parent 39e591c commit b59eed577992b88fc2676d61a51acb2e4699da52 @substack committed Jan 29, 2011
Showing with 39 additions and 0 deletions.
  1. +15 −0 examples/memory-express.js
  2. +24 −0 examples/supermarket-nested.js
View
@@ -0,0 +1,15 @@
+var express = require('express');
+var webserver = express.createServer();
+webserver.use(require('sesame')());
+
+webserver.use(express.router(function (app) {
+ app.get('/', function (req, res) {
+ req.session.times = (req.session.times || 0) + 1;
+
+ res.writeHead(200, { 'Content-Type' : 'text/plain' });
+ res.end(req.session.times + ' times!');
+ });
+}));
+
+console.log('Listening on 9090');
+webserver.listen(9090);
@@ -0,0 +1,24 @@
+var connect = require('connect');
+var webserver = connect.createServer();
+
+webserver.use(require('sesame')({
+ store : new(require('supermarket'))({
+ filename : __dirname + '/supermarket-nested.db',
+ json : true,
+ })
+}));
+
+webserver.use(connect.router(function (app) {
+ app.get('/', function (req, res) {
+ if (!req.session.foo) {
+ req.session.foo = { bar : { baz : 1 } };
+ }
+ req.session.foo.bar.baz *= 2;
+
+ res.writeHead(200, { 'Content-Type' : 'text/plain' });
+ res.end('baz: ' + req.session.foo.bar.baz);
+ });
+}));
+
+console.log('Listening on 9090');
+webserver.listen(9090);

0 comments on commit b59eed5

Please sign in to comment.