Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

Commit

Permalink
ready for release
Browse files Browse the repository at this point in the history
  • Loading branch information
ptariche committed Apr 10, 2018
1 parent e201627 commit 9657aa0
Show file tree
Hide file tree
Showing 15 changed files with 8,940 additions and 0 deletions.
161 changes: 161 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
### Bower ###
bower_components
.bower-cache
.bower-registry
.bower-tmp

### Code ###
# Visual Studio Code - https://code.visualstudio.com/
.settings/
.vscode/
tsconfig.json
jsconfig.json

### Emacs ###
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*

# Org-mode
.org-id-locations
*_archive

# flymake-mode
*_flymake.*

# eshell files
/eshell/history
/eshell/lastdir

# elpa packages
/elpa/

# reftex files
*.rel

# AUCTeX auto folder
/auto/

# cask packages
.cask/
dist/

# Flycheck
flycheck_*.el


# projectiles files
.projectile

# directory configuration
.dir-locals.el

### macOS ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
build/

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env


### Vim ###
# swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# session
Session.vim
# temporary
.netrwhist
# auto-generated tag files
tags

local.env
64 changes: 64 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"disallowEmptyBlocks": true,
"disallowSpacesInCallExpression": false,
"disallowSpacesInsideArrayBrackets": false,
"disallowSpacesInsideParentheses": false,
"disallowQuotedKeysInObjects": true,
"disallowSpaceAfterObjectKeys": false,
"disallowSpaceAfterPrefixUnaryOperators": false,
"disallowSpaceBeforePostfixUnaryOperators": false,
"disallowSpaceBeforeBinaryOperators": [
","
],
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowSpaceBeforeComma": true,
"disallowYodaConditions": true,
"disallowKeywords": [ "with" ],
"disallowKeywordsOnNewLine": ["else"],
"disallowMultipleLineBreaks": false,
"disallowMultipleLineStrings": true,
"disallowMultipleVarDecl": true,
"disallowSpaceBeforeSemicolon": true,
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
"requireSpacesInConditionalExpression": true,
"requireBlocksOnNewline": 1,
"requireCommaBeforeLineBreak": true,
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceAfterBinaryOperators": true,
"requireLineFeedAtFileEnd": true,
"requireCapitalizedConstructors": true,
"requireDotNotation": true,
"requireSpacesInForStatement": true,
"requireSpaceBetweenArguments": true,
"requireCurlyBraces": [
"do",
"for",
"try",
"catch"
],
"requireSpaceAfterKeywords": [
"do",
"if",
"else",
"for",
"while",
"do",
"switch",
"case",
"return",
"try",
"catch",
"typeof",
"function"
],
"requirePaddingNewLinesAfterBlocks": {
"allExcept": ["inProperties"]
},
"requireSemicolons": true,
"safeContextKeyword": ["self", "ctx", "_this", "_self"],
"validateLineBreaks": "LF",
"validateQuoteMarks": "'",
"validateIndentation": 2
}
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
.nyc_output/
coverage/
tmp/
.vscode/
npm-debug.log
.travis.yml
test/
*.tgz
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: node_js
sudo: false
node_js:
- "8"
- "9"
install:
- yarn install
- yarn add coveralls
script:
- npm run coverage
after_success:
- nyc report --reporter=text-lcov | coveralls
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# FDOH

[![npm version](https://img.shields.io/npm/v/fdoh.svg?style=flat-square)](https://www.npmjs.org/package/fdoh)
[![Build Status](https://travis-ci.org/ptariche/fdoh.svg?branch=master)](https://travis-ci.org/ptariche/fdoh)
[![Coverage Status](https://coveralls.io/repos/github/ptariche/fdoh/badge.svg?branch=master)](https://coveralls.io/github/ptariche/fdoh?branch=master)

### Fetch with DNS over HTTPS

The point of this utility is to be able to utilize node-fetch with your DNS queries running over HTTPS from Cloudflare [1.1.1.1](https://1.1.1.1) or Google DNS over HTTPS.

### Fetch Example
- [Link](./examples/fetch.js)

### As Axios Interceptor
Utilization of this can also be added as an [axios plugin](./examples/axios.js).

### Installation

```js
npm install --save fdoh
```

### Usage of Primary Class
- *Fdoh*
* Arguments
+ **url** {String}(Fetch API Url)
+ **options** {Object}(Fetch API Object)
+ **provider** {String}(GOOGLE or CLOUDFLARE. Defaulted to Cloudflare)
+ **responseWithConfig** {Boolean} (Utilized to return a basic config for middleware or interceptor libraries)

* Returns {Optional Object or Function-Object}
+ if responseWithConfig is not passed, [Node-Fetch](https://github.com/bitinn/node-fetch) is returned
+ if responseWithConfig is set to true, an object is returned
+ *Object*
+ uri {String}
+ headers {Object}


### Dependencies
- [dohdec](https://github.com/hildjj/dohdec)
- [is-ip](https://github.com/sindresorhus/is-ip)
20 changes: 20 additions & 0 deletions examples/axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const Util = require('./util');
const Fdoh = require('./../index');
const Axios = require('axios');

Axios.interceptors.request.use( config => {
return Fdoh(config.url, null, null, true)
.then ( _config => {
config.url = _config.url;
config.headers = _config.headers;
return Promise.resolve(config);
})
.catch ( (err) => {
return Promise.reject(err);
});
});

Axios
.get(Util.URL.NETFLIX)
.then(response => Util._Log(response.data))
.catch(err => Util._Error(err));
12 changes: 12 additions & 0 deletions examples/fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const Util = require('./util');
const Fdoh = require('./../index');
const Fetch = Fdoh;

Fetch(Util.URL.NETFLIX)
.then (response => {
response.json()
.then( result => Util._Log(result))
.catch ( err => Util._Error(err) );
})
.catch ( err => Util._Error(err) );

5 changes: 5 additions & 0 deletions examples/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports._Error = (err) => console.error(err);
module.exports._Log = (msg) => console.log(msg);
module.exports.URL = {
NETFLIX: 'https://help.netflix.com/api/en/deviceerrors?locale=en'
};
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/');

0 comments on commit 9657aa0

Please sign in to comment.