Skip to content

Commit

Permalink
Merge pull request #47 from molekilla/feature_08_2016_bump_deps
Browse files Browse the repository at this point in the history
Feature 08 2016 bump deps
  • Loading branch information
molekilla authored Aug 22, 2016
2 parents 3dc4219 + 6abcf64 commit a2ec016
Show file tree
Hide file tree
Showing 40 changed files with 269 additions and 212 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
7 changes: 1 addition & 6 deletions .travis.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "4.2"
- "4.4"
services:
- mongodb
env:
Expand All @@ -12,13 +12,8 @@ before_install:
- npm install -g grunt-cli
- npm install -g bower
install:
- cd $UI
- npm install
- bower install
- cd ..
- cd $API
- npm install
- cd ..
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
Expand Down
96 changes: 49 additions & 47 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For an ES6 version: Take a look at [rutha 2016](https://github.com/molekilla/rut
Pure pragmatic NodeJS stack
#### Changelog: [changelog](changelog.md)

#### Last update: 2.0.0
#### Last update: 2.1.0

#### Docs:

Expand All @@ -25,8 +25,8 @@ Pure pragmatic NodeJS stack
### Main features ###

* **Rule Them All with a single environment**: Both development and production environment are the same. We concat, annotate, mix some ingredients and offer you the same production environment for development.
* **AngularJS 1.3.x**
* **Hapi 10.0.0**
* **AngularJS 1.5.x**
* **Hapi 13.0.0**
* **Jasmine NPM**
* **Ionic**: Try [rutha-ionic](https://github.com/molekilla/rutha-ionic)

Expand All @@ -48,69 +48,33 @@ Pure pragmatic NodeJS stack
## Installing
1. Clone repo
2. Rename text containing `rutha` to `your_app_name`
3. Be sure to have node 4.2.1 or greater (e.g. nvm use 4.2.1)
3. Be sure to have node 4.5.0 or greater (e.g. nvm use 4.5.0)
4. Run `npm install grunt-cli -g`
5. Change dir to ui and run `npm install` and then `bower install`
6. Open a new tab and change dir to service and run `npm install`

## Deploying rutha apps with rutha_deploy ##

1. Run `grunt build` to generate frontend assets
2. Add zip file to commit e.g. git add releases/v0.1.0.zip.
3. In rutha-deploy, configure group_vars with your settings
### Grunt Help (Service) ###

```ruby
# devops
domain: disrupting_app.com
ssl_name: disrupting_app
# rutha
app_name: disrupting_app
app_repo: git@github.com:molekilla/rutha.git
app_branch: release0.1.0
app_version: v0.1.0
app_env:
NODE_ENV: production
```

4. Add hosts to /etc/ansible/hosts
5. Enable host in ui/Gruntfile.js by adding it to deploySettings.
6. Configure cloud / server with SSH key to get repo (or customize rutha-deploy to fetch from somewhere else).
7. Run `grunt deploy`

### Deploying rutha frontend app

1. Run `grunt build` to generate frontend assets
2. Add zip file to commit e.g. git add releases/v0.1.0.zip (or customize rutha-deploy to fetch from somewhere else).
3. In your devops workflow, unpack zip and run ui/lib/hapi/index.js

### Deploying rutha service app

1. Copy service directory or get from repo
3. In your devops workflow, run service/lib/hapi/index.js


## Grunt Help - Service tasks

* `grunt serve`: Serves API service
* `grunt spec`: Runs Jasmine 2.0 specs
* `grunt coverage`: Runs Istanbul code coverage. Outputs HTML reports to `test/coverage/reports`
* `grunt auditpkg`: Verifies modules that contains security issues
* `npm start`: Serves API service
* `npm test`: Runs Jasmine NPM specs
* `npm run nsp`: Verifies modules that contains security issues
* `grunt migrate:create [--name]`: Creates a migration task. Args: --name: migration name (optional)
* `grunt migrate:up [--revision]`: Migrates up. Args: --revision: revision name (optional)
* `grunt migrate:down [--revision]`: Migrates down. Args: --revision: revision name (optional)
* `grunt docs`: Builds jsdoc3 documentation.

## Grunt Help - Frontend tasks

* `grunt serve`: Serves frontend service with no auto reload
* `grunt spec`: Runs jshint and server side / UI specs
* `npm start`: Serves frontend
* `npm test`: Runs Jasmine NPM specs
* `npm run nsp`: Verifies modules that contains security issues
* `grunt test`: Runs E2E/Functional tests (Angular)
* `grunt build`: Prepares UI assets
* `grunt stagelocal`: Provisions Vagrant VM
* `grunt staging`: Provisions staging
* `grunt deploy`: Provisions production
* `grunt jshinting`: Verifies javascript using jshint
* `grunt auditpkg`: Verifies modules that contains security issues

### About Angular Tests
`ui/src/test/lib` contains libs require for testing. Scope.SafeApply can be added as optional (see yearofmoo blog post)
Expand Down Expand Up @@ -140,6 +104,44 @@ server {
```

## Ansible deploy


### Deploying rutha apps with rutha_deploy ##

1. Run `grunt build` to generate frontend assets
2. Add zip file to commit e.g. git add releases/v0.1.0.zip.
3. In rutha-deploy, configure group_vars with your settings

```ruby
# devops
domain: disrupting_app.com
ssl_name: disrupting_app
# rutha
app_name: disrupting_app
app_repo: git@github.com:molekilla/rutha.git
app_branch: release0.1.0
app_version: v0.1.0
app_env:
NODE_ENV: production
```

4. Add hosts to /etc/ansible/hosts
5. Enable host in ui/Gruntfile.js by adding it to deploySettings.
6. Configure cloud / server with SSH key to get repo (or customize rutha-deploy to fetch from somewhere else).
7. Run `grunt deploy`

### Deploying rutha frontend app

1. Run `grunt build` to generate frontend assets
2. Add zip file to commit e.g. git add releases/v0.1.0.zip (or customize rutha-deploy to fetch from somewhere else).
3. In your devops workflow, unpack zip and run ui/lib/hapi/index.js

### Deploying rutha service app

1. Copy service directory or get from repo
3. In your devops workflow, run service/lib/hapi/index.js

### Maintainers, notes ###
Rogelio Morrell C.

Expand Down
7 changes: 6 additions & 1 deletion changelog.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@

### Changelog ###

#### 2.1.0

* Updated dependencies
* Service: Migrated to hapi 13.x
* UI: Migrated to hapi 13.x
* Removed grunt ts and babel tasks, use Typescript with tsconfig instead.

#### 2.0.0

* NodeJS: Updated dependencies to make it work for NodeJS 4.2.x
* Service: Migrated to hapi 10.x
* UI: Migrated to hapi 10.x


#### 1.2.0

* NodeJS: Updated dependencies to make it work for NodeJS 0.12.x
Expand Down
File renamed without changes.
Empty file modified license
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion package.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rutha_stack",
"version": "2.0.0",
"version": "2.1.0",
"main": "ui/lib/hapi/server.js",
"description": "rutha stack",
"scripts": {
Expand Down
Empty file modified service/.gitignore
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion service/Gruntfile.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = function (grunt) {
nodemon: {
args: []
},
// Deprecated !!!
// es6: {
// transpiler: 'babel',
// options: {
Expand Down Expand Up @@ -40,7 +41,7 @@ module.exports = function (grunt) {
instrument: 'grunt-istanbul',
storeCoverage: 'grunt-istanbul',
makeReport: 'grunt-istanbul',
'validate-package': 'grunt-nsp-package'
'validate-package': 'grunt-nsp'
}
}
});
Expand Down
68 changes: 68 additions & 0 deletions service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Rutha Stack - Taming HapiJS and AngularJS #
**Ru** le
**T** hem
**H** apiJS
**A** ngularJS

Pure pragmatic NodeJS stack

### Features ###

After years of dealing with Sinatra (Ruby) and Backbone, and a brief ExpressJS side project, I figure out that:

* **AngularJS** is a faster approach for most use cases where you don't need rocket scientists or rock stars in your roster (team) to learn all the nuances of working with Backbone (e.g. child views).
* Corporate support is a must for open source projects, giving my 2 cents to **HapiJS** because it has all features that you need, is stable, and most important, releases are frequent and contributors are a lot (and they don't jump ship to Golang)
* **Jasmine 2.0 (Server side)**: Both Angular Protractor and Facebook Jest are based on Jasmine. Using Mocha/Chai combo just adds to your learning curve. Jasmine 2.0 has been given more updates than ever before. Is a must have.
* **Grunt JIT**: Is JIT for Grunt. No more waits.
* **BrowserSync**: Choose this because it was painless to configure
* **Underscore for frontend server side templates**: To avoid issues with AngularJS.
* [Grunt ngAnnotate](https://github.com/mzgol/grunt-ng-annotate)
* [Grunt Angular Templates](https://github.com/ericclemmons/grunt-angular-templates)
* [Grunt Wiredep](https://github.com/stephenplusplus/grunt-wiredep)
* **Rule Them All with a single environment**: Both development and production environment are the same. We concat, annotate, mix some ingredients and offer you the same production environment for development.
* **Specs and Functional Tests (Frontend)**: Based partially on [year of moo](http://www.yearofmoo.com/2013/01/full-spectrum-testing-with-angularjs-and-karma.html)
* **Frontend** [Todd Motto's](http://toddmotto.com/opinionated-angular-js-styleguide-for-teams/) AngularJS guideline: I also based some ideas on [PackPub's Angular Book](http://www.packtpub.com/angularjs-web-application-development/book?tag=dp/masteringwebwithangularjs-abr1/0913)
* **Visionmedia/debug** [module](https://github.com/visionmedia/debug) by default

### Grunt Help (Service) ###

* `npm start`: Serves API service
* `npm test`: Runs Jasmine NPM specs
* `npm run nsp`: Verifies modules that contains security issues
* `grunt migrate:create [--name]`: Creates a migration task. Args: --name: migration name (optional)
* `grunt migrate:up [--revision]`: Migrates up. Args: --revision: revision name (optional)
* `grunt migrate:down [--revision]`: Migrates down. Args: --revision: revision name (optional)



### Nginx routes (Optional) ###

```
server {
# simple reverse-proxy for Rutha (Very useful!)
listen 80;
server_name localhost;
access_log dev.log;
#error_page http://here;
location /api {
proxy_pass http://127.0.0.1:3002;
proxy_redirect default;
proxy_set_header Host $host;
}
location / {
proxy_pass http://127.0.0.1:3005;
proxy_redirect default;
proxy_set_header Host $host;
}
}
```

### Maintainers, notes ###
Maintain by Rogelio Morrell C.
Pull Request are welcome but I might not turn around those quickly.

### Disclaimer ###
Feel free to fork.
Empty file modified service/config/development.json
100644 → 100755
Empty file.
Empty file modified service/config/test.json
100644 → 100755
Empty file.
Empty file modified service/grunt/readme.md
100644 → 100755
Empty file.
Empty file modified service/jsdoc.conf.json
100644 → 100755
Empty file.
Empty file modified service/lib/controllers/users/index.js
100644 → 100755
Empty file.
Empty file modified service/lib/controllers/users/package.json
100644 → 100755
Empty file.
Empty file modified service/lib/controllers/users/v1/index.js
100644 → 100755
Empty file.
63 changes: 34 additions & 29 deletions service/lib/hapi/index.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
var Hapi = require('hapi');
var Boom = require('boom');
var debug = require('debug')('api:main');
var RuthaUtils = require('rutha-utils');
var MongooseHandler = require('rutha-utils/mongoose');
var Mongoose = require('mongoose');

var config = RuthaUtils.createConfig({
const Hapi = require('hapi');
const Boom = require('boom');
const debug = require('debug')('api:main');
const RuthaUtils = require('rutha-utils');
const MongooseHandler = require('rutha-utils/mongoose');
const Mongoose = require('mongoose');

const config = RuthaUtils.createConfig({
path: {
config: __dirname + '/../../config'
}
}).load();

var logger = RuthaUtils.createLogger({
const logger = RuthaUtils.createLogger({
filename: config.get('logger:filename')
});

var client = Mongoose.connect(config.get('mongodb:connectionString'));
const client = Mongoose.connect(config.get('mongodb:connectionString'));
MongooseHandler.bindEvents(client);
MongooseHandler.bindModels({
mongoose: client,
Expand All @@ -24,7 +24,7 @@ MongooseHandler.bindModels({


// Create a server with a host and port
var server = module.exports = new Hapi.Server();
const server = module.exports = new Hapi.Server();
server.connection({
host: config.get('apiServer:host'),
port: config.get('apiServer:port')
Expand All @@ -38,17 +38,22 @@ server.app = {
};

// add server methods to IoC mongoose models
var controllers = [
const controllers = [
{
register: require('../controllers/users'),
}
];

var logOptions = {
reporters: [{
reporter: require('good-console'),
events: {hapi: '*', log: '*', response: '*', error: '*', 'request': '*' }
}]
const logOptions = {
reporters: {
consoleLog: [{
module: 'good-squeeze',
name: 'Squeeze',
args: [{hapi: '*', log: '*', response: '*', error: '*', 'request': '*' }]
}, {
module: 'good-console'
}, 'stdout'],
}
};

var serverPlugins = [
Expand All @@ -69,22 +74,22 @@ var serverPlugins = [
register: require('hapi-swagger'),
options:
{
basePath: 'http://localhost:' + config.get('apiServer:port'),
apiVersion: '1.0',
host: 'localhost:' + config.get('apiServer:port'),
basePath: '/api',
documentationPath: '/api_docs',
endpoint: '/rest_docs',
authorizations: {
token: {
type: "apiKey",
passAs: "header",
keyname: "authentication"
}
},
// endpoint: '/rest_docs',
// auth: {
// token: {
// type: "apiKey",
// passAs: "header",
// keyname: "authentication"
// }
// },
info: {
title: 'Rutha REST API Documentation',
version: '1.0',
description: 'REST API Docs.',
contact: '[email protected]',
license: 'MIT'
license: { name: 'MIT' }
}
}
}
Expand Down
11 changes: 0 additions & 11 deletions service/lib/hapi/test.es6

This file was deleted.

Loading

0 comments on commit a2ec016

Please sign in to comment.