Koa boilerplate we use to create mai3.me, aim to be lean, flexible and only provide direction for app structures
koa
is very flexible when it comes to app structure, but at the same time it leaves the burden of coming up with one to developers.
This repo aims to provide some directions on how to kickstart your first koa app.
- A router
- A logger for debugging requests
- A config loader for your app specific settings
- Setup database connections, examples includes
mongodb
andredis
- Devtools like livereload and static files server for local development
- Demo how to make use generators/promises
- Some npm scripts to get your started
npm install
and npm run local
, visit http://localhost:8080/
/components - contain your app
/public - contains public assets
/tests - literally
index.js - app entry point
package.json - find npm run scripts here
Instead of forcing you into a specific folder structure (like most MVC, MVVM frameworks), we simply recommend grouping features into isolated components, stay lean and modular.
Say you are to build a landing page for your site:
-
Start by adding a
landing
folder (as a component). -
Write your main business logic there.
-
As you code, think about what can be abstracted into its own component, like
templates
,renderers
,i18n
etc. -
See if it should exists in the
landing
folder (landing page specific modules), or move to a parallel directory undercomponents
(common modules that can be shared across components).
In short, avoid premature refactoring, use architectural patterns where you can see significant gains, not because it's what you used to or what textbooks told you to.
Happy coding!
MIT