Skip to content

Commit

Permalink
refactor(h5p-server): removed qs and merge dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
sr258 committed Dec 29, 2024
1 parent 421cbb3 commit 6408292
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 12,028 deletions.
1,519 changes: 16 additions & 1,503 deletions packages/h5p-examples/package-lock.json

Large diffs are not rendered by default.

683 changes: 16 additions & 667 deletions packages/h5p-express/package-lock.json

Large diffs are not rendered by default.

841 changes: 13 additions & 828 deletions packages/h5p-html-exporter/package-lock.json

Large diffs are not rendered by default.

848 changes: 5 additions & 843 deletions packages/h5p-mongos3/package-lock.json

Large diffs are not rendered by default.

1,178 changes: 0 additions & 1,178 deletions packages/h5p-react/package-lock.json

Large diffs are not rendered by default.

1,028 changes: 2 additions & 1,026 deletions packages/h5p-redis-lock/package-lock.json

Large diffs are not rendered by default.

558 changes: 11 additions & 547 deletions packages/h5p-rest-example-client/package-lock.json

Large diffs are not rendered by default.

3,145 changes: 87 additions & 3,058 deletions packages/h5p-rest-example-server/package-lock.json

Large diffs are not rendered by default.

215 changes: 0 additions & 215 deletions packages/h5p-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions packages/h5p-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@
"https-proxy-agent": "^5.0.1",
"image-size": "^1.0.2",
"jsonpath": "^1.1.1",
"merge": "^2.1.1",
"mime-types": "^2.1.35",
"nanoid": "^3.3.2",
"node-machine-id": "^1.1.12",
"promisepipe": "^3.0.0",
"qs": "^6.11.1",
"sanitize-html": "^2.10.0",
"stream-buffers": "^3.0.2",
"tmp-promise": "^3.0.3",
Expand Down
21 changes: 13 additions & 8 deletions packages/h5p-server/src/ContentTypeCache.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { AxiosInstance } from 'axios';
import * as merge from 'merge';
import * as qs from 'qs';
import { machineIdSync } from 'node-machine-id';

import H5pError from './helpers/H5pError';
Expand Down Expand Up @@ -91,16 +89,23 @@ export default class ContentTypeCache {
await this.registerOrGetUuid();
let formData = this.compileRegistrationData();
if (this.config.sendUsageStatistics) {
formData = merge.recursive(
true,
formData,
this.compileUsageStatistics()
);
formData = {
...formData,
...this.compileUsageStatistics()
};
}

const params = new URLSearchParams();
for (const field in formData) {
params.set(field, formData[field].toString());
}
const queryStringedFormData = params.toString();

const response = await this.httpClient.post(
this.config.hubContentTypesEndpoint,
qs.stringify(formData)
queryStringedFormData
);

if (response.status !== 200) {
throw new H5pError(
'error-communicating-with-hub',
Expand Down
Loading

0 comments on commit 6408292

Please sign in to comment.