Mongodb realm api client for NODEJS
A mongdb realm api client for nodejs.
This is using mongodb-stitch-api-client under the hood. Soon mongodb-stitch-api-client
will be deprecated.
How to install
npm install mongodb-realm-api-client
Getting Started
The basic syntax is:
const getClient = require("mongodb-realm-api-client");
const {trigger, application} = getClient({
"publicKey": "some public key",
"privateKey": "some private key",
"baseUrl": "https://stitch.mongodb.com/api/admin/v3.0",
"projectId": "some project/group id",
"appId": "some stitch appId" // Optional when you are creating app using Application
});
await trigger.getAll();
const createApplication = await application.create({"name": "myFirstStitchApp", "deployment_model": "LOCAL", "location": "IE"});
Running the tests
npm test
API
Following entities are currently supported
Application
Promise
application.create(body, [productType]) ⇒ Creates the stitch application
Kind: instance method of Application
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Default | Description |
---|---|---|---|
body | Object |
Object that contains stitch application details. | |
[productType] | string |
standard |
Optional product type. standard or atlas |
Promise
application.getAll([productType]) ⇒ Returns all applications
Kind: instance method of Application
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Default | Description |
---|---|---|---|
[productType] | string |
standard |
Optional product type. standard or atlas |
Promise
application.get(appId) ⇒ Returns a single application as per app Id
Kind: instance method of Application
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
appId | string |
Application Id |
Promise
application.delete(appId) ⇒ Deletes a single application as per app Id
Kind: instance method of Application
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
appId | string |
Application Id |
Service
Promise
service.create(body) ⇒ Creates the service
Kind: instance method of Service
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
body | Object |
Object that contains stitch service details. |
Promise
service.update(serviceId, body) ⇒ Updates the service
Kind: instance method of Service
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
serviceId | string |
Service Id. |
body | Object |
Object that contains stitch service details. |
Promise
service.getAll() ⇒ Returns all services
Kind: instance method of Service
Returns: Promise
- - promise which resolves on success and rejects on error
Promise
service.get(serviceId) ⇒ Returns single service as per service Id
Kind: instance method of Service
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
serviceId | string |
Service Id |
Promise
service.delete(serviceId) ⇒ Deletes single service as per service Id
Kind: instance method of Service
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
serviceId | string |
Service Id |
Trigger
Promise
trigger.create(body) ⇒ Creates the trigger
Kind: instance method of Trigger
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
body | Object |
Object that contains stitch trigger details. |
Promise
trigger.update(triggerId, body) ⇒ Updates the trigger
Kind: instance method of Trigger
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
triggerId | string |
Service Id. |
body | Object |
Object that contains stitch trigger details. |
Promise
trigger.resume(triggerId, [useResumeToken]) ⇒ Resumes the trigger
Kind: instance method of Trigger
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
triggerId | string |
Service Id. |
useResumeToken | bool |
Whether to use resume token for restarting trigger. Default is true. |
Promise
trigger.getAll() ⇒ Returns all triggers
Kind: instance method of Trigger
Returns: Promise
- - promise which resolves on success and rejects on error
Promise
trigger.get(triggerId) ⇒ Returns single trigger as per trigger Id
Kind: instance method of Trigger
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
triggerId | string |
Trigger Id |
Promise
trigger.delete(triggerId) ⇒ Deletes single trigger as per trigger Id
Kind: instance method of Trigger
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
triggerId | string |
Trigger Id |
Token
Promise
token.getBearerToken() ⇒ Returns the bearer token as per public key and private key
Kind: instance method of Token
Returns: Promise
- - promise which resolves on success and rejects on error
StitchFunction
Promise
stitchFunction.create(body) ⇒ Creates the function
Kind: instance method of StitchFunction
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
body | Object |
Object that contains stitch functions details. |
Promise
stitchFunction.update(functionId, body) ⇒ Updates the function
Kind: instance method of StitchFunction
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
functionId | string |
Service Id. |
body | Object |
Object that contains stitch function details. |
Promise
stitchFunction.getAll() ⇒ Returns all functions
Kind: instance method of StitchFunction
Returns: Promise
- - promise which resolves on success and rejects on error
Promise
stitchFunction.get(functionId) ⇒ Returns single function as per function Id
Kind: instance method of StitchFunction
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
functionId | string |
function Id |
Promise
stitchFunction.delete(functionId) ⇒ Deletes single function as per function Id
Kind: instance method of StitchFunction
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
functionId | string |
function Id |
Rule
Promise
rule.create(serviceId, body) ⇒ Creates the rule
Kind: instance method of Rule
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
serviceId | string |
service id |
body | Object |
Object that contains stitch rules details. |
Promise
rule.update(serviceId, ruleId, body) ⇒ Updates the rule
Kind: instance method of Rule
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
serviceId | string |
service id |
ruleId | string |
Service Id. |
body | Object |
Object that contains stitch rule details. |
Promise
rule.getAll(serviceId) ⇒ Returns all rules
Kind: instance method of Rule
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
serviceId | string |
service id |
Promise
rule.get(serviceId, ruleId) ⇒ Returns single rule as per rule Id
Kind: instance method of Rule
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
serviceId | string |
service id |
ruleId | string |
rule Id |
Promise
rule.delete(serviceId, ruleId) ⇒ Deletes single rule as per rule Id
Kind: instance method of Rule
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
serviceId | string |
service id |
ruleId | string |
rule Id |
Log
Promise
log.get([options]) ⇒ Returns all the logs as per options passed
Kind: instance method of Log
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Default | Description |
---|---|---|---|
[options] | object |
{} |
Options having parameter which will be passed as query string |
Security
Promise
security.allowOrigins(body) ⇒ Set the allowed HTTP origins from which Stitch should allow requests.
Kind: instance method of Security
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
body | Object |
Object that contains allowed http origins |
Promise
security.getAll() ⇒ List the allowed HTTP origins from which Stitch should allow requests.
Kind: instance method of Security
Returns: Promise
- - promise which resolves on success and rejects on error
Promise
email.sendConfirmationEmail(email) ⇒ Send a confirmation email.
Kind: instance method of Email
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
string |
Email address. |
Promise
email.confirmPendingUser(email) ⇒ Confirm a pending user.
Kind: instance method of Email
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
string |
Email address. |
Promise
email.reRunPendingConfirmation(email) ⇒ Re-runs a pending user’s confirmation workflow.
Kind: instance method of Email
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
string |
Email address. |
Webhook
Promise
webhook.create(serviceId, body) ⇒ Creates the webhook
Kind: instance method of Webhook
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
serviceId | string |
service id |
body | Object |
Object that contains stitch webhooks details. |
Promise
webhook.update(serviceId, webhookId, body) ⇒ Updates the webhook
Kind: instance method of Webhook
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
serviceId | string |
service id |
webhookId | string |
Service Id. |
body | Object |
Object that contains stitch webhook details. |
Promise
webhook.getAll(serviceId) ⇒ Returns all webhooks
Kind: instance method of Webhook
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
serviceId | string |
service id |
Promise
webhook.get(serviceId, webhookId) ⇒ Returns single webhook as per webhook Id
Kind: instance method of Webhook
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
serviceId | string |
service id |
webhookId | string |
webhook Id |
Promise
webhook.delete(serviceId, webhookId) ⇒ Deletes single webhook as per webhook Id
Kind: instance method of Webhook
Returns: Promise
- - promise which resolves on success and rejects on error
Param | Type | Description |
---|---|---|
serviceId | string |
service id |
webhookId | string |
webhook Id |