Skip to content

Commit

Permalink
Fix check-types (remove node-fetch & form-data) (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashachabin authored Jun 17, 2024
1 parent 7abe2ce commit 62d5749
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 165 deletions.
5 changes: 1 addition & 4 deletions common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
},
"dependencies": {
"encoding": "^0.1.13",
"form-data": "^4.0.0",
"node-fetch": "^2.7.0",
"tslib": "^2.6.2",
"typescript": "^4.9.5"
},
"devDependencies": {
"@types/node": "^18.17.15",
"@types/node-fetch": "^2.6.4"
"@types/node": "^20.14.3"
}
}
4 changes: 1 addition & 3 deletions common/strapi/create-methods.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import fetch, { Response } from 'node-fetch';

import { StrapiContentTypes } from '../types/strapi';
import { parallelRequests } from '../utils/parallelRequests';
import { STRAPI_URL, REQUEST_PAGINATION_SIZE } from './constants';
Expand Down Expand Up @@ -123,7 +121,7 @@ export function createStrapiMethods(contentType: StrapiContentTypes, jwt?: strin
throw new Error(rawResult.statusText);
}

const result = await rawResult.json();
const result = await rawResult.json() as any;

if (result.error) {
throw new Error(JSON.stringify(result.error));
Expand Down
2 changes: 0 additions & 2 deletions common/strapi/login.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import fetch from 'node-fetch';

import { StrapiLoginResponse } from '../types/strapi';
import { STRAPI_URL, EMAIL, PASSWORD } from './constants';

Expand Down
4 changes: 0 additions & 4 deletions common/strapi/upload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import fetch from 'node-fetch';
import FormData from 'form-data';

import { STRAPI_URL } from './constants';

export async function deleteFile(id: number, jwt: string) {
Expand All @@ -20,7 +17,6 @@ export async function uploadFile(data: FormData, jwt: string) {
try {
const resp = await fetch(`${STRAPI_URL}/api/upload`, {
headers: {
...data.getHeaders(),
...(jwt ? { Authorization: `Bearer ${jwt}` } : {}),
},
method: 'POST',
Expand Down
Loading

0 comments on commit 62d5749

Please sign in to comment.