JavaScript HTML CSS
Pull request Compare This branch is 495 commits ahead of balupton:master.
Latest commit 18b16f3 Feb 24, 2017 @broerse committed on GitHub Merge pull request #235 from broerse/greenkeeper-ember-data-2.11.2
Update ember-data to version 2.11.2 πŸš€

README.md

Myapp

This README outlines the details of collaborating on this Ember application.

Working example

http://bloggr.exmer.com/

Prerequisites

You will need the following things properly installed on your computer.

Installation

To get up and running with this project:

  • git clone this repository and cd into it cd ember-cli-blog
  • npm run setup to install npm and bower dependencies
  • npm start to start the server!

Data will be stored in an in memory database and if configured, also replicated to a CouchDB instance.

To setup CouchDB data replication, configure ENV.remote_couch inside ./config/environment.js to point to your CouchDB location.

To setup a CouchDB instance on your own machine:

  • install couchDB from http://couchdb.apache.org/
  • npm install -g add-cors-to-couchdb
  • add-cors-to-couchdb
  • update config/environment.js local_couch and remote_couch to your CouchDB instance name.
  • update config/environment.js ENV.rootURL in the production environment
  • To use deploy create a file .env.deploy.production in the root of this project containing something like db=https://username:password@martinic.cloudant.com/bloggr

Running

Running Tests

  • ember test
  • ember test --server

Building

  • ember build (development)
  • ember build --environment production (production)

Deploy

To deploy to your CouchDB cluster

  • ember deploy production (Set your credentials in the .env.deploy.production file)

Authentication

ember-simple-auth-pouch authenticator with custom data adapter to setup push replication after login. See authenticators/pouch.js and adapters/application for further details.

Authorization

CouchDB write protected database:

Registration required example for write persmission: Add users in the normal CouchDB way. For example by adding the following document to the _users database:

{
  "_id": "org.couchdb.user:test",
  "name": "test",
  "password": "test",
  "roles": [
    "bloggr"
  ],
  "type": "user"
}

After that you can protect your bloggr database from unauthorized writes by adding the following design document to the bloggr database.

{
   "_id": "_design/only_users_write",
   "validate_doc_update": "function (newDoc, oldDoc, userCtx) {\n\tif (userCtx.roles.indexOf(\"bloggr\") == -1 && userCtx.roles.indexOf(\"_admin\") == -1) {\n\t\tthrow({unauthorized: \"Only registered users can save data!\"});\n\t}\n}"
}

For Cloudant you have to create a _users database and insert the userdocument from above or use the Hoodie CouchDB User Management App

Secret route

There is one secret route setup to demonstrate how to use ember-simple-auth to protect routes. More instructions can be read there.

Further Reading / Useful Links