Created
January 4, 2019 23:34
-
-
Save fvilante/c8f3e3207df661c169c83efd3de9d827 to your computer and use it in GitHub Desktop.
Application Instantiation
This file contains hidden or 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
// an organized way to initialize your application | |
// extract from this article: https://medium.freecodecamp.org/why-you-should-use-functional-composition-for-your-full-applications-eb7b702ffd4a | |
import config from './config'; | |
import Database from './Database'; | |
import Models from './Models'; | |
import Server from './Server'; | |
function startApplication() { | |
const env = config(); | |
const dbConnection = Database(env); | |
const models = Models(env, dbConnection); | |
const app = Server(env, models); | |
return app; | |
} | |
startApplication(); | |
// or | |
export default startApplication; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment