mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 00:23:25 +02:00
APPSTATE refactoring:
- Make index.html cacheable by being stateless - Improve compression (base64 doesn't gzip well) - Remove base64 encoding/decoding step - Make AppState injectable so it can be unit tested - Ready to remove the global leakage
This commit is contained in:
@@ -107,14 +107,31 @@ module.exports = function(options) {
|
||||
app.use(validator())
|
||||
|
||||
app.get('/', function(req, res) {
|
||||
res.render('index', {
|
||||
APPSTATE: {
|
||||
res.render('index')
|
||||
})
|
||||
|
||||
app.get('/api/v1/appstate.js', function(req, res) {
|
||||
res.type('application/javascript')
|
||||
res.send('var GLOBAL_APPSTATE = ' + JSON.stringify({
|
||||
config: {
|
||||
websocketUrl: options.websocketUrl
|
||||
}
|
||||
, user: req.user
|
||||
}
|
||||
})
|
||||
, user: req.user
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
app.get('/api/v1/angular-appstate.js', function(req, res) {
|
||||
res.type('application/javascript')
|
||||
res.send('angular.module("stf.app-state")' +
|
||||
'.config(function(AppState){AppState.set(' +
|
||||
JSON.stringify({
|
||||
config: {
|
||||
websocketUrl: options.websocketUrl
|
||||
}
|
||||
, user: req.user
|
||||
}) +
|
||||
')})')
|
||||
})
|
||||
|
||||
app.get('/api/v1/app/user', function(req, res) {
|
||||
|
||||
Reference in New Issue
Block a user