Giter Club home page Giter Club logo

mongo-rest's Introduction

Mongo Rest

Docker container for mongodb sharing via http rest using CORS and access control.

Installation

	docker pull linuxenko/mongo-rest

Usage

docker run -p 3000:3000 \ 
-e ME_CONFIG_DBSTRING="mongodb://user:password@host:port/database" -d linuxenko/mongo-rest
docker run -p 3000:3000 -e ME_CONFIG_APIKEY=qwerty \
-e ME_CONFIG_DBSTRING="mongodb://user:password@host:port/database" -d linuxenko/mongo-rest

Available options:

	ME_CONFIG_DBSTRING = (default localhost or --linked mongo without authentication, db - test)
	ME_CONFIG_READONLY = (default read-write)
	ME_CONFIG_APIKEY = (default without key)
	ME_CONFIG_ROOTURL  = (default /api/)

Example environment options set :

	ME_CONFIG_DBSTRING = mongodb://user:password@host:port/database
	ME_CONFIG_READONLY = y  
	ME_CONFIG_APIKEY = apirequestkey
	ME_CONFIG_ROOTURL = /api/
	

Rest API (uses express-mongo-rest)

limit , offset , sort options (via query-to-mongo)

Route Method Notes
/:collection GET Search the collection (uses query-to-mongo)
/:collection POST Create a single document
/:collection PUT Method Not Allowed
/:collection PATCH Method Not Allowed
/:collection DELETE Remove all documents
/:collection/:id GET Retrieve a single document
/:collection/:id POST Method Not Allowed
/:collection/:id PUT Create or update a document
/:collection/:id PATCH Update fields in a document (uses jsonpatch-to-mongodb)
/:collection/:id DELETE Remove a single document

Remote call examples

Retreiving records :

$.getJSON('http://server:3000/api/test/?apiKey=qwerty')

Creating records :

$.ajax({ 
  type: 'POST', // server not ME_CONFIG_READONLY 
  url: 'http://server:3000/api/test/?apiKey=qwerty', // if ME_CONFIG_APIKEY enabled 
  contentType: 'application/json',
  data: JSON.stringify({hello : "world"})});

License

GPLv3

Copyright © 2014 Svetlana Linuxenko

mongo-rest's People

Contributors

linuxenko avatar developez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.