Socket
Book a DemoInstallSign in
Socket

@useoptic/document-express

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@useoptic/document-express

An Optic fixture for documenting Express JS APIs

Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
10
-41.18%
Maintainers
2
Weekly downloads
 
Created
Source

Optic for Express JS

Optic's documenting middleware for Express JS. 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-express --save-dev
  • Before testing your Express App, wrap it in the documenting middleware.
import withOptic from '@useoptic/document-express'
//Express App used in Production
import {app} from '../server.js'

//Using Optic to document your API as your tests run
const appWithOptic = withOptic(app) 

//Example Test
it('can get a list of users', (done) => {
    request(appWithOptic)
       .get('/users')
       .expect(200, done)  
})

  • Consider wrapping the Express App within a shared test fixture so it's easier to integrate Optic with all of your tests.

Next Steps

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

FAQs

Package last updated on 03 Mar 2019

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