Skip to content

Commit ad12ed8

Browse files
committed
v0.1.0
0 parents  commit ad12ed8

13 files changed

Lines changed: 18048 additions & 0 deletions

File tree

.babelrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env"
4+
],
5+
"plugins": [
6+
["@babel/plugin-proposal-class-properties"],
7+
["@babel/plugin-transform-async-to-generator"]
8+
]
9+
}

.github/workflows/unittest.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Unit test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
unit_test:
7+
runs-on: ${{ matrix.operating-system }}
8+
strategy:
9+
matrix:
10+
operating-system: [ ubuntu-18.04, windows-2016 ]
11+
node-version: [10.x, 12.x, 14.x, 15.x]
12+
13+
env:
14+
EMAIL_VALIDATION_API_KEY: ${{ secrets.API_KEY }}
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
24+
- name: Run test
25+
run: |
26+
npm install
27+
npm run test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.idea

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Abstract
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# AbstractAPI javascript-core library
2+
3+
Pure JS library for using [Abstract API](https://www.abstractapi.com/). This is core library that has some shared logic and functions used by other libraries.
4+
5+
# See other
6+
7+
To use and maintain this library, please see the following:
8+
9+
- [Javascript Email Validation](https://github.com/abstractapi/javascript-email-validation)
10+
- [Javascript IP Geolocation](https://github.com/abstractapi/javascript-ip-geolocation)
11+
- [Javascript Phone Validation](https://github.com/abstractapi/javascript-phone-validation)

dist/javascript-core.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./lib/index');

lib/index.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"use strict";
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
exports.buildUrl = exports.makeApiCall = void 0;
7+
8+
var makeApiCall = function makeApiCall(service, apiKey, params) {
9+
var url = buildUrl(service, apiKey, params);
10+
var xmlHttp = new XMLHttpRequest();
11+
return new Promise(function (resolve, reject) {
12+
xmlHttp.onreadystatechange = function () {
13+
if (xmlHttp.readyState !== 4) {
14+
return;
15+
}
16+
17+
if (xmlHttp.status >= 200 && xmlHttp.status < 300) {
18+
resolve(JSON.parse(xmlHttp.responseText));
19+
} else {
20+
reject(xmlHttp);
21+
}
22+
};
23+
24+
xmlHttp.open('GET', url, true);
25+
xmlHttp.send();
26+
});
27+
};
28+
29+
exports.makeApiCall = makeApiCall;
30+
31+
var buildUrl = function buildUrl(service, apiKey, params) {
32+
if (!apiKey) {
33+
throw new Error('No api key is set.');
34+
}
35+
36+
var paramString = '';
37+
38+
if (typeof params === 'string') {
39+
paramString = "&".concat(params);
40+
} else if (Array.isArray(params)) {
41+
params.forEach(function (param) {
42+
paramString += "&".concat(param);
43+
});
44+
}
45+
46+
return "https://".concat(service, ".abstractapi.com/v1?api_key=").concat(apiKey).concat(paramString, "&lang=js");
47+
};
48+
49+
exports.buildUrl = buildUrl;

0 commit comments

Comments
 (0)