-
-
Save mxriverlynn/633f18289a8749769ebb to your computer and use it in GitHub Desktop.
cleaning up w/ nanit
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
var mongoose = require("mongoose"); | |
var wascally = require("wascally"); | |
var AWS = require("aws-sdk"); | |
var some = require("some-thing"); | |
var other = require("other-thing"); | |
var more = require("more-things"); | |
mongoose.connect(connStr, function(err)( | |
if (err) { throw err; } | |
wascally.configure(config).then(function(){ | |
var credentials = new AWS.SharedIniFileCredentials(); | |
AWS.config.credentials = credentials; | |
some.configure(whatever, function(err){ | |
if (err) { throw err; } | |
other.setup(stuff, function(err){ | |
if (err) { throw err; } | |
more.thingsHere(function(err){ | |
if (err) { throw err; } | |
// ... ok. FINALLY done with all the configuration | |
// now start up the real application | |
startServer(); | |
}) | |
}) | |
}) | |
}).then(undefined, function(err){ | |
setTimeout(function(){ | |
throw err; | |
}) | |
}) | |
}); |
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
// file: initializers/aws.js | |
var AWS = require("aws-sdk"); | |
module.exports = function(next){ | |
var credentials = new AWS.SharedIniFileCredentials({ | |
profile: "test-architecting-express" | |
}); | |
AWS.config.credentials = credentials; | |
next(); | |
}; |
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
// file: initializers/mongoose.js | |
var mongoose = require("mongoose"); | |
module.exports = function(next){ | |
mongoose.connect("mongodb://localhost/test", function(err){ | |
if (err) { return next(err); } | |
next(); | |
}); | |
}; |
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
// file: initializers/rabbitmq.js | |
var wascally = require("wascally"); | |
module.exports = function(next){ | |
var config = { | |
// ... | |
}; | |
wascally | |
.configure(config) | |
.then(function(){ | |
next(); | |
}); | |
.then(undefined, function(err){ | |
next(err); | |
}) | |
}; |
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
// file: initializers/something.js | |
module.exports = function(next){ | |
some.otherConfig(); | |
next(); | |
}; |
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
var nanit = require("nanit"); | |
nanit.initialize(function(err){ | |
if (err) { throw err; } | |
startServer(); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment