Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

proxycrawl

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxycrawl - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

.commitlintrc.json

3

.eslintrc.js

@@ -6,3 +6,3 @@ module.exports = {

},
extends: 'eslint:recommended',
extends: ['eslint:recommended', 'prettier'],
parserOptions: {

@@ -16,3 +16,2 @@ ecmaVersion: 8,

'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
semi: ['error', 'always'],

@@ -19,0 +18,0 @@ },

{
"name": "proxycrawl",
"version": "2.2.0",
"version": "2.3.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node test.js"
"test": "node test.js",
"tsc": "rm -f index.d.ts && rm -f src/*.d.ts && tsc --allowJs -d --emitDeclarationOnly index.js"
},

@@ -32,3 +33,18 @@ "repository": {

"homepage": "https://github.com/proxycrawl/proxycrawl-node",
"dependencies": {}
"dependencies": {},
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"eslint": "^7.18.0",
"eslint-config-prettier": "^7.2.0",
"husky": "^4.3.8",
"prettier": "^2.2.1",
"typescript": "^4.1.3"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"types": "./index.d.ts"
}

@@ -7,2 +7,6 @@ const https = require('https');

/**
* The API base url.
* @constant
*/
const _APIURL_ = 'https://api.proxycrawl.com/';

@@ -17,2 +21,7 @@

class BaseAPI {
/**
* Returns the base path to use on the API calls. This is used internally in the class.
* @type string
* @private
*/
get basePath() {

@@ -22,2 +31,8 @@ return '';

/**
* The encoding use to decode the API responses. This is used internally in the class.
* @type string
* @default utf8
* @private
*/
get responseEncoding() {

@@ -27,4 +42,10 @@ return 'utf8';

constructor(options = {}) {
if (undefined === options.token || '' === options.token) {
/**
* Creates a BaseAPI object. This class is not meant to be used directly but extended from subclasses.
* @param {object} options The options to initialize the API.
* @param {string} options.token The token to use in the API.
* @param {number} [options.timeout=30000] The API timeout in milliseconds.
*/
constructor(options) {
if (undefined === options || undefined === options.token || '' === options.token) {
throw new Error('Token is required to use the API, please pass token option');

@@ -37,2 +58,8 @@ }

/**
* Makes a request to ProxyCrawl API.
* @param {string} path Path from the API to load.
* @param {object} [options={}] Additional options for the request.
* @returns {Promise}
*/
request(path, options = {}) {

@@ -68,2 +95,8 @@ const url = this.buildURL(path, options);

/**
* Decompresses and processes the response from the API.
* @param {object} response The HTTP response object.
* @returns {Promise}
* @private
*/
processResponse(response) {

@@ -109,2 +142,8 @@ response.headers = lowerHeaders(response.headers);

/**
* Builds the url to call the API.
* @param {string} path Path of the API to call.
* @param {object} options Additional parameters to pass.
* @returns {URL}
*/
buildURL(path, options) {

@@ -111,0 +150,0 @@ let url = _APIURL_ + path + '?token=' + this.options.token;

@@ -0,1 +1,5 @@

/**
* Nothing to see here.
* Config used for tests and to easily change defaults.
*/
const config = {

@@ -2,0 +6,0 @@ defaults: {

@@ -13,2 +13,8 @@ const querystring = require('querystring');

class CrawlingAPI extends BaseAPI {
/**
* Makes a GET request to the Crawling API.
* @param {string} url The url to load.
* @param {object} [options={}] Any of the available Crawling API parameters.
* @returns {Promise}
*/
get(url, options = {}) {

@@ -19,2 +25,10 @@ options.url = url;

/**
* Makes a POST request to the Crawling API.
* @param {string} url The url to load.
* @param {(object|string)} data The data that you want to send via POST.
* @param {object} [options={}] Any of the available Crawling API parameters.
* @param {string} [options.postType] If 'json', the data will be sent as JSON
* @returns {Promise}
*/
post(url, data, options = {}) {

@@ -33,2 +47,10 @@ options.url = url;

/**
* Makes a PUT request to the Crawling API.
* @param {string} url The url to load.
* @param {(object|string)} data The data that you want to send via POST.
* @param {object} [options={}] Any of the available Crawling API parameters.
* @param {string} [options.postType] If 'json', the data will be sent as JSON
* @returns {Promise}
*/
put(url, data, options = {}) {

@@ -40,2 +62,8 @@ options.url = url;

/**
* Processes the response from BaseAPI and parses some fields for easy access.
* @param {object} response The response object
* @returns {Promise}
* @private
*/
processResponse(response) {

@@ -42,0 +70,0 @@ return super.processResponse(response).then((response) => {

@@ -12,2 +12,8 @@ const BaseAPI = require('./base-api.js');

class LeadsAPI extends BaseAPI {
/**
* Get leads from a specific domain.
* @param {string} domain The domain to find leads from.
* @param {object} [options={}] Additional parameters to pass to the API.
* @returns {Promise}
*/
getFromDomain(domain, options = {}) {

@@ -18,2 +24,8 @@ options.domain = domain;

/**
* Processes the response from BaseAPI and parses some fields for easy access.
* @param {object} response The response object
* @returns {Promise}
* @private
*/
processResponse(response) {

@@ -20,0 +32,0 @@ return super.processResponse(response).then((response) => {

@@ -12,2 +12,7 @@ const CrawlingAPI = require('./crawling-api.js');

class ScraperAPI extends CrawlingAPI {
/**
* Returns the base path to use on the API calls. This is used internally in the class.
* @type string
* @private
*/
get basePath() {

@@ -17,2 +22,6 @@ return 'scraper';

/**
* POST is not allowed.
* @throws {Error}
*/
post() {

@@ -22,2 +31,6 @@ throw Error('Only GET is allowed for the ScraperAPI');

/**
* PUT is not allowed.
* @throws {Error}
*/
put() {

@@ -24,0 +37,0 @@ throw Error('Only GET is allowed for the ScraperAPI');

@@ -12,2 +12,7 @@ const BaseAPI = require('./base-api.js');

class ScreenshotsAPI extends BaseAPI {
/**
* Returns the base path to use on the API calls. This is used internally in the class.
* @type string
* @private
*/
get basePath() {

@@ -17,2 +22,8 @@ return 'screenshots';

/**
* The encoding use to decode the API responses. This is used internally in the class.
* @type string
* @default utf8
* @private
*/
get responseEncoding() {

@@ -22,2 +33,8 @@ return 'binary';

/**
* Gets a screenshot from the ProxyCrawl Screenshots API.
* @param {string} url URL from the website to take a screenshot.
* @param {object} options Any additional parameters you would like to send to the API.
* @returns {Promise}
*/
get(url, options = {}) {

@@ -24,0 +41,0 @@ options.url = url;

@@ -0,1 +1,11 @@

/**
* Contains a set of generic functions used in different places.
* @module utils
*/
/**
* Turns a text into snake case.
* @param {string} text The text to convert.
* @returns {string} The text converted.
*/
function snakeCase(text) {

@@ -5,2 +15,7 @@ return text.replace(/[A-Z]/g, (match) => '_' + match.toLowerCase());

/**
* Converts an object of headers to lower case.
* @param {object} headers The headers to convert.
* @returns {object} The converted object.
*/
function lowerHeaders(headers) {

@@ -7,0 +22,0 @@ const result = {};

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc