Skip to content

Commit

Permalink
feat: improve stability
Browse files Browse the repository at this point in the history
  • Loading branch information
ifyour committed Nov 6, 2023
1 parent 4ed4bcf commit 231c246
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/const.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export const API_URL = 'https://www2.deepl.com/jsonrpc';
export const DEFAULT_LANGUAGE = 'AUTO';
export const REQUEST_ALTERNATIVES = 3;
export const DEFAULT_REQUEST_PARAMS = {
text: '',
source_lang: DEFAULT_LANGUAGE,
target_lang: DEFAULT_LANGUAGE

Check failure on line 7 in src/const.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Insert `,`
};

Check failure on line 8 in src/const.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Insert `⏎`
4 changes: 2 additions & 2 deletions src/query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RequestParams, ResponseParams } from './types';
import { API_URL, DEFAULT_LANGUAGE, REQUEST_ALTERNATIVES } from './const';
import { API_URL, DEFAULT_LANGUAGE, REQUEST_ALTERNATIVES, DEFAULT_REQUEST_PARAMS } from './const';

Check failure on line 2 in src/query.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Replace `·API_URL,·DEFAULT_LANGUAGE,·REQUEST_ALTERNATIVES,·DEFAULT_REQUEST_PARAMS·` with `⏎··API_URL,⏎··DEFAULT_LANGUAGE,⏎··REQUEST_ALTERNATIVES,⏎··DEFAULT_REQUEST_PARAMS,⏎`

function buildRequestParams(sourceLang: string, targetLang: string) {
return {
Expand Down Expand Up @@ -58,7 +58,7 @@ async function query(params: RequestParams) {
'Content-Type': 'application/json; charset=utf-8',
},
method: 'POST',
body: buildRequestBody(params),
body: buildRequestBody({ ...DEFAULT_REQUEST_PARAMS, ...params }),
});

if (response.ok) {
Expand Down

0 comments on commit 231c246

Please sign in to comment.