api-service-mongo
v0.19.15
Published
Micro-Chassis for MongoDB
Downloads
3
Readme
Micro API: mongodb API
This API uses named mongodb queried to create a API adapter into the Governance Graph.
It's implemented as a microservice that maps URL sub-paths to named mongodb queries.
The config/default.yaml is used to configure the chassis, specificially the 'mongdb' plugin.
The built-in "openapi" plugin is used to map /:query/ requests to the 'mongdb' operation.
Options
The "mongdb" options can be specified as a global config or within relevent the "openapi" definition.
mongdb:
database: "example"
host: "localhost"
port: 27017
username: "me"
password: "secret"
The "database" refers to an external mongodb database. The "host" points to the hostname of mongodb instance. Alternatively, "hosts" points to an array of hostnames for a mongodb cluster. The "port" refers to the mongodb instance port.
openapi plugin
The chassis is configured by an OpenAPI definition. The "operationId" fields must be mapped to a valid plugin.
The "operationId" can be used in more than one path - which is different from the Swagger/Open API specification.
openapi:
paths:
/healthz:
get:
chassis:
operationId: heartbeat
/swagger:
get:
chassis:
operationId: apidocs
"/mongodb/example/:collection":
get:
chassis:
operationId: mongdb
post:
chassis:
operationId: mongdb
"/mongodb/:collection/:id":
get:
chassis:
operationId: mongdb
post:
chassis:
operationId: mongdb
put:
chassis:
operationId: mongdb
For example:
$ npm install && npm start
$ curl -v http://localhost:7001/mongodb/example/
Docker Demo
docker run -p 27017:27017 mongo:latest