@useoptic/document-sails

An Optic fixture for documenting Sails JS

Usage no npm install needed!

<script type="module">
  import useopticDocumentSails from 'https://cdn.skypack.dev/@useoptic/document-sails';
</script>

README

Using Optic with Sails

Optic's documenting middleware for Sails.

Usage

Install the node module from npm:

npm install @useoptic/document-sails

Add the Optic documenting middleware to config/http.js. The middleware will be skipped by default and will never run in production. It only runs when your tests were started by optic api:document. Every HTTP request your run to test your API will be used by Optic to infer the current API contract.

module.exports.http = {

  middleware: {
    order: [
      'cookieParser',
      'session',
      'bodyParser',
      'compress',
      'poweredBy',
      'documentSails', //Optic always goes just before router
      'router',
      'www',
      'favicon'
    ], 	
    
    documentSails: require('@useoptic/document-sails') //import middleware from package
    
  }
}