当前位置: 首页 > 软件库 > Web应用开发 > Web框架 >

koa-joi-router-docs

授权协议 View license
开发语言 JavaScript
所属分类 Web应用开发、 Web框架
软件类型 开源软件
地区 不详
投 递 者 邓高韵
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Koa-Joi-Router Docs Generator

This project is based on paul42/joi-router-swagger-docs.

A node module for generating Swagger 2.0 JSONdefinitions from existing koa-joi-routerroutes.

Aiming to be a replacement forkoa-resourcer-docs which cantake advantage of various Swagger 2.0 tools for generating client libraries,test suites, AWS Lambda/serverless, etc.

Preview

code_to_docs

Install

# use npm
npm install koa-joi-router-docs --save
# use yarn
yarn add koa-joi-router-docs

Example

Visit example/ folder to see the full example.

API

new SwaggerAPI()

Creates a new SwaggerAPI instance.

swaggerAPI.addJoiRouter(router, options)

Add a joi-router instance to the API. The router should already have all itsroutes set up before calling this method (which pulls the route definitionsfrom the router's .routes property).

Options:

  • prefix: Prefix to add to Swagger path (use prefix from JoiRouter if not set)

swaggerAPI.generateSpec(baseSpec, options)

Create a Swagger specification for this API. A base specification should beprovided with an info object (containing at least the title and versionstrings) and any other global descriptions.

Options:

  • defaultResponses: Custom default responses
    {
      200: {
        description: 'Success'
      }
    }

Donation

If you find this project useful, you can buy us a cup of coffee:


Acknowledgements

We are grateful to the authors of existing related projects for their ideas and collaboration:

Contributors

chuyik
chuyik
  • koa-router Koa 的路由中间件 使用方式 new Router([opts]); 创建一个路由. 选项参数: opts : Object opts.prefix : String - 设置路由的前缀 例子: 基本用法: const Koa = require("Koa"); const Router = require("@koa/router"); // 初始化 koa 实例 c

  • Koa中常用的中间件: koa-session:让无状态的http拥有状态,基于cookie实现的后台保存信息的session koa-mysql:封装了需要用到的SQL语句 koa-mysql-session:当不想让session存储到内存,而想让session存储到mysql数据库中时使用 koa-router:后台会接受到各种请求的url,路由会根据不同的url来使用不同的处理逻辑。 ko

  • import Koa from 'koa'; import Joi from 'joi'; import Router from '@koa/router'; import validateSchemaJoi from './middlewares/schema.js'; const app = new Koa(); const router = new Router(); const log

  • 背景 koa-router路由越来越多,api下的router都要使用下面的方式引入,怎么才能方便快捷的将api下的所有文件都引入呢 这次记录的就是如果将koa-router 一次性循环引入 const book = require('./app/api/v1/book') const classic = require('./app/api/v1/classic') // ... app.use

  • Koa-router 先是app.js的代码 // 导入koa,和koa 1.x不同,在koa2中,我们导入的是一个class,因此用大写的Koa表示: const Koa = require('koa'); // 创建一个Koa对象表示web app本身: const app = new Koa(); // 引入路由对象 const router= require('./controller/r

  • 1、引入Koa类和路由类 const Koa=require('koa'); const Router=require('koa-router'); 2、实例化两个类 const app=new Koa(); const router=new Router(); 3、启动路由及其方法 app.use(router.routes()) . use(router.allowe

  • 使用: const Koa = require('koa') const app = new Koa() const Router = require('koa-router') const user = new Router() app.use(uer.routes()) // 加载user路由中间件 user.get(routerName, url, ctx => { // 参数一可省略 -

  • 版本7.4.0 比较长,建议一边看一边打断点,光看一遍估计是不知道在说什么的,因为它的思路不是面向过程的那种一条线,而是互相穿插,绕来绕去的。 koa-router的核心其实是path-to-regexp这个库,不过koa-router做了非常多的参数处理和封装,主要提供的功能有:基础的rest方法的注册、嵌套路由、路由中间层、参数处理等,我们一个一个来看。 先来看看koa-router的基本使用

  • 目录 背景 创建路由 路由中间件注册 测试 背景 上一篇文章已经完成了KOA骨架的搭建。这节课来讲解下如何添加路由。 大家都知道,路由其实就是用来标识应用上的唯一的一个接口,所以接口通常又被称为资源。在express的使用过程大家都知道我们可以借用express-router来实现路由编程。那么在KOA里头同样有这么一个包,称为koa-router,这个包在上一节课里头,我已经提前安装。 创建路由

  • 简介 koa需要搭配中间件来做接口更方便,使用Koa-body & Koa-router 使用 koa2 创建接口,处理post请求 const koa=require("koa") const Router=require('koa-router') const koaBody = require('koa-body') const router=new Router() const app=

  • 对比 如果使用nodejs来搭建Service服务,那么我们首选express或者koa,而fastify告诉我们一个数据: Framework Version Router? Requests/sec hapi 18.1.0 ✓ 29,998 Express 4.16.4 ✓ 38,510 Restify 8.0.0 ✓ 39,331 Koa 2.7.0 ✗ 50,933 Fastify 2.0

  • https://blog.csdn.net/weixin_30363817/article/details/96367416

  • 安装 npm i koa-router -D 使用 一、引入 const Koa = require('koa') const router = require('koa-router')() const app = new Koa() 二、定义路由 // get请求路由 router.get('/profile/:username', async (ctx, next) => { //

  • Koa2学习(六)使用koa-router 配置简单路由 引入中间件 配置需要的路由 通过app.use注册路由 const Koa = require('koa') const app = new Koa() // 引入koa-router并对其实例化 const router = require('koa-router')() // 配置get路由 router.get('/get', fun

 相关资料
  • joi-router Easy, rich and fully validated koa routing. Features: built in input validation using joi built in output validation using joi built in body parsing using co-body and await-busboy built on

  • koa-joi-swagger Using joi schema to validate request & response, and generate swagger document to create beautiful API documents. Feature Router agnostic. Using your favorite library for validation, a

  • koa-react-router koa 2 middleware for React server side rendering and routing with react-router 5. Looking for React Router 3 support see v1 docs.Try React Router 5 though it's awesome! Usage To insta

  • Koa-OAI-Router 中文 English I have used markdown and wiki to manage api doc, from which I have suffered a lot. It wastes too much time and is very boring. The document should be repaired when you change

  • Koa tree router Koa tree router is a high performance router for Koa. Features Fast. Up to 11 times faster than Koa-router. Benchmark Express-style routing using router.get, router.put, router.post, e

  • Joi

    Joi 是用于 JavaScript 的强大的模式描述语言和数据验证器,让你可以使用简单、直观且可读的语言来描述数据。 示例: const Joi = require('joi');const schema = Joi.object({ username: Joi.string() .alphanum() .min(3) .max(30)