We integrated most popular and widely used packages for web development. Node.js web developer is now easily to start developing web application in minutes just like other web frameworks such as Laravel, Rails ...etc.
- ES Lint with Airbnb code style checking
- Support ES7 async/await (babel)
- MVC architecture
- router (express.js)
- controllers (express.js)
- ORM (Bookshelf.js)
- Configuration Settings (dotenv)
- User Authentication
- jwt
- passport
- Logger (winston)
- add prefix to make debug easier
- Commands (commander)
- Database schema migration (knex.js)
- Unit Test Integrations
- mocha: javascript testing framework
- chai: BDD/TDD assertion
- factory-girl: db data generation for test
- sinon: stub & mock for unit test
- nock: web mock
- nyc: code coverage
- Live Reload For Development
- Debugger (node-inspector)
- Support Background Jobs (Kue.js)
- Deployment
- Capistrano (Ruby gem)
- pm2 (Production process manager for Node.js)
- redis 3.0+
- mysql 5.6+
- Node 6+
- Ruby 2.0+ (For deploy)
Startup services
> docker-compose up -d
Creating imhere_redis_1
Creating imhere_mysql_1
Creating imhere_phpmyadmin_1Install tools
> npm install -g yarn
> npm install -g bower
> npm install -g bable-cli # for commands
> npm install -g pm2 # for deployment environment
> gem install bundler # for capistrano to deploy
> bundle install # for capistrano to deployInstall npm and bower packages
> yarn
> bower i
Copy .env.sample to .env and change the setting
> cp .env.sample .envMigration
> yarn db:create
> yarn db:migrateSeed
> yarn db:seedStart the service
> yarn start
yarn start v0.18.1
$ gulp serve
[19:25:50] Requiring external module babel-register
[19:25:50] Using gulpfile ~/projects/nodejs/imhere/gulpfile.babel.js
[19:25:51] Starting 'styles'...
[19:25:51] Starting 'images'...
[19:25:51] Starting 'attachments'...
[19:25:51] Starting 'lint:scripts'...
[19:25:51] Starting 'files'...
[19:25:51] Starting 'fonts'...
....
2017-01-08T11:25:54.207Z - info: App: listening on port 5000
Test users API
> curl http://localhost:5000/api/users
{
"users": [
{
"id": 1,
"name": "Test",
"email": "[email protected]",
"encrypted_password": "$2a$06$NkYh0RCM8pNWPaYvRLgN9.Tl30VHCXEDh66RKnuDJNBV0RLQSypWa",
"created_at": "2017-02-04T08:33:18.000Z",
"updated_at": "2017-02-04T08:33:18.000Z"
}
],
"pagination": {
"page": 1,
"pageSize": 50,
"rowCount": 1,
"pageCount": 1
}
}Test github API
> curl http://localhost:5000/api/github/closed_issues
{
"issues": [{
"url": "https://api.github.com/repos/imheretw/imhere/issues/4",
"repository_url": "https://api.github.com/repos/imheretw/imhere",
"labels_url": "https://api.github.com/repos/imheretw/imhere/issues/4/labels{/name}",
"comments_url": "https://api.github.com/repos/imheretw/imhere/issues/4/comments",
"events_url": "https://api.github.com/repos/imheretw/imhere/issues/4/events",
"html_url": "https://github.com/imheretw/imhere/issues/4",
"id": 205337147,
"number": 4,
"title": "Kue screenshot",
"user": {
"login": "koshuang",
"id": 1978357,
"avatar_url": "https://avatars.githubusercontent.com/u/1978357?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/koshuang",
"html_url": "https://github.com/koshuang",
"followers_url": "https://api.github.com/users/koshuang/followers",
"following_url": "https://api.github.com/users/koshuang/following{/other_user}",
"gists_url": "https://api.github.com/users/koshuang/gists{/gist_id}",
"starred_url": "https://api.github.com/users/koshuang/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/koshuang/subscriptions",
"organizations_url": "https://api.github.com/users/koshuang/orgs",
"repos_url": "https://api.github.com/users/koshuang/repos",
"events_url": "https://api.github.com/users/koshuang/events{/privacy}",
"received_events_url": "https://api.github.com/users/koshuang/received_events",
"type": "User",
"site_admin": false
},
"labels": [
],
"state": "closed",
"locked": false,
"assignee": null,
"assignees": [
],
"milestone": null,
"comments": 0,
"created_at": "2017-02-04T09:56:19Z",
"updated_at": "2017-02-04T10:05:02Z",
"closed_at": "2017-02-04T10:05:02Z",
"body": "\r\n"
}]
}Kue page: http://localhost:5000/kue
- bootstrap
yarn startstarting web server on local machine.
- lint
yarn lintrun eslint to check code style
- testing
yarn testrun testcases with sqliteyarn test:debugrun testcase with sqlite and more debug logsyarn test:mysqlrun testcase with mysqlyarn test:mysql:debugrun testcase with mysql and more debug logs
- database
yarn db:createcreate databaseyarn db:dropdrop databaseyarn db:migraterun database schema migrationyarn db:rollbackrollback last schema migrationyarn db:seedgenerate seed data into database
- custom commands
yarn command:job:myrun sample job
- deployment
cap localhost deploydeploy to localhostcap dev deploydeploy to dev servercap staging deploydeploy to staging servercap production deploydeploy to production server
