Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

osprey-mock-service

Package Overview
Dependencies
Maintainers
3
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

osprey-mock-service

Generate an API mock service from a RAML definition using Osprey

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-44.44%
Maintainers
3
Weekly downloads
 
Created
Source

Osprey Mock Service

NPM version NPM downloads Build status Test coverage Greenkeeper badge

Generate an API mock service from a RAML definition using Osprey.

Usage

Global (CLI)

npm install -g osprey-mock-service

Start the service from the CLI. This will automatically use the baseUri as the path to the mock service. For example, http://example.com/api will result in http://localhost:{PORT}/api.

osprey-mock-service -f api.raml -p 3000 --cors

Options

  • -f Path to the root RAML definition (E.g. /path/to/api.raml)
  • -p Port number to bind the server locally
  • --cors Enable CORS with the API

Locally (JavaScript)

npm install osprey-mock-service --save

The mocking service simply accepts a RAML definition and returns a router that can be mounted into any Connect-style middleware layer or even used with http. Best used with osprey to support incoming validation automatically.

const ospreyMockService = require('osprey-mock-service')
const express = require('express')
const wap = require('webapi-parser').WebApiParser
const path = require('path')
const osprey = require('osprey')

async function main () {
  const app = express()
  const fpath = `file://${path.join(__dirname, 'api.raml')}`
  let model = await wap.raml10.parse(fpath)
  model = await wap.raml10.resolve(model)

  app.use(osprey.server(model))
  app.use(ospreyMockService(model))
  app.listen(3000)
}

main()

Additional methods
  • createServer Creates a mock service instance with Osprey
  • createServerFromBaseUri Creates a mock service with Osprey and uses the base URI path
  • loadFile Creates a mock service with Osprey and the base URI path from a RAML file

License

Apache License 2.0

FAQs

Package last updated on 28 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc