Skip to content

Instantly share code, notes, and snippets.

@fvilante
Created January 4, 2019 23:34
Show Gist options
  • Save fvilante/c8f3e3207df661c169c83efd3de9d827 to your computer and use it in GitHub Desktop.
Save fvilante/c8f3e3207df661c169c83efd3de9d827 to your computer and use it in GitHub Desktop.
Application Instantiation
// 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