How to use requestExecutor method in wpt

Best JavaScript code snippet using wpt

store.ts

Source:store.ts Github

copy

Full Screen

...57 public async getAccessToken(code: string): Promise<IAccessToken> {58 const { client_id, client_secret } = process.env;59 const params = { client_id, client_secret, code };60 const url = `${this.baseAuthUrl}/login/oauth/access_token`;61 const accessToken: any = await requestExecutor('post', url, params, null);62 return accessToken as IAccessToken;63 }64 public async getUserInfo(accessToken: string): Promise<IUser> {65 const params = { access_token: accessToken };66 const url = `${this.baseAPIUrl}/user`;67 const user = await requestExecutor('get', url, params, null);68 return user as IUser;69 }70 public async getConfigBranches(accessToken: string): Promise<IBranch[]> {71 const { repoOwner, repoName } = config;72 const params = { access_token: accessToken };73 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/branches?per_page=1000`;74 const branches: IBranch[] = await requestExecutor('get', url, params, null);75 this._baseBranch = _.find(branches, { name: config.baseBranch });76 return branches as IBranch[];77 }78 public async getWorkflowBranches(accessToken: string): Promise<IBranch[]> {79 const { repoOwner, repoName } = config.workflowConfig;80 const params = { access_token: accessToken };81 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/branches?per_page=1000`;82 const branches: IBranch[] = await requestExecutor('get', url, params, null);83 this._baseBranch = _.find(branches, { name: config.baseBranch });84 return branches as IBranch[];85 }86 public async createBranch(accessToken: string, branchName: string, sha: string): Promise<IBranch> {87 const { repoOwner, repoName } = config;88 const params = { access_token: accessToken };89 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/git/refs`;90 const data = {91 ref: `refs/heads/${branchName}`,92 sha93 };94 const result: any = await requestExecutor('post', url, params, data);95 return result;96 }97 public async createWorkflowBranch(accessToken: string, branchName: string, sha: string): Promise<IBranch> {98 const { repoOwner, repoName } = config.workflowConfig;99 const params = { access_token: accessToken };100 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/git/refs`;101 const data = {102 ref: `refs/heads/${branchName}`,103 sha104 };105 const result: any = await requestExecutor('post', url, params, data);106 return result;107 }108 public async getConfigs(accessToken: string, branchName: string, perPage: number, page: number): Promise<IFile[]> {109 const { repoOwner, repoName, sourcePath } = config;110 const params = { access_token: accessToken, ref: branchName, page: page, per_page: perPage };111 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${sourcePath}`;112 const files = await requestExecutor('get', url, params, null);113 return files as IFile[];114 }115 public async getContent(accessToken: string, path: string, branchName: string): Promise<IFile> {116 const { repoOwner, repoName } = config;117 const params = { access_token: accessToken, ref: branchName };118 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${path}`;119 const file = await requestExecutor('get', url, params, null);120 return file as IFile;121 }122 public async getTables(accessToken: string, fileName: string, branch: string): Promise<IFile> {123 const { repoOwner, repoName, sourcePath } = config;124 const params = { access_token: accessToken, ref: branch };125 const path = `${sourcePath}/${fileName}`;126 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${path}`;127 const file = await requestExecutor('get', url, params, null);128 return file as IFile;129 }130 public async updateConfig(accessToken: string, path: string, branchName: string, contents: string, sha: string): Promise<any> {131 if (branchName === config.baseBranch) {132 return new Error('Can\'t write into master branch');133 }134 const { repoOwner, repoName } = config;135 const params = { access_token: accessToken };136 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${path}`;137 const data = {138 "message": `Updated ${path}`,139 "content": contents,140 "sha": sha,141 "branch": branchName142 };143 const result: any = await requestExecutor('put', url, params, data);144 return result;145 }146 public async getSourceLayout(accessToken: string, fileName: string, branchName: string): Promise<IFile> {147 const { repoOwner, repoName } = config;148 const path = `${config.sourceLayoutPath}/${fileName}`;149 const params = { access_token: accessToken, ref: branchName };150 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${path}`;151 const file = await requestExecutor('get', url, params, null);152 return file as IFile;153 }154 public async updateSourceLayout(accessToken: string, fileName: string, branchName: string, contents: string, sha: string): Promise<any> {155 if (branchName === config.baseBranch) {156 return new Error('Can\'t write into master branch');157 }158 const path = `${config.sourceLayoutPath}/${fileName}`;159 const { repoOwner, repoName } = config;160 const params = { access_token: accessToken };161 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${path}`;162 const data = {163 "message": `Updated ${path}`,164 "content": contents,165 "sha": sha,166 "branch": branchName167 };168 const result: any = await requestExecutor('put', url, params, data);169 return result;170 }171 public async createConfig(accessToken: string, fileName: string, branchName: string, contents: string): Promise<any> {172 if (branchName === config.baseBranch) {173 return new Error('Can\'t write into master branch');174 }175 const { repoOwner, repoName, sourcePath } = config;176 const path = `${sourcePath}/${fileName}`;177 const params = { access_token: accessToken };178 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${path}`;179 const data = {180 "message": `Created ${path}`,181 "content": contents,182 "branch": branchName183 };184 const result: any = await requestExecutor('put', url, params, data);185 return result;186 }187 public async createWorkflow(accessToken: string, branchName: string, contents: string, filePath: string): Promise<any> {188 if (branchName === config.workflowConfig.baseBranch) {189 return new Error('Can\'t write into master branch');190 }191 const { repoOwner, repoName } = config.workflowConfig;192 const sourcePath = config.workflowConfig.path;193 const path = `${sourcePath}/${filePath}`;194 const params = { access_token: accessToken };195 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${path}`;196 const data = {197 "message": `Created ${path}`,198 "content": contents,199 "branch": branchName200 };201 const result: any = await requestExecutor('put', url, params, data);202 return result;203 }204 public async getPullRequests(accessToken: string, state: string, sort: string, direction: string) {205 const { repoOwner, repoName, baseBranch } = config;206 const params = { access_token: accessToken, state, sort, direction };207 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/pulls`;208 const result: any = await requestExecutor('get', url, params, null);209 return result;210 }211 public async createPullRequest(accessToken: string, branchName: string) {212 if (branchName === config.baseBranch) {213 return new Error('Can\'t write into master branch');214 }215 const { repoOwner, repoName, baseBranch } = config;216 const params = { access_token: accessToken };217 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/pulls`;218 const data = {219 title: `PR for ${branchName}`,220 head: branchName,221 base: baseBranch222 };223 const result: any = await requestExecutor('post', url, params, data);224 return result;225 }226 public async updatePullRequest(accessToken: string, branchName: string, prId: string, state: string) {227 if (branchName === config.baseBranch) {228 return new Error('Can\'t write into master branch');229 }230 const { repoOwner, repoName, baseBranch } = config;231 const params = { access_token: accessToken };232 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/pulls/${prId}`;233 const data = {234 title: `PR for ${branchName}`,235 head: branchName,236 base: baseBranch,237 state238 };239 const result: any = await requestExecutor('patch', url, params, data);240 return result;241 }242 public getLoginUrl(host): string {243 const authUrl = config.authUrl;244 const { client_id } = process.env;245 const params = {246 client_id,247 redirect_uri: `${host}/${config.redirectUri}`,248 scope: config.scope,249 state: config.state,250 allow_signup: config.allowSignup251 };252 const query = Object.keys(params)253 .map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k]))254 .join('&');255 return `${authUrl}?${query}`;256 }257 public get baseBranchSha() {258 if (this._baseBranch) {259 return this._baseBranch.commit.sha;260 } else {261 return '';262 }263 }264 public async getTableColumns(accessToken: string, tableName) {265 const { repoOwner, repoName, columnsPath } = config.dbConfig;266 const params = { access_token: accessToken };267 const path = `${columnsPath}/${tableName.toUpperCase()}.sql`;268 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${path}`;269 const file = await requestExecutor('get', url, params, null);270 return file as IFile;271 }272 public async getDataPartners(accessToken: string) {273 const { repoOwner, repoName, dataPartnerPath } = config.dbConfig;274 const params = { access_token: accessToken };275 const tableStructurePath = `${dataPartnerPath}/tables/DATA_PARTNER.sql`;276 const tableContentPath = `${dataPartnerPath}/scripts/populate_partner.sql`;277 let result = '';278 // get table structure279 const structureUrl = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${tableStructurePath}`;280 const fileStructure: any = await requestExecutor('get', structureUrl, params, null);281 const file = fileStructure as IFile;282 result += Buffer.from(file.content, 'base64').toString();283 // get insert statements then parse them284 const dataUrl = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${tableContentPath}`;285 const fileContent: any = await requestExecutor('get', dataUrl, params, null);286 const data = fileContent as IFile;287 result += Buffer.from(data.content, 'base64').toString();288 // concat them and return for further processing289 return result;290 }291 public async getFeedTypes(accessToken: string) {292 const { repoOwner, repoName, feedTypePath } = config.dbConfig;293 const params = { access_token: accessToken };294 const tableStructurePath = `${feedTypePath}/tables/FEED_TYPE.sql`;295 const tableContentPath = `${feedTypePath}/scripts/populate_feed_type.sql`;296 let result = '';297 // get table structure298 const structureUrl = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${tableStructurePath}`;299 const fileStructure: any = await requestExecutor('get', structureUrl, params, null);300 const file = fileStructure as IFile;301 result += Buffer.from(file.content, 'base64').toString();302 // get insert statements then parse them303 const dataUrl = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${tableContentPath}`;304 const fileContent: any = await requestExecutor('get', dataUrl, params, null);305 const data = fileContent as IFile;306 result += Buffer.from(data.content, 'base64').toString();307 // concat them and return for further processing308 return result;309 }310 public async getAllTables(accessToken: string) {311 const { repoOwner, repoName, columnsPath } = config.dbConfig;312 const params = { access_token: accessToken };313 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${columnsPath}`;314 const files = await requestExecutor('get', url, params, null);315 return files as IFile[];316 }317 public async getBusinessRules(accessToken: string): Promise<IFile> {318 const { repoOwner, repoName, basebranch, path } = config.businessRuleConfig;319 const params = { access_token: accessToken, ref: basebranch };320 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${path}`;321 const file = await requestExecutor('get', url, params, null);322 return file as IFile;323 }324 public async getWorkflows(accessToken: string, sha: string): Promise<IFile[]> {325 const { repoOwner, repoName, path } = config.workflowConfig;326 const params = { access_token: accessToken, recursive: 1, path: path };327 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/git/trees/${sha}`;328 const files = await requestExecutor('get', url, params, null);329 // filter workflow files from the tree330 const workflows = _.filter(files.tree || [], file => (file.type === 'blob' && _.includes(file.path, path)));331 // format it by adding data partner, feed type, name332 _.forEach(workflows, workflow => {333 const relativePath = workflow.path.replace(path, '');334 const fileRegex = /(\w+)\/(\w+)\/(.*\.sql)$/;335 const fileInfo = relativePath.match(fileRegex);336 if (fileInfo) {337 workflow.dataPartner = fileInfo[1];338 workflow.feedType = fileInfo[2];339 workflow.name = fileInfo[3];340 }341 });342 return workflows as IFile[];343 }344 public async getWorkflow(accessToken: string, branch: string, path: string): Promise<IFile[]> {345 const { repoOwner, repoName } = config.workflowConfig;346 const params = { access_token: accessToken, ref: branch };347 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${path}`;348 const files = await requestExecutor('get', url, params, null);349 return files as IFile[];350 }351 public async updateWorkflow(accessToken: string, path: string, branchName: string, contents: string, sha: string): Promise<any> {352 if (branchName === config.workflowConfig.baseBranch) {353 return new Error('Can\'t write into master branch');354 }355 const { repoOwner, repoName } = config.workflowConfig;356 const params = { access_token: accessToken };357 const url = `${this.baseAPIUrl}/repos/${repoOwner}/${repoName}/contents/${path}`;358 const data = {359 "message": `Updated ${path}`,360 "content": contents,361 "sha": sha,362 "branch": branchName363 };364 const result: any = await requestExecutor('put', url, params, data);365 return result;366 }367 public async executeConfig(fileName: string): Promise<any> {368 const { userName, host, configDirectory } = config.clusterConfig;369 const { privateKeyPath } = process.env;370 return new Promise((resolve, reject) => {371 try {372 this.logger.info("\n");373 this.logger.info(JSON.stringify({ type: 'start execute config in cluster', file: fileName, host, userName, at: (new Date()).toUTCString() }));374 const ssh = new node_ssh();375 const command = `spark-submit /etc/pegasus/acp-ExTra/acp_extra/application.py --config-directory ${configDirectory} --workflow_run_id 11111 --config_file ${fileName}`;376 ssh.connect({377 host,378 username: userName,...

Full Screen

Full Screen

request-executor.js

Source:request-executor.js Github

copy

Full Screen

1'use strict';2angular.module('fs')3 .value('requestQueue', [])4 /* Request Executor */5 .factory('requestExecutor', function (safeApply, requestQueue, $http) {6 var requestExecutor = {};7 requestExecutor.add = function add (request) {8 requestQueue.push(request);9 };10 requestExecutor.process = function proccessRequest() {11 var request;12 if (requestQueue.length === 0) {13 return;14 }15 request = requestQueue.pop();16 safeApply(null, function () {17 $http({18 method: request.method,19 data: request.data,20 url: [request.host, request.path].join('/'),21 withCredentials: true22 }).success(function (data, status, headers, config) {23 var result = request.success(data, status, headers, config);24 requestExecutor.process();25 return result;26 })27 .error(function () {28 var result = request.error();29 requestExecutor.process();30 return result;31 });32 });33 };34 return requestExecutor;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5wpt.runTest(options, function(err, data) {6 if (err) return console.log(err);7 wpt.getTestResults(data.data.testId, function(err, data) {8 if (err) return console.log(err);9 console.log(data);10 });11});12var wpt = require('webpagetest');13var wpt = new WebPageTest('www.webpagetest.org');14var options = {15};16wpt.runTest(options, function(err, data) {17 if (err) return console.log(err);18 wpt.getTestResults(data.data.testId, function(err, data) {19 if (err) return console.log(err);20 console.log(data);21 });22});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var requestExecutor = wpt.requestExecutor('www.webpagetest.org');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9### requestExecutor(url, [options], [callback])10* `options` - Options to pass to the request. See [request](

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var requestExecutor = wpt.requestExecutor;3var options = {4}5requestExecutor(options, function (error, response, body) {6 console.log(body);7});8This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptdriver = require('wptdriver');2var requestExecutor = wptdriver.requestExecutor;3var method = 'GET';4var data = '';5var headers = '';6var callback = function(status, response){7 console.log(response);8};9requestExecutor(url, method, data, headers, callback);10For more details on how to use wptdriver, please refer to the [wptdriver wiki](

Full Screen

Using AI Code Generation

copy

Full Screen

1var requestExecutor = require('request-executor');2var wpt = require('webpagetest');3var url = require('url');4var wpt = new WebPageTest('www.webpagetest.org', 'A.2a2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f');5wpt.runTest(testUrl, function(err, data) {6 if (err) return console.error(err);7 console.log(data);8});9var requestExecutor = require('request-executor');10var wpt = require('webpagetest');11var url = require('url');12var wpt = new WebPageTest('www.webpagetest.org', 'A.2a2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f');13wpt.runTest(testUrl, function(err, data) {14 if (err) return console.error(err);15 console.log(data);16});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful