Skip to content

Commit

Permalink
feat: v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
surmon-china committed Nov 23, 2022
1 parent e707983 commit 5be63f1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

### v0.4.0 (2022-11-24)

**Breaking Change**

- API key desensitization is no longer processed when an error occurs.

### v0.3.0 (2022-11-24)

**Breaking Change**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mongodb-data-api",
"version": "0.3.0",
"version": "0.4.0",
"description": "MongoDB atlas data API SDK for Node.js",
"author": "Surmon",
"license": "MIT",
Expand Down
12 changes: 2 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ export class MongoDBDataAPI<InnerDoc = Document> {
return `${endpoint}/action/${action}`
}

const API_KEY_FIELD = 'api-key'

return this.#axios({
method: 'post',
data: JSON.stringify(mergedParams),
Expand All @@ -148,7 +146,7 @@ export class MongoDBDataAPI<InnerDoc = Document> {
headers: {
'Content-Type': 'application/json',
'Access-Control-Request-Headers': '*',
[API_KEY_FIELD]: this.#config.apiKey
'api-key': this.#config.apiKey
},
...axiosConfig
})
Expand All @@ -157,13 +155,7 @@ export class MongoDBDataAPI<InnerDoc = Document> {
})
.catch((error) => {
// https://www.mongodb.com/docs/atlas/api/data-api-resources/#error-codes
if (_axios.isAxiosError(error)) {
const errorJSON: any = error.toJSON()
errorJSON.config.headers[API_KEY_FIELD] = '*****'
return Promise.reject(errorJSON)
} else {
return Promise.reject(error)
}
return Promise.reject(_axios.isAxiosError(error) ? error.toJSON() : error)
})
}

Expand Down

0 comments on commit 5be63f1

Please sign in to comment.