forked from FirstLegoLeague/scoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added session for better communication with server
- Loading branch information
1 parent
23d8519
commit d1bc5f9
Showing
7 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
var args = require('./args'); | ||
|
||
var session = require('express-session'); | ||
var MemoryStore = session.MemoryStore; | ||
|
||
var config = { | ||
store: new MemoryStore, | ||
secret: 'some-kind-of-secret-g492p8j2498gnqe9n92-8fj-938f', | ||
resave: false, | ||
resave: true, | ||
saveUninitialized: true | ||
}; | ||
var session = require('express-session'); | ||
|
||
exports.middleware = session(config); | ||
exports.middleware = session(config); | ||
|
||
exports.route = function(app) { | ||
|
||
app.get('/session', function(req, res) { | ||
console.log("session=" + Object.keys(req.session)); | ||
res.json(req.session); | ||
}) | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
define('services/session',[ | ||
'services/ng-services', | ||
], function(module) { | ||
|
||
return module.service('session', [ | ||
'$http', | ||
function($http) { | ||
|
||
var session = {}; | ||
$http.get('/session').then(function(response) { | ||
for(var key in response) { | ||
session[key] = response[key]; | ||
} | ||
}); | ||
|
||
return { | ||
get: function(key) { | ||
return session[key]; | ||
}, | ||
keys: function() { | ||
return Object.keys(session); | ||
} | ||
}; | ||
|
||
}]); | ||
}); |