@useoptic/document-node-http

v0.1.6
Optic's documenting middleware for [micro](https://github.com/zeit/micro) or any other framework that uses the node http primitives. This package supports APIs written in Javascript, Typescript, or ReasonML and can be used with the testing framework of yo

Optic for micro

Optic's documenting middleware for micro or any other framework that uses the node http primitives. This package supports APIs written in Javascript, Typescript, or ReasonML and can be used with the testing framework of your choice.

Usage

Install as a dev dependency

npm install @useoptic/document-node-http --save-dev

Before testing your micro service, wrap it in the documenting middleware.

import {withOptic} from '@useoptic/document-node-http/micro'

const micro = require('micro')
const test = require('ava')
const listen = require('test-listen')
const request = require('request-promise')

const microWithOptic = withOptic(micro);

test('my endpoint', async t => {
  const service = microWithOptic(async (req, res) => {
    micro.send(res, 200, {
      test: 'woot'
    })
  })

  const url = await listen(service)
  const body = await request(url)

  t.deepEqual(JSON.parse(body).test, 'woot')
  service.close()
})

Next Steps

Once you've setup the documenting middleware, review the Optic docs to finish setting up Optic for your API

npm i @useoptic/document-node-http

Metadata

  • ISC
  • Whatever
  • Unknown
  • released 4/7/2019

Downloads