All Projects → lisniuse → Reqman

lisniuse / Reqman

Licence: mit
Reqman is a tool that can quickly help back-end engineers with api testing, as well as a nodejs-based crawler tool.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Reqman

Java Notes
📚 计算机科学基础知识、Java开发、后端/服务端、面试相关 📚 computer-science/Java-development/backend/interview
Stars: ✭ 1,284 (+943.9%)
Mutual labels:  backend
Back End Developer Interview Questions
📝 Interview for Back end Developer
Stars: ✭ 106 (-13.82%)
Mutual labels:  backend
Lastbackend
System for containerized apps management. From build to scaling.
Stars: ✭ 1,536 (+1148.78%)
Mutual labels:  backend
Dailyessay
Python|Golang|Linux (关于工作中写的一些各种各样的东西)
Stars: ✭ 90 (-26.83%)
Mutual labels:  backend
Gentelella
Welcome to Gentelella - Responsive Bootstrap Admin Application based on the Foundation of Symfony and Gentelella!
Stars: ✭ 100 (-18.7%)
Mutual labels:  backend
Nextjs Wordpress Starter
WebDevStudios Next.js WordPress Starter
Stars: ✭ 104 (-15.45%)
Mutual labels:  backend
Tinyhttp
🦄 0-legacy, tiny & fast web framework as a replacement of Express
Stars: ✭ 1,259 (+923.58%)
Mutual labels:  backend
Slides
it is a repository to store all slides used by Triton Ho's public presentation and course.
Stars: ✭ 1,782 (+1348.78%)
Mutual labels:  backend
Cakephp Realworld Example App
Stars: ✭ 103 (-16.26%)
Mutual labels:  backend
Vue2 Element
基于vue2 + vue-router2 + element-ui + vuex2 + fetch + webpack2 企业级后台管理系统最佳实践
Stars: ✭ 112 (-8.94%)
Mutual labels:  backend
Cake Slayer
🍰🔪 Architecture of Haskell backend applications
Stars: ✭ 92 (-25.2%)
Mutual labels:  backend
Hiera Http
HTTP backend for Hiera
Stars: ✭ 95 (-22.76%)
Mutual labels:  backend
Atlas.js
A component-based Node.js library to reduce boilerplate and provide sane project structure 🍻
Stars: ✭ 108 (-12.2%)
Mutual labels:  backend
Qa Best Practices
This is a summary of QA practices Futurice uses and recommends to be used.
Stars: ✭ 88 (-28.46%)
Mutual labels:  backend
Ext Solr
A TYPO3 extension that integrates the Apache Solr search server with TYPO3 CMS. dkd Internet Service GmbH is developing the extension. Community contributions are welcome. See CONTRIBUTING.md for details.
Stars: ✭ 118 (-4.07%)
Mutual labels:  backend
Poetryclub Backend
基于 laravel + vue.js 的诗词小筑网站后台页面与后端代码
Stars: ✭ 87 (-29.27%)
Mutual labels:  backend
Micro
Micro is a distributed cloud operating system
Stars: ✭ 10,778 (+8662.6%)
Mutual labels:  backend
1972
1972 - Criando APIs com NodeJs
Stars: ✭ 120 (-2.44%)
Mutual labels:  backend
Gobetween
☁️ Modern & minimalistic load balancer for the Сloud era
Stars: ✭ 1,631 (+1226.02%)
Mutual labels:  backend
Pragma
Build GraphQL APIs In No Time
Stars: ✭ 111 (-9.76%)
Mutual labels:  backend

English | 简体中文

Reqman

Reqman is a tool that can quickly help back-end engineers with api testing, as well as a nodejs-based crawler tool.

Financial Contributors on Open Collective NPM version

npm

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 8.0 or higher is required.

Installation is done using the npm install command:

$ npm install reqman

Importing

// Using Node.js `require()`
const Reqman = require('reqman');

// Using ES6 imports
import Reqman from 'reqman';

Features

  • ✔︎ Chained API
  • ✔︎ Out of the box
  • ✔︎ Crawler, can simulate requests
  • ✔︎ Suitable for complex and strong coupling scenarios
  • ✔︎ Powerful request library request based on nodejs

Super simple to use

Reqman is designed to be like request and is the easiest way to make http calls. It supports https, to follow redirection by default.

All you have to do is write an anonymous function in the parameters of the push method that returns a object and return your request parameters.

Example 1: a single request

Click here to view this example source code

//Importing Reqman, remember to capitalize the first letter because Reqman is a class.
const Reqman = require('reqman');

//new Reqman,and then the parameter is passed in a base address.
const req = new Reqman({
  baseUrl: "https://github.com"
});

//For example, you can use reqman to grab the github address of this project, like this:
req
  .push(function () {
    return {
      method: "GET",
      url: `/lisniuse/reqman`
    }
  })
  .done();

If you specify the showInfo parameter as false, the results will not be printed to the screen, like this:

req
  .push(function () {
    return {
      method: "GET",
      url: `/lisniuse/reqman`,
      showInfo: false
    }
  })
  .done();
  

Example 2: Chained API

In the chained API, the result of the first request is used as the argument to the second request. like this:

const Reqman = require('reqman');

const req = new Reqman({
  baseUrl: "http://127.0.0.1:3000"
});

//Define account password
const user = {
  username: "admin",
  password: "admin"
}

req
  //Request a login api
  .push(function () {
    return {
      method: "POST",
      url: `/api/login`,
      data: user, //Pass in the user object just defined to data
      complete: function (selfElement) { //Return the requestElement object of the queue
        let response = selfElement.result.response;
        let body = JSON.parse(response.body);
        //Note: It is recommended not to hang public variables directly on the reqman instance, which may override the requman properties and methods. Reqman provides a store object to store the public variables that need to be stored during the request process.
        this.store.userToken = body.data.token; //Get the user token
      }
    }
  })
  //Then we update the user's information with the token obtained after login.
  .push(function () {
    return {
      method: "POST",
      url: `/api/user/updateInfo`,
      headers: {
        'Authorization': this.store.userToken //The variables in the store can be directly used in subsequent requests.
      },
      data: {
        nickname: "jack ma" //Update nickname jack ma
      }
    }
  })
  .done()//just do it.

Example 3: Example of a complete representation of reqman's api and features

'use strict'

const req = new Reqman({
  baseUrl: "http://127.0.0.1:3000",
  output: "./request-result.txt", //Append the result returned after the request to the specified file path at the same time.
  specList: {
    type: 'valid', //Parameters: invalid or valid. Define valid or invalid requests.
    list: ['bob'] //Let the request named bob be valid and the rest of the requests invalid. If type is invalid, the opposite is true.
  }
});

req.
  //Define a request named bob, and the prevElement parameter represents the requestElement object of the previous request.
  push('bob', function (prevElement) {
    return {
      method: "POST",
      url: `/?name=bob`,
      headers: { //With custom headers
        'content-type': 'application/octet-stream'
      },
      complete: function (selfElement) { //Callback function after request

      }
    }
  })
  //Define a request named jack, and the prevElement parameter represents the requestElement object of the previous request.
  .push('jack', function (prevElement) {
    return {
      baseUrl: 'http://127.0.0.1:4000', //Customize the base address for this request
      output: "./jack-result.txt", //Customize the output file path for this request
      method: "GET",
      url: `/`,
      data: {
        name: 'jack'
      },
      showInfo: false, //Do not print the returned body information
      complete: function (selfElement) { //Callback function after request
        //do something...
      }
    }
  })
  .done(function () {
    //exit the program
    process.exit(1);
  })

More examples

More examples in the projects folder of the project, you can run this command directly:

node getHelloworld.js

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

License

The MIT License (MIT)

Copyright (c) 2015-present ZhiBing <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

back to top

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].