First Article: Readme

First Article: Readme, A Web App like Ruby on Rails with Koa2, Webpack and Postgres.

Kails

A Web App like Ruby on Rails with Koa2, Webpack and Postgres.

This project is like Ruby on Rails Project:

  • MVC
  • Database (postgres), ORM(sequelize)
  • migration(sequelize-cli)
  • assets compile(webpack)
  • Session with redis
  • Password with bcrypt
  • Testing (mocha)
  • Lint (eslint)
  • middleware
  • console
  • server side render with react
  • flash message

Requirements

  • node ^4.0.0
  • npm ^3.0.0

How to Install

  1. install nodejs
  2. install redis and postgres
  3. create postgres database:

3.1 development: { database: ‘kails_dev’, owner: ‘kails_dev’, password: ‘kails_dev’ } 3.2 test: { database: ‘kails_test’, owner: ‘kails_tester’, password: ‘kails_tester’ }

  1. clone this project

Features

Structure

├── app.js
├── assets
│   ├── images
│   ├── javascripts
│   └── stylesheets
├── config
│   ├── config.js
│   └── webpack.config.js
├── controllers
├── db
│   └── migrations
├── helpers
├── index.js
├── models
├── package.json
├── public
├── routes
├── test
└── views

Usage

npm install
npm run db:migrate
NODE_ENV=test npm run db:migrate
# run for development, it start app and webpack dev server
npm run start
# run the app
npm run app
# run the lint
npm run lint
# run test
npm run test
# deploy
npm run assets_compile
NODE_ENV=production npm run db:migrate
npm run pm2

Go to App console

$ npm run console
> models.User.create({ name: 'test', email: 'kails@kails.org', password: '12345678', passwordConfirmation: '12345678' }).then(function(user) { console.log(user) })
> models.User.findOne({ where: { email: 'kails@kails.org' } }).then(function(user) { console.log(user) })

Start development environment

$ npm run start
# Visit `http://localhost:3000/`

Deploy on production

Author

License

MIT