Skip to content

Commit 5be63f1

Browse files
committed
feat: v0.4.0
1 parent e707983 commit 5be63f1

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
### v0.4.0 (2022-11-24)
6+
7+
**Breaking Change**
8+
9+
- API key desensitization is no longer processed when an error occurs.
10+
511
### v0.3.0 (2022-11-24)
612

713
**Breaking Change**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mongodb-data-api",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "MongoDB atlas data API SDK for Node.js",
55
"author": "Surmon",
66
"license": "MIT",

src/index.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ export class MongoDBDataAPI<InnerDoc = Document> {
134134
return `${endpoint}/action/${action}`
135135
}
136136

137-
const API_KEY_FIELD = 'api-key'
138-
139137
return this.#axios({
140138
method: 'post',
141139
data: JSON.stringify(mergedParams),
@@ -148,7 +146,7 @@ export class MongoDBDataAPI<InnerDoc = Document> {
148146
headers: {
149147
'Content-Type': 'application/json',
150148
'Access-Control-Request-Headers': '*',
151-
[API_KEY_FIELD]: this.#config.apiKey
149+
'api-key': this.#config.apiKey
152150
},
153151
...axiosConfig
154152
})
@@ -157,13 +155,7 @@ export class MongoDBDataAPI<InnerDoc = Document> {
157155
})
158156
.catch((error) => {
159157
// https://www.mongodb.com/docs/atlas/api/data-api-resources/#error-codes
160-
if (_axios.isAxiosError(error)) {
161-
const errorJSON: any = error.toJSON()
162-
errorJSON.config.headers[API_KEY_FIELD] = '*****'
163-
return Promise.reject(errorJSON)
164-
} else {
165-
return Promise.reject(error)
166-
}
158+
return Promise.reject(_axios.isAxiosError(error) ? error.toJSON() : error)
167159
})
168160
}
169161

0 commit comments

Comments
 (0)