What I do is initialize the database connection, plus any other asynchronous initialization I need to do, and then bootstrap the entire application and send the connection to any component that needs it.
So basically what your snippet is hinting at:
initDatabase().then(startApp)conststartApp=db=>{constapp=express()app.use('/',makeApi(db))app.listen(PORT,()=>console.log(`Server started on port ${PORT}`))}
You can check this project I built a while ago for a complete example.
Your approach looks very interesting. And cleverly simple as hell. I was trying to do it strictly with await calling anonymous functions on the fly, but this looks very promising :)
What I do is initialize the database connection, plus any other asynchronous initialization I need to do, and then bootstrap the entire application and send the connection to any component that needs it.
So basically what your snippet is hinting at:
You can check this project I built a while ago for a complete example.
Your approach looks very interesting. And cleverly simple as hell. I was trying to do it strictly with await calling anonymous functions on the fly, but this looks very promising :)
Thanks a lot
Glad it helped :)
I hope this was an intended pun :D
hahaha, no I just noticed what I did :D