0.1.6 • Published 6 years ago

@useoptic/document-node-http v0.1.6

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

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

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago