0.0.20 • Published 1 year ago

fe-dev-server-plugin-capture v0.0.20

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

fe-dev-server-plugin-capture

Capture plugin: capture JSON API response in files, data will be differentiated with pathname, method, search, requestBody

Capture reply plugin: reply request using captured files

fe-dev-server-plugin-capture

Usage

Capture JSON API response from other plugins, normally with proxy plugin.

Config

dir

string - the location of captured files

replyBy

RegExp / function - capture response only from some plugin

needCaptureFn

function - capture response with conditions, you can get responseBody and statusCode in function params

defaultConfig

object - default config for every request

defaultConfig.maxCache: number, Default: 0 - the maximum captured files in same pathname and method

defaultConfig.ignoreSearch: string[] - the fields to be ignored in search when calculate if the request is differentiated with others

defaultConfig.ignoreBody: string[] - the fields to be ignored in requestBody when calculate if the request is differentiated with others

eachAPIConfig

object - config for specify request, the key formats like ${pathname}/${method}, and value is the config object

eachAPIConfig.maxCache: the same as defaultConfig.maxCache

eachAPIConfig.ignoreSearch: the same as defaultConfig.ignoreSearch

eachAPIConfig.ignoreBody: the same as defaultConfig.ignoreBody

Dynamic params in route is supported, for examples:

({
	eachAPIConfig: {
		'/api/login': {
			maxCache: 1,
		},
		// /api/users/1 or /api/users/2 will using this config
		'/api/users/{id}': {
			maxCache: 10,
		},
	}
})

fe-dev-server-plugin-capture-reply

Usage

When you got captured files already, using these files to reply directly instead of from remote server. Normally, the ignoreSearch and ignoreBody should be equal to capture plugin, otherwise the calculation for same request judgement will be mismatched.

Config

dir

string - the location of captured files

defaultConfig

object - default config for every request

defaultConfig.delay: number, Default: 0 - response delay in milliseconds

defaultConfig.delayOffset: number, Default: 0 - the maximum delay time offset in milliseconds

defaultConfig.ignoreSearch: string[] - the fields to be ignored in search when calculate if the request is differentiated with others

defaultConfig.ignoreBody: string[] - the fields to be ignored in requestBody when calculate if the request is differentiated with others

defaultConfig.usingLatestAsDefault: boolean, Default: false - if the calculation of specify captured file not found, reply with the latest captured file or just skip to next plugin

eachAPIConfig

object - config for specify request, the key formats like ${pathname}/${method}, and value is the config object

eachAPIConfig.delay - the same as defaultConfig.delay

eachAPIConfig.delayOffset - the same as defaultConfig.delayOffset

eachAPIConfig.ignoreSearch - the same as defaultConfig.ignoreSearch

eachAPIConfig.ignoreBody - the same as defaultConfig.ignoreBody

eachAPIConfig.usingLatestAsDefault - the same as defaultConfig.usingLatestAsDefault

0.0.20

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.16

1 year ago

0.0.17

1 year ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.15

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago