1.1.2 • Published 8 years ago

test-rest v1.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

test-rest

Build Status

A lightweight and simple to user REST API testing server. You can even unleash it as a development backend to get rid of those annoying mock backends.

Built upon the excellent Hapi framework.

Installation

Simply install the latest version via npm npm install test-rest.

To install the latest development version you can install it directly from git via npm npm install git+ssh://git@github.com:ptMuta/test-rest.git#master (See npm docs for more information)

Configuration

The only required configuration for the server is the specification file for the server endpoints.

Usage

You can either import the test-server module with require('test-rest') or install the module globally and use the command line interface to run the server using test-server [-c HAPI_CONFIG] server_config

You can also check the cli help -h and version -v

Example Configuration

The following configuration implements all the features currently available. If you don't need the custom handler functions you can pass in a plain json object as well.

export default {
	"identifierKey": "id",
	"routes": [
		{
			"path": "projects",
			"methods": [
				"GET_ALL",
				"GET_BY_KEY",
				"POST",
				"PUT",
				"DELETE"
			],
			"state": [
				{"id": 1, "name": "MasterProject1"}
			],
			"nested": [
				{
					"path": "tasks",
					"methods": [
						"GET_ALL",
						"GET_BY_KEY",
						"POST",
						"PUT",
						"DELETE",
						(path, state) => {
							return {
								path: `${path}/meta`,
								method: 'GET',
								handler: (request, reply) => reply({type: 'metaResponse', state})
							}
						}
					],
					"state": [
						{"id": 1, "name": "MasterProject2"}
					]
				}
			]
		}
	]
};

Documentation

See GitHub Pages.

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago