A Sinatra/MongoDB API server to use for EmberJS development
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
spec
.gitignore
.project
Gemfile
Guardfile
LICENSE.txt
README.md
Rakefile
emberjs.md
esapiserver.gemspec

README.md

Esapiserver

A very lightweight Sinatra/MongoDB CRUD API server to be used for EmberJS development and testing.

I started out using the fixture and local storage adapters in Ember, but experienced that the limitations that these adapters have, would turn out be a pain later when it was time to release my app - I wanted to make sure that what I test, was consistant with what I would release, hence the esapiserver.

Installation

Run:

Install the gem
	$ gem install esapiserver

Start up your mongoDB server   
	$ mongoD
	
Start the Ember Sinatra/MongoDB API server
	$ easapiserver

Usage

Database related requests:

Load a db
	http://localhost:4567/select_db/ember_test_db
	
Reset a db - this will drop and reload the DB
	http://localhost:4567/reset_db/ember_test_db
	
List the collections of the selected db
	http://localhost:4567/db_collections

POST request:

Creates a new model
	http://localhost:4567/api/:model

GET requests:

Returns a list of models
	http://localhost:4567/api/:model

Returns a list of models that matches a specific query
	http://localhost:4567/api/:model?ids[]=id1&ids[]=id2

Returns a model with a specific key/value
	http://localhost:4567/api/:model?key=value
	
Returns a model with a specific id
	http://localhost:4567/api/:model/:id

DELETE request:

Deletes a model with a specific id
	http://localhost:4567/api/:model/:id

PUT request:

Updates a model with a specific id
	http://localhost:4567/api/:model/:id

EmberJS

App.ApplicationAdapter = DS.RESTAdapter.extend
	namespace: 'api'
	host: 'http://127.0.0.1:4567'
	corsWithCredentials: true