express-insomnia-gendoc
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

express-insomnia-gendoc

Auto generate a insomnia API Docs with your express.js for import.

Setup / Install:

npm i express-insomnia-gendoc
yarn add express-insomnia-gendoc

Still in beta, may occur bugs or unexpected error.

Usage

import express from 'express'
import { Request, Response } from 'express'
import { appleRoute } from "./apple"

import { routeGenDoc } from "express-insomnia-gendoc"

const app = express()
app.use(express.static("public"))

app.get('/', function (req: Request, res: Response) {
  res.end('Hello World')
})

app.get('/hello', function (req: Request, res: Response) {
  res.json({ status: "burh" })
})

app.use("/apple", appleRoute) // Assume you have other route


const PORT = 8080
routeGenDoc(app, PORT); // Put the functions at the last

app.listen(PORT, () => {
  console.log(`Listening at http://localhost:${PORT}/`)
})

Params

routeGenDoc(app:Express, currentPort: number, options?:RouteGenOptions)

interface RouteGenOptions {
    collectionsName? : string; // "My API Router"
    documentsName?: string; // "insomnia_doc"
    export_source? : string; // "insomnia.desktop.app:v2022.5.1"
}

Then, a insomnia_doc.json will be generated at the root folder.
In the Insomnia home page, you can process the below steps:

  1. Click "Create".
  2. Under the "IMPORT FROM", select the "+ File".
  3. Select the generated folder.
  4. You will see a new Collection is created.

Readme

Keywords

none

Package Sidebar

Install

npm i express-insomnia-gendoc

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

28.8 kB

Total Files

7

Last publish

Collaborators

  • r48n34