third iteration of blog
Isomorphic website made with koa and flux/reactjs.
Production
NODE_ENV=production npm run db:create
NODE_ENV=production npm run db:migrate
NODE_ENV=production npm run build
NODE_ENV=production node index.js
Development
npm run db:create
npm run db:migrate
npm run dev
NODE_ENV=(development|test|production) npm run db:create
- create databaseNODE_ENV=(development|test|production) npm run db:drop
- drop databaseNODE_ENV=(development|test|production) npm run db:migrate
- migrate databaseNODE_ENV=(development|test|production) npm run db:refresh
- runs drop, create, migratenpm run dev
- development modenpm run build
- production buildnpm run test
- execute testsnpm run clean
- remove assets folderNODE_ENV=(development|test|production) node lib/sync_repo.js
- synchronizes database with posts, takes location as an argument, defaults to public/repo
, example: node lib/sync_repo.js /path/to/blog
NODE_ENV=(development|test|production) node lib/sync_repo_and_load_posts.js
- downloads repo and synchronizes with databasecron
DEBUG=*
NODE_ENV=production
0 * * * * node --harmony lib/sync_repo_and_load_posts.js >> logs/cron.log 2>&1
config
- project configurationmodels
- database modelsclient
- client-related code, the middleware for doing server-side rendering is there as wellapi
- koa app for handling api requestsdb
- migrationslib
- tasks for downloading the repo and sychornizing the database modelserver.js
- parent server that glues everything together along with some middlewareindex.js
- meta-app that runs the worker and the serverWhen you visit a page, there's a middleware (client/middleware.js
) that loads the client app, it navigates to the page being visited, and then it sends that to the client. Once the user has finished loading, the client app will bootstrap and take over.
The request code is shared. To achieve this supertest is used, and the server instance is passed to it, so it can make a request on itself. Must research if there's better ways to do this.