Socket
Socket
Sign inDemoInstall

@tealina/doc-ui

Package Overview
Dependencies
1
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @tealina/doc-ui

For visualize and interact API's resources.


Version published
Weekly downloads
13
increased by160%
Maintainers
1
Install size
3.83 MB
Created
Weekly downloads
 

Readme

Source

Automatic generate modern UI for visualize and interact API's resources.

The document resouces should be json file in @tealina/doc-types format.

Install

pnpm add @tealina/doc-ui

yarn add @tealina/doc-ui

npm i @tealina/doc-ui

Usage

  1. Build the route whith recourses
// buildDocRoute.ts
import express, { Router } from 'express'
import path from 'node:path'
import {
  TealinaVdocWebConfig,
  getAssetsPath,
  assembleHTML,
  VDOC_BASENAME,
} from '@tealina/doc-ui'

const vDocCofig: TealinaVdocWebConfig = {
  sources: [
    {
      baseURL: '/api/v1',
      jsonURL: `${VDOC_BASENAME}/v1.json`,
      name: 'v1',
    },
  ],
  errorMessageKey: 'message',
  features: {
    playground: {
      //...
    },
  },
}

const docRouter = Router({ caseSensitive: true })
  .get('/index.html', (req, res, next) => {
    assembleHTML(vDocCofig).then(html => res.send(html))
  })
  .get('/v1.json', (req, res, next) => {
    res.sendFile(path.resolve('docs/api-v1.json'))
  })
  .use(express.static(getAssetsPath()))

export { docRouter, VDOC_BASENAME }
  1. Regitst Route
// server.ts
import { VDOC_BASENAME, docRouter } from './buildDocRoute.ts'
express().use(VDOC_BASENAME, docRouter).listen(5000)
  1. Open the link after server started.
http://localhost:5000/api-doc/index.html

FAQs

Last updated on 06 Jan 2024

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc