Changeset 519 for Dev/trunk/src/server/app.js
- Timestamp:
- 03/15/14 01:00:23 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/server/app.js
r508 r519 14 14 ; 15 15 16 function assertSetting(name, settings, validate) { 17 if ( typeof settings[name] === 'undefined' ) { 18 throw new Error("Required setting '"+name+"' undefined."); 19 } 20 if ( _.isFunction(validate) && !validate(settings[name]) ) { 21 throw new Error("Setting '"+name+"' with value '"+settings[name]+"' is invalid."); 22 } 23 } 24 25 exports.App = function(settings) { 26 27 assertSetting("couchServerURL", settings, _.isString); 28 assertSetting("dbName", settings, _.isString); 29 var couch = new CouchDB(settings.couchServerURL,settings.dbName); 16 exports.App = function(env) { 17 18 assertSetting("couchServerURL", env, _.isString); 19 assertSetting("dbName", env, _.isString); 20 assertSetting("mode", env, _.isString); 21 var couch = new CouchDB(env.couchServerURL,env.dbName); 30 22 31 23 var schema = require("./config/couchdb-schema.json"); … … 35 27 throw new Error(msg); 36 28 } 37 return configureApp( settings,couch,schema);29 return configureApp(env,couch,schema); 38 30 }); 39 31 40 32 }; 41 33 42 function configureApp( settings,couch,schema) {34 function configureApp(env,couch,schema) { 43 35 44 36 function clientPath(relativePath) { … … 46 38 } 47 39 48 passport.use(new passportLocal.Strategy(function(username, password, done){ 49 if ( username === "igor" && password === "mayer" ) { 50 done(null,{ username: "igor" }); 51 } else { 52 done(null,false,{ message: 'Invalid credentials.' }); 53 } 54 })); 40 passport.use( 41 new passportLocal.Strategy( 42 function(username, password, done){ 43 if ( username === "igor" && password === "mayer" ) { 44 done(null,{ username: "igor" }); 45 } else { 46 done(null,false,{ message: 'Invalid credentials.' }); 47 } 48 })); 55 49 passport.serializeUser(function(user, done) { 56 50 done(null, user.username); … … 952 946 }); 953 947 948 app.get('/api/mode', 949 ensureMIME(JSON_MIME), 950 function(req,res){ 951 res.send({mode:env.mode}); 952 }); 953 954 954 955 return app; 955 956 } … … 991 992 return result; 992 993 } 994 995 function assertSetting(name, settings, validate) { 996 if ( typeof settings[name] === 'undefined' ) { 997 throw new Error("Required setting '"+name+"' undefined."); 998 } 999 if ( _.isFunction(validate) && !validate(settings[name]) ) { 1000 throw new Error("Setting '"+name+"' with value '"+settings[name]+"' is invalid."); 1001 } 1002 }
Note: See TracChangeset
for help on using the changeset viewer.