Skip to content

Commit

Permalink
Use require instead of import
Browse files Browse the repository at this point in the history
  • Loading branch information
negative0 committed Jun 14, 2020
1 parent 86bb71c commit ff1c73b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,6 @@ temp/

# End of https://www.gitignore.io/api/node,intellij+all

/lib/
/lib/

/.idea/
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"main": "lib/index.js",
"scripts": {
"test": "echo \"Skipping tests for now TODO\"",
"compile:commonjs": "better-npm-run compile:commonjs",
"compile:es": "babel -d es/ src/",
"compile": "babel src --out-dir lib",
"compile:es": "babel src --out-dir lib",
"compile": "npm run compile:es ",
"prepare": "npm run compile"
},
"babel": {
Expand Down
10 changes: 6 additions & 4 deletions src/axiosInstance.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from "axios";
import {AUTH_KEY, IP_ADDRESS_KEY} from "./constants";
const axios = require("axios");

const constants = require("./constants");

/**
* Global level axios configuration. These settings are automatically used in other places by using an axiosInstance instead of axios directly
Expand All @@ -14,11 +15,12 @@ export let axiosInstance = axios.create({
*/
axiosInstance.interceptors.request.use(
config => {
config.baseURL = localStorage.getItem(IP_ADDRESS_KEY);
config.baseURL = localStorage.getItem(constants.IP_ADDRESS_KEY);

config.headers.Authorization = 'Basic ' + localStorage.getItem(AUTH_KEY);
config.headers.Authorization = 'Basic ' + localStorage.getItem(constants.AUTH_KEY);
return config;
},
error => Promise.reject(error)
);

export default axiosInstance;
15 changes: 8 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {axiosInstance} from "./axiosInstance";
import urls from "./endpoint";
import {addColonAtLast, isLocalRemoteName} from "./Tools";
const axiosInstance = require('./axiosInstance');
const urls = require('./endpoint');
const tools = require('./Tools')

/**
* getStats returns the current rclone stats.
Expand Down Expand Up @@ -52,7 +52,7 @@ export const setCurrentBandwidthSetting = (newRate) => {
* @returns {Function}
*/
export const createNewPublicLink = (remoteName, remotePath) => {
remoteName = addColonAtLast(remoteName);
remoteName = tools.addColonAtLast(remoteName);
return new Promise((resolve, reject) => {
axiosInstance.post(urls.createPublicLink, {fs: remoteName, remote: remotePath}).then(res => {
resolve(res.data);
Expand Down Expand Up @@ -209,8 +209,9 @@ export const getJobStatus = (jobId) => {
}

/**
* purgeDir returns the status of a job with jobId
* @param jobId {number} Valid job id
* purgeDir deletes the directory with given fs and remote
* @param fs {string} Name of fs
* @param remote {string} path remoteName
* @return {Promise<unknown>}
*/
export const purgeDir = (fs , remote) => {
Expand Down Expand Up @@ -248,7 +249,7 @@ export const deleteFile = (fs , remote) => {
}

/**
* cleanTrashForRemote returns the status of a job with jobId
* cleanTrashForRemote cleans the trash for the remote with remote fs
* @param fs {string} Remote Name
* @return {Promise<unknown>}
*/
Expand Down

0 comments on commit ff1c73b

Please sign in to comment.