Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 3184b52

Browse files
committed
test: Adds test suite via ava
1 parent fd8d93d commit 3184b52

8 files changed

+858
-56
lines changed

README.md

+23-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [Using a Data API api key (preferred)](#using-a-data-api-api-key-preferred)
1111
- [Using Email and Password](#using-email-and-password)
1212
- [Using a custom JWT](#using-a-custom-jwt)
13+
- [Using Bearer Auth (required for browser)](#using-bearer-auth-required-for-browser)
1314
- [Supported Methods and API](#supported-methods-and-api)
1415
- [Create a Mongo Client](#create-a-mongo-client)
1516
- [Select a Database](#select-a-database)
@@ -49,14 +50,19 @@ const mc = new MongoClient({
4950
},
5051
});
5152

52-
await mc.findOne({
53-
/* good 'ole mongo */
53+
const { data, error } = await mc.findOne({
54+
/* good 'ole mongo! See the Collection Methods for what's available */
5455
});
5556
```
5657

5758
## Authentication
5859

59-
Authenticating to the Mongo Data API is done with either an API Key, an email/password, or via a JWT string:
60+
| Authentication Method | Supported |
61+
| :-------------------- | :-------: |
62+
| API Key ||
63+
| Email & Password ||
64+
| Custom JWT ||
65+
| Bearer | ⚠️ |
6066

6167
### Using a Data API api key (preferred)
6268

@@ -96,6 +102,20 @@ Authenticating to the Mongo Data API is done with either an API Key, an email/pa
96102
}
97103
```
98104

105+
### Using Bearer Auth (required for browser)
106+
107+
_[Read more about authenticating Realm users in the browser](https://www.mongodb.com/docs/atlas/app-services/users/sessions/#std-label-manage-user-sessions)_
108+
109+
```ts
110+
{
111+
// ...
112+
auth: {
113+
/** @type string */
114+
bearerToken: tokenFromRealm,
115+
},
116+
}
117+
```
118+
99119
# Supported Methods and API
100120

101121
## Create a Mongo Client

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@
5959
"@commitlint/config-conventional": "^15.0.0",
6060
"@types/node": "^18.15.11",
6161
"ava": "^4.3.0",
62+
"cross-fetch": "^3.1.5",
6263
"dotenv": "^16.0.3",
6364
"esbuild": "0.17.16",
6465
"husky": "^7.0.4",
6566
"lint-staged": "13.0.3",
67+
"msw": "^1.2.1",
68+
"node-fetch": "^3.3.1",
6669
"npm-run-all": "^4.1.5",
6770
"release-it": "^15.10.2",
6871
"shx": "^0.3.4",

0 commit comments

Comments
 (0)