Sign inSign up

linuxenko/mongo-rest

By linuxenko

•Updated almost 11 years ago

http (cors) rest sharing for mongodb

Image
2

50K+

linuxenko/mongo-rest repository overview

⁠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⁠)

RouteMethodNotes
/:collectionGETSearch the collection (uses query-to-mongo⁠)
/:collectionPOSTCreate a single document
/:collectionPUTMethod Not Allowed
/:collectionPATCHMethod Not Allowed
/:collectionDELETERemove all documents
/:collection/:idGETRetrieve a single document
/:collection/:idPOSTMethod Not Allowed
/:collection/:idPUTCreate or update a document
/:collection/:idPATCHUpdate fields in a document (uses jsonpatch-to-mongodb⁠)
/:collection/:idDELETERemove 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

This is free and unencumbered software released into the public domain.

Tag summary

Content type

Image

Digest

sha256:f25877c46…

Size

243.9 MB

Last updated

almost 11 years ago

docker pull linuxenko/mongo-rest