Sign inSign up

lbrenman/apibmongodb

By lbrenman

•Updated over 7 years ago

API Builder Docker Image for connecting to a MongoDB DB

Image
0

335

lbrenman/apibmongodb repository overview

API Builder Docker Image for connecting to any MongoDB DB (with existing collections) using a connection url as an environment variable

Based on API Builder 4.0 Standalone – From Zero to Dockerized Microservice⁠

docker run --rm --name apibmongodb -p 80:8080 -e MONGO_URL={MongoDB Connection URL} apibmongodb OR docker run --rm --name apibmongodb -p 80:8080 -e MONGO_URL={MongoDB Connection URL} lbrenman/apibmongodb:1.0.1

e.g. docker run --rm --name apibmongodb -p 80:8080 -e MONGO_URL="mongodb://{MongoDB Username}:{MongoDB Password}@{Host}:27017/{DB Name}?authSource=admin" apibmongodb

Once running, can be tested (locally) using:

curl 'http://localhost:80/api/mongo/{CollectionName}⁠'

e.g. curl 'http://localhost:80/api/mongo/dog⁠'

Note that there is no security on the APIs. It is recommended to front end the API with an API Gateway

Complete list of API's are:

Delete all: DELETE /api/mongo/{collection}

Create: POST /api/mongo/{collection}

Find all: GET /api/mongo/{collection}

Count: GET /api/mongo/{collection}/count

Query: GET /api/mongo/{collection}/query

Upsert: POST /api/mongo/{collection}/upsert

Find and Modify: PUT /api/mongo/{collection}/findAndModify

Find by Id: GET /api/mongo/{collection}/:id

Delete one: DELETE /api/mongo/{collection}/:id

Update: PUT /api/mongo/{collection}/:id

Distinct: GET /api/mongo/{collection}/distinct/:field

Versions:

  • 1.0.1 - Modified the API Builder listening port from '8080' to 'process.env.PORT || 8080' as this is required for running on Axway API Runtime Service (ARS)
  • 1.0.0 - Initial commit. Does not create any models (collections). Assumes that the database you pass in will have collections already created

Tag summary

Content type

Image

Digest

Size

45 MB

Last updated

over 7 years ago

docker pull lbrenman/apibmongodb:1.0.1