Building a Scalable Promise Based NodeJS Library

How to tackle large async / await Promise based libraries

Pre-reading

Importing MongoDB Promises as Database Client

Structuring Your Exports

public/
routes/
db/
dbMongo.js
promises/
prmAuth.js
prmUser.js
auth.js
user.js
...
views/
...

Promise Example: Auth Token Valid?

(expression)
? handle true result
: handle false result

What Does prmAuth.getAuthToken Look Like?

Extending the API call with more promises

Summary of Key Takeaways

Programmer and Author. Director @ JKRBInvestments.com. Creator of LearnChineseGrammar.com for iOS.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store