Skip to content

Commit

Permalink
fix: delete axios & move to node 18
Browse files Browse the repository at this point in the history
  • Loading branch information
dubisdev committed Dec 4, 2022
1 parent d7654a7 commit 2fa6f22
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: Install dependencies
run: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Install dependencies
run: yarn
- name: Release
Expand Down
4 changes: 1 addition & 3 deletions deploy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import axios from 'axios';

const deployWebhooksURL = process.env.DEPLOY_ENDPOINT_WEBHOOKS;

if (deployWebhooksURL) await axios.get(deployWebhooksURL);
if (deployWebhooksURL) await fetch(deployWebhooksURL);
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@
"@addtodoist/twitter-autohook": "2.2.0",
"@bugsnag/js": "7.18.0",
"@doist/todoist-api-typescript": "2.1.2",
"axios": "1.2.0",
"crypto-js": "4.1.1",
"dotenv": "16.0.3",
"mongoose": "6.7.5",
"twitter-api-v2": "1.12.9"
},
"engines": {
"node": ">=16"
"node": ">=18"
},
"repository": {
"type": "git",
Expand Down
31 changes: 19 additions & 12 deletions src/services/todoist-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
* This module includes tools to interact with the Todoist API.
*/

import axios from 'axios';
import { TodoistApi } from '@doist/todoist-api-typescript';

export const getTodoistUserData = async (token: string) => {
const { data } = await axios.post('https://api.todoist.com/sync/v9/sync',
{ sync_token: '*', resource_types: ['user'] },
{ headers: { Authorization: `Bearer ${token}` } }
);

const {user} = data;
const headers = { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` };
const body = JSON.stringify({ sync_token: '*', resource_types: '["user"]' });
const requestConfig = { method: 'POST', headers, body };

const { user } = await fetch('https://api.todoist.com/sync/v9/sync', requestConfig ).then(res => {
if (res.ok) return res.json();
throw new Error('Something went wrong getting your Todoist user data');
});

return user;
};

Expand All @@ -35,11 +37,16 @@ export const getTodoistProjects = (token: string) => {

export const revokeAccessToken = async (token: string) => {
const revokeUrl = 'https://api.todoist.com/sync/v9/access_tokens/revoke';
const { status } = await axios.post(revokeUrl, {
client_id: process.env.TODOIST_CLIENT_ID,
client_secret: process.env.TODOIST_CLIENT_SECRET,
access_token: token,
});

const status = await fetch(revokeUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
client_id: process.env.TODOIST_CLIENT_ID,
client_secret: process.env.TODOIST_CLIENT_SECRET,
access_token: token,
})
}).then(res => res.status);

if (status === 204) return true;
return false;
Expand Down
19 changes: 0 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1925,15 +1925,6 @@ axios-retry@^3.1.9:
"@babel/runtime" "^7.15.4"
is-retry-allowed "^2.2.0"

[email protected]:
version "1.2.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.2.0.tgz#1cb65bd75162c70e9f8d118a905126c4a201d383"
integrity sha512-zT7wZyNYu3N5Bu0wuZ6QccIf93Qk1eV8LOewxgjOZFd2DenOs98cJ7+Y6703d0wkaXGY6/nZd4EweJaHz9uzQw==
dependencies:
follow-redirects "^1.15.0"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

axios@^0.27.0:
version "0.27.2"
resolved "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz"
Expand Down Expand Up @@ -3688,11 +3679,6 @@ follow-redirects@^1.14.9:
resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz"
integrity sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==

follow-redirects@^1.15.0:
version "1.15.2"
resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==

foreground-child@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz"
Expand Down Expand Up @@ -6085,11 +6071,6 @@ promzard@^0.3.0:
dependencies:
read "1"

proxy-from-env@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz"
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==

pstree.remy@^1.1.8:
version "1.1.8"
resolved "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz"
Expand Down

0 comments on commit 2fa6f22

Please sign in to comment.