Skip to content

Proxy support added for axios. #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ bower_components
node_modules
.npm
npm-debug.log
.spago

# cache
.pulp-cache
Expand All @@ -25,4 +26,4 @@ generated-docs
/.purs*

# editor
.vscode
.vscode
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ main = launchAff_ do
* Build Project

```bash
$ yarn install
$ yarn build
```

Expand All @@ -61,4 +62,4 @@ $ yarn test

```bash
$ yarn start
```
```
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"build": "pulp build"
},
"dependencies": {
"axios": "^0.19.0",
"axios": "^0.21.1",
"pulp": "^13.0.0",
"purescript": "^0.13.2"
"purescript": "^0.14.4"
}
}
}
22 changes: 21 additions & 1 deletion src/Axios/Config.purs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,24 @@ auth username password = Config "auth" $ encode { username, password }

-- | Constructs a `Config` with key headers from an array of `Header`
headers :: Array Header -> Config
headers = Config "headers" <<< encode
headers = Config "headers" <<< encode

type ProxyRecord =
{ host :: String
, port :: Number }

-- Commented out because this is for Node only!
-- | Constructs a `Config` with a proxy from a URL
-- proxyFromURL :: String -> Config
-- proxyFromURL str =
-- let url = Node.URL.parse str in
-- let port = case Data.Number.parse url.port of
-- Just n -> n
-- Nothing -> 8000
-- in
-- -- let pr = { host: url.hostname, port: port }
-- Config "proxy" $ encode { host: url.hostname, port: port }

-- | Constructs a `Config` with a proxy from hostname and port
proxy :: String -> Int -> Config
proxy hostname port = Config "proxy" $ encode { host:hostname, port: port }
2 changes: 1 addition & 1 deletion test/Types.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Axios (class Axios, defaultAxios', genericAxios)
import Axios.Types (Header(..), Method(..))
import Axios.Config (auth, baseUrl, headers, method)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Show.Generic (genericShow)
import Foreign.Generic (class Decode, class Encode, defaultOptions, genericDecode, genericEncode)


Expand Down