UNPKG

job-hoarder

Version:

Job board aggregator to pull in standardized job postings from company job pages

55 lines (54 loc) 1.98 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var parser_1 = __importDefault(require("./parser")); var axios_1 = __importDefault(require("axios")); var JazzScrape = /** @class */ (function () { function JazzScrape(params) { // Allow string paramater to resolve if (typeof params === 'string') { params = { companyId: params, }; } // Check for params if (!params || !params.companyId) throw new Error('Client must have a company Id'); this.companyId = params.companyId; this.enrich = params.enrich || false; this.parser = new parser_1.default(); } /** * Gets jobs from job board * @returns {array} List of jobs */ JazzScrape.prototype.getJobs = function (_a) { var _this = this; var _b = (_a === void 0 ? {} : _a).enrich, enrich = _b === void 0 ? this.enrich : _b; return axios_1.default .get("https://" + this.companyId + ".applytojob.com/apply") .then(function (res) { return res.data; }) .then(this.parser.parseJobs) .then(function (jobs) { if (enrich) { return Promise.all(jobs.map(function (j) { return _this.getJob(j.id); })); } return jobs; }); }; /** * Gets job details from job board * @param {string} id Id of job to retrieve * @returns {object} Job assigned to Id */ JazzScrape.prototype.getJob = function (id) { return axios_1.default .get("https://" + this.companyId + ".applytojob.com/apply/" + id) .then(function (res) { return res.data; }) .then(this.parser.parseJob); }; return JazzScrape; }()); exports.default = JazzScrape;