All Projects → Aconex → Drakov

Aconex / Drakov

Licence: mit
Mock Server that implements the API Blueprint specification

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Drakov

justreq
A caching proxy server for testing interface of HTTP or HTTPS. A never offline testing interface server. A mock server
Stars: ✭ 15 (-96.79%)
Mutual labels:  mock-server
Vue Fullstack
vue fullstack template
Stars: ✭ 297 (-36.4%)
Mutual labels:  mock-server
Dredd
Language-agnostic HTTP API Testing Tool
Stars: ✭ 3,770 (+707.28%)
Mutual labels:  api-blueprint
mockserver-node
Node.js module and grunt plugin to start and stop MockServer and MockServer Proxy
Stars: ✭ 34 (-92.72%)
Mutual labels:  mock-server
Mockman
Manage and start the mock servers on your local platform easily
Stars: ✭ 281 (-39.83%)
Mutual labels:  mock-server
Mockserver
MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and…
Stars: ✭ 3,479 (+644.97%)
Mutual labels:  mock-server
wiremock-junit5
Wiremock extension to inject server into JUnit5 tests
Stars: ✭ 43 (-90.79%)
Mutual labels:  mock-server
Smocker
Smocker is a simple and efficient HTTP mock server and proxy.
Stars: ✭ 465 (-0.43%)
Mutual labels:  mock-server
Drafter
API Blueprint Parser (C++)
Stars: ✭ 286 (-38.76%)
Mutual labels:  api-blueprint
Mockttp
Powerful friendly HTTP mock server & proxy
Stars: ✭ 346 (-25.91%)
Mutual labels:  mock-server
mokker
The mock does not mock you. The video: https://www.youtube.com/watch?v=gGLNJpC-Ov0
Stars: ✭ 13 (-97.22%)
Mutual labels:  mock-server
Chn Eolinker Ams Lite 4.0 For Java
中国最大的API接口管理平台,3.x开源发行版,支持多国语言[英语、简体中文、繁体中文]
Stars: ✭ 275 (-41.11%)
Mutual labels:  mock-server
Mockserver
Mockserver is a mock data tools and switch between mock data and real data,【一个用于前后分离时模拟数据的web系统,并可在直实数据与实际数据中自由切换】
Stars: ✭ 332 (-28.91%)
Mutual labels:  mock-server
speakeasy
A tool for creating Go web servers which can be embedded in iOS and Android apps.
Stars: ✭ 27 (-94.22%)
Mutual labels:  mock-server
Mocker Api
mocker-api that creates mocks for REST APIs. It will be helpful when you try to test your application without the actual REST API server.
Stars: ✭ 374 (-19.91%)
Mutual labels:  mock-server
vuetibook
Integrating Vue.js, Vuetify and Storybook
Stars: ✭ 16 (-96.57%)
Mutual labels:  mock-server
Stubby4j
An HTTP stub server for testing application interactions with web services (REST, etc) & external system stubbing for easy testing
Stars: ✭ 300 (-35.76%)
Mutual labels:  mock-server
Wiremock
A tool for mocking HTTP services
Stars: ✭ 4,790 (+925.7%)
Mutual labels:  mock-server
Wiremock.net
WireMock.Net is a flexible library for stubbing and mocking web HTTP responses using request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality.
Stars: ✭ 408 (-12.63%)
Mutual labels:  mock-server
Protagonist
Protagonist is Node.js wrapper for the API Blueprint parser
Stars: ✭ 343 (-26.55%)
Mutual labels:  api-blueprint

Drakov API Blueprint Mock Server

Gitter

npm version Build Status

Drakov

Mock server that implements the API Blueprint specification:

Community

We have setup a google group to assist with the answering of questions any users of Drakov may have.

It can be found at https://groups.google.com/forum/?hl=en#!forum/drakov-api-server

Notes on the Node.js compatibility

Since version 1.0.2, a version of the Drafter package is being used, which attempts to install the version with C bindings (faster), but falls back if compilation of this package fails to Drafter.js.

MSON Support via Attribute elements

Since version 0.1.12 MSON support is now provided.

Logging to assist with debugging request matching

Drakov provide some logging in the following situations:

  • When request's path does not match any documented endpoints
  • When request's headers does not match headers schema
  • When request's body does not match body schema (corresponding to request's content-type)

Debug Mode

When flag --debugMode is set on Drakov's start up all mismatching requests will be dumped on logs. Also Drakov will send a detail payload within the 404 response.

Installation instructions

npm install -g drakov

Running

drakov -f <glob expression to your md files> -s <comma delimited list of static file paths> -p <server port>

Argument Notes:

  • Glob expression is required
  • If a list of static file paths are provided, then Drakov will proxy the static files
  • Server port is optional and defaults to 3000
  • CORS headers are sent by default, you need to use the --disableCORS switch/property

Running with configuration file

drakov --config config.js

Important

This mode of operation will load your configuration from a Javascript file that must export an object of arguments as supported in the arguments module.

All command line arguments aside from --config will be ignored, and the defaults will be merged in.

Running with .drakovrc configuration file

drakov

Similar to utilities such as JSHint, drakov will look for a .drakovrc file in the current path where drakov is executed and walk up the path until / is reached.

The .drakovrc file should be a valid Node.js module that exports a valid Drakov configuration object such as would be used with the --config switch.

API discovery

drakov -f <glob expression to your md files> --discover

Enables the /drakov endpoint, which lists all the available endpoints currently being served by Drakov

Examples with command line arguments

With only a glob expression

drakov -f "../com/foo/contracts/*.md"

With glob expression and single static path

drakov -f "../com/foo/contracts/*.md" -s "../path/to/static/files"

With glob expression and multiple static paths (must be comma delimited with no spaces)

drakov -f "../com/foo/contracts/*.md" -s "../path/to/static/files" -s "../second/path/to/static/files"

With glob expression and static path that has a specific mount point

drakov -f "../com/foo/contracts/*.md" -s "../path/to/static/files=/www/path"

With glob expression and static path that has a specific mount point with different path mount delimiter

drakov -f "../com/foo/contracts/*.md" -s "../path/to/static/files:/www/path" -d ":"

With glob expression and specified server port

drakov -f "../com/foo/contracts/*.md" -p 4007

When running drakov and binding to a public IP

drakov -f "../com/foo/contracts/*.md" --public

Reload Drakov when loaded specification files change

You can tell Drakov to watch for changes in the spec files that are loaded. When changes are detected, Drakov will reload.

drakov -f "../com/foo/contracts/*.md" --watch

CORS Header

By default a CORS header is sent, you can disable it with the --disableCORS switch.

drakov -f "../com/foo/contracts/*.md" --disableCORS

Automatic response to OPTIONS requests

When you run server for testing API on different port than your app it's handy to allow cross origin resource sharing (CORS). For this to work you need also to listen on every route for OPTIONS requests.

drakov -f "../com/foo/contracts/*.md" --autoOptions

Run on Public Interface

By default Drakov only binds to localhost, to run on all public IP interfaces use the --public switch.

drakov -f "../com/foo/contracts/*.md" --public

SSL Support

To enable SSL you must provide both key and certificate. Use parameters --sslKeyFile and --sslCrtFile to specify the path to your key and certificate files. Once SSL is enabled Drakov will only respond to HTTPS requests.

drakov -f "../com/foo/contracts/*.md" --sslKeyFile="./ssl/server.key" --sslCrtFile="./ssl/server.crt"

Stealth Mode

In some cases you may wish to suppress the logging output of Drakov. To do so, run is with the --stealthmode options.

drakov -f "../com/foo/contracts/*.md" --stealthmode

Response Delay

In some case you may want to force Drakov to delay sending a response. To do this simple use the --delay argument followed by a number (ms).

drakov -f "../com/foo/contracts/*.md" --delay 2000

Allow Methods Header

For HTTP methods such as DELETE, you may want Drakov to return them in the appropriate methods allow header. You can do this using the --method argument

drakov -f "../com/foo/contracts/*.md" --method DELETE

drakov -f "../com/foo/contracts/*.md" --method DELETE --method OPTIONS

Allow Headers Header

For HTTP headers such as Authorization, you may want Drakov to return them in the appropriate methods allow header. You can do this using the --header argument

drakov -f "../com/foo/contracts/*.md" --header Authorization

drakov -f "../com/foo/contracts/*.md" --header Authorization --header X-Csrf-Token

Drakov includes many headers by default: Origin, X-Requested-With, Content-Type, Accept when CORS is enabled.

Ignore Headers

In cases where strict HTTP headers matching against API blueprints is not necessary, you can use the --ignoreHeader argument:

drakov -f "../com/foo/contracts/*.md" --ignoreHeader Cookie --ignoreHeader Authorization

Using as a Node.js module

var drakov = require('drakov');

var argv = {
    sourceFiles: 'path/to/files/**.md',
    serverPort: 3000,
    staticPaths: [
        '/path/to/static/files',
        '/another/path/to/static/files',
        '/path/to/more/files=/mount/it/here'
    ],
    stealthmode: true,
    disableCORS: true,
    sslKeyFile: '/path/to/ssl/key.key',
    sslCrtFile: '/path/to/ssl/cert.crt',
    delay: 2000,
    method: ['DELETE','OPTIONS']
};

drakov.run(argv, function(){
    // started Drakov
    drakov.stop(function() {
        // stopped Drakov
    });
});

Using as an Express middleware

Due to protagonist parsing being async, we need to setup the middleware with an init function

var drakovMiddleware = require('drakov').middleware;

var argv = {
    sourceFiles: 'path/to/files/**.md',
    serverPort: 3000,
    staticPaths: [
        '/path/to/static/files',
        '/another/path/to/static/files',
        '/path/to/more/files=/mount/it/here'
    ],
    stealthmode: true,
    disableCORS: true,
    sslKeyFile: '/path/to/ssl/key.key',
    sslCrtFile: '/path/to/ssl/cert.crt',
    delay: 2000,
    method: ['DELETE','OPTIONS']
};

var app = express();
drakovMiddleware.init(app, argv, function(err, middlewareFunction) {
    if (err) {
        throw err;
    }
    app.use(middlewareFunction);
    app.listen(argv.serverPort);
});

FAQ

Q: If I have multiple requests/responses on the same API endpoint, which response will I get?

A: Drakov will respond first with any responses that have a JSON schema with the first response matching the request body for that API endpoint. You can request a specific response by adding a Prefer header to the request in the form Prefer:status=XXX where XXX is the status code of the desired response. See issue #88 for details.

Q: If I have multiple responses on a single request, which response will I get?

A: Drakov will respond with the first response.

Q: Drakov is too loud (outputting too much logging), can I turn off request and API responses?

A: You can suppress all but the startup output of Drakov with --stealthmode.

CONTRIBUTING

Pull requests with patches for fixes and enhancements are very welcome. We have a few requirements that will help us to quickly assess your contributions.

If you have any ideas or questions you are welcome to post an issue.

Code conventions

  • Setup your editor to use the .editorconfig and .jshintrc files included in the project
  • We use 4 spaces for tabs
  • Most of the style issues should be resolve as long as you run npm test and run against the jshinting rules
  • We prefer readability over compact code

Logging in your code

  • Include the lib/logger module and use logger.log(), this allows your logging be properly disabled in Drakov's stealth mode
  • Always have a type qualifier in square brackets in from of your message in white, logger.log('[TYPE]'.white, 'Something is happening');`
  • We don't have any guidelines for how to log, except that you should have your type a different colour from your actual message (better logging is in our roadmap)

Functionality that adds CLI arguments

  • Make sure you add the new argument property to the yargsConfigOptions object in the arguments module

Middleware functionality

  • For functionality that does something with the request object add code to the request module
  • For functionality that does something with the response object add code to the response module

Testing

  • If your contribution deals with API Blueprint request/response behaviour add an example into an existing or new markdown file in the test/example/md directory
  • Always add a test in test/api for request/response behaviour tests, or test/unit if it is a unit test
  • All test specification files must end in -test.js
  • Always run npm test before you submit your build request

CHANGELOG

A history of changes with a list of contributors can be found at https://github.com/Aconex/drakov/blob/master/CHANGELOG.md

MAINTAINERS

Yakov Khalinsky [email protected]

Marcelo Garcia de Oliveira [email protected]

Drakov Logo

Huge thanks to Eva Mansk for the funky logo!

You are welcome to use the Drakov logo as long it is to refer to this project and you provide acknowledgement and a link back to our project.

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].