Registry / database / api-service-mongo

api-service-mongo

JSON →
library0.19.15jsnpmunverified

Micro-chassis for MongoDB that exposes named MongoDB queries as RESTful API endpoints via an OpenAPI definition. Version 0.19.15 is the current stable release, with irregular cadence. It maps URL sub-paths to named MongoDB operations, supporting GET, POST, PUT, and DELETE on collections and documents. Differs from typical REST-to-MongoDB adapters by using operationId mappings in an OpenAPI spec to define routes declaratively.

npm install api-service-mongo
INSTALL
IMPORT
SIG · API-SERVICE-MONGO
A
api-service-mongo
databasejavascriptv0.19.15
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import apiServiceMongo from 'api-service-mongo'
const apiServiceMongo = require('api-service-mongo')
ESM-only package; TypeScript types are bundled.
MongoChassis
import { MongoChassis } from 'api-service-mongo'
Named export for the chassis class.
config
import { config } from 'api-service-mongo'
const config = require('api-service-mongo').config
Default configuration object.

Initializes the MongoDB micro-chassis with an OpenAPI configuration and starts the server on port 7001.

import apiServiceMongo from 'api-service-mongo'; const options = { mongdb: { database: 'example', host: 'localhost', port: 27017, username: 'me', password: process.env.MONGO_PASSWORD ?? 'secret' }, openapi: { paths: { '/mongodb/example/:collection': { get: { chassis: { operationId: 'mongdb' } }, post: { chassis: { operationId: 'mongdb' } } }, '/mongodb/:collection/:id': { get: { chassis: { operationId: 'mongdb' } }, put: { chassis: { operationId: 'mongdb' } }, delete: { chassis: { operationId: 'mongdb' } } }, '/healthz': { get: { chassis: { operationId: 'heartbeat' } } }, '/swagger': { get: { chassis: { operationId: 'apidocs' } } } } } }; const app = apiServiceMongo(options); app.listen(7001, () => { console.log('Server running on port 7001'); });
Debug
Known issues
deprecatedPackage name 'api-service-mongo' is deprecated after v0.19.15.
fix
Migrate to '@some-scope/mongo-chassis' (if released) or consider alternatives like 'mongodb-rest'.
affects: >=0.19.15
gotchaThe 'mongdb' plugin misspelling is intentional; do not correct to 'mongodb'.
fix
Use 'mongdb' in config and operationId mappings exactly as documented.
affects: *
breakingIn v0.18.0, the config structure changed: 'mongodb' key renamed to 'mongdb'.
fix
Update config from 'mongodb' to 'mongdb'.
affects: >=0.18.0
gotchaoperationId can be reused across multiple paths, which violates OpenAPI spec.
fix
Ensure operationId is consistent if used in multiple paths; understand this is intentional.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'api-service-mongo'
Package not installed or wrong import path.
fix
Run 'npm install api-service-mongo' and ensure import is correct: import apiServiceMongo from 'api-service-mongo'
TypeError: apiServiceMongo is not a function
Using default import incorrectly when package expects named export.
fix
Use default import: import apiServiceMongo from 'api-service-mongo'
MongoNetworkError: failed to connect to server [localhost:27017] on first connect
MongoDB not running or connection config wrong.
fix
Start MongoDB Docker container: docker run -p 27017:27017 mongo:latest
Upgrade
Version history
0.19.15latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
api-service-mongo — npm install api-service-mongo · libregistry