@donniekim/rest-client
Advanced tools
Comparing version 1.0.0 to 1.0.2
79
index.js
@@ -1,4 +0,75 @@ | ||
module.exports = { | ||
company: 'Matrix Jobs', | ||
project: 'Rest API Client' | ||
}; | ||
const axios = require('axios') | ||
function RestClient(config) { | ||
this.config = config || {} | ||
if (!this.config.baseURL) { | ||
this.config.baseURL = 'https://api.justjobs.io' | ||
} | ||
if (!this.config.domain) { | ||
this.config.domain = process.env.DOMAIN || 'https://careerfactory.net' | ||
} | ||
this.client = axios.create({ | ||
baseURL: this.config.baseURL | ||
}) | ||
} | ||
RestClient.prototype.setConfig = function(config, replace = false) { | ||
if (replace) { | ||
this.config = config | ||
} else { | ||
Object.assign(this.config, config) | ||
} | ||
this.client = axios.create({ | ||
baseURL: this.config.baseURL || "https://api.justjobs.io" | ||
}) | ||
} | ||
RestClient.prototype.search = function(payload) { | ||
const params = { | ||
limit: 20, | ||
q: '', | ||
l: '', | ||
page: 1, | ||
placement: 'job_board', | ||
site: this.config.domain, | ||
co: 'us', | ||
distance: 30 | ||
} | ||
Object.assign(params, payload) | ||
if (payload.category) { | ||
params.c0 = payload.category | ||
} | ||
let query = querystring.stringify(params) | ||
let url = `/api/es_search?${query}` | ||
return this.client.get(url).then(resp => resp.data) | ||
} | ||
RestClient.prototype.locationSearch = function(country, term, size) { | ||
let url = `/api/suggestions/location?co=${country}&term=${term}&size=${size}` | ||
return this.client.get(url).then(resp => resp.data) | ||
} | ||
RestClient.prototype.ipLookup = function(ip) { | ||
let url = `/api/ip-lookup?ip=${ip}` | ||
return this.client.get(url).then(resp => resp.data) | ||
} | ||
RestClient.prototype.getChain = function(location, trackInfo) { | ||
let params = Object.assign(trackInfo, { | ||
l: location, | ||
chain_name: "dynamic_cf", | ||
site: process.env.DOMAIN | ||
}) | ||
let query = querystring.stringify(trackInfo) | ||
let url = `/api/chain?${query}` | ||
return this.client.get(url).then(resp => resp.data) | ||
} | ||
RestClient.prototype.trackImpression = function(payload) { | ||
let url = `/api/impression` | ||
return this.client.post(url, payload).then(resp => resp.data) | ||
} | ||
module.exports = RestClient; |
{ | ||
"name": "@donniekim/rest-client", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"description": "Rest Client for MatrixJobs API", | ||
@@ -19,7 +19,10 @@ "main": "index.js", | ||
"author": "Donnie Kim", | ||
"license": "ISC", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://gitlab.com/matrix-media/jobs-search-engine-js-client/issues" | ||
}, | ||
"homepage": "https://gitlab.com/matrix-media/jobs-search-engine-js-client#readme" | ||
"homepage": "https://gitlab.com/matrix-media/jobs-search-engine-js-client#readme", | ||
"dependencies": { | ||
"axios": "^0.19.0" | ||
} | ||
} |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2630
64
0
1
2
+ Addedaxios@^0.19.0
+ Addedaxios@0.19.2(transitive)
+ Addedfollow-redirects@1.5.10(transitive)