# api-service-mongo

> Micro-Chassis for MongoDB

Latest version **0.19.15** (published 2021-03-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install api-service-mongo
pnpm add api-service-mongo
yarn add api-service-mongo
bun add api-service-mongo
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.19.15 |
| Published | 2021-03-07 |
| First published | 2019-04-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 12 |
| Unpacked size | 100.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | troven |

## Links

- npm: https://www.npmjs.com/package/api-service-mongo
- npm.io page: https://npm.io/package/api-service-mongo

## Dependencies (12)

- [config](https://npm.io/package/config.md) ^3.3.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.20
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.14.0
- [mongodb](https://npm.io/package/mongodb.md) ^3.5.9
- [@types/node](https://npm.io/package/@types/node.md) ^10.17.29
- [@types/assert](https://npm.io/package/@types/assert.md) ^1.5.2
- [@types/config](https://npm.io/package/@types/config.md) 0.0.34
- [@types/lodash](https://npm.io/package/@types/lodash.md) ^4.14.161
- [api-service-core](https://npm.io/package/api-service-core.md) ^0.60.26
- [@types/body-parser](https://npm.io/package/@types/body-parser.md) ^1.19.0
- [api-service-common](https://npm.io/package/api-service-common.md) ^0.16.12
- [winston-loggly-bulk](https://npm.io/package/winston-loggly-bulk.md) ^2.0.3

## Recent versions

- 0.19.15 (latest) — 2021-03-07
- 0.19.14 — 2021-03-07
- 0.19.13 — 2021-02-18
- 0.19.12 — 2021-01-19
- 0.19.11 — 2021-01-19
- 0.19.10 — 2020-12-30
- 0.19.9 — 2020-12-30
- 0.19.8 — 2020-12-29
- 0.19.7 — 2020-12-28
- 0.19.6 — 2020-12-28
- 0.19.5 — 2020-12-07
- 0.19.4 — 2020-12-07
- 0.19.3 — 2020-12-05
- 0.19.2 — 2020-12-01
- 0.19.1 — 2020-11-21
- … 75 more at https://npm.io/package/api-service-mongo/versions

## 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
```

---
_Source: https://npm.io/package/api-service-mongo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
