Code Monkey home page Code Monkey logo

koa-oai-router-middleware's Introduction

Koa-OAI-Router-Middleware

License Node Version NPM Version Build Status Test Coverage Downloads Dependency Status

Middleware loader plugin koa-oai-router

Installation

npm i koa-oai-router-middleware --save

Info

field type info
plugin class string MiddlewarePlugin
plugin name string middleware
evoked fields string|[string] x-oai-middleware, x-middleware, x-oai-controller, x-controller
evoked fileds value [{file,handler}] file is relative file path of middleware , handler is name of middleware exported
options string|object if options is string, effect same as object contains dir, middlewareDir and middleware.

Usage

In this example, we will load middlewares from ./controllers directory and recognize the value of x-oai-middleware then bind them to a api.

const Koa = require('koa');
const Router = require('koa-oai-router');
const MiddlewarePlugin = require('koa-oai-router-middleware');

const app = new Koa();
const router = new Router({
  apiDoc: './api',
  options: {
    middleware: './controllers',
    // OR
    MiddlewarePlugin: './controllers',
  },
});

router.mount(MiddlewarePlugin);

app.use(bodyParser());
app.use(router.routes());
# ./api/paths/pets.yaml

/pets:
  get:
    description: "Returns all pets from the system that the user has access to"
    x-oai-middleware:
      - file: pets
        handler: get
    parameters:
      - name: "tags"
        in: "query"
        description: "tags to filter by"
        required: false
        type: "array"
        items:
          type: "string"
        collectionFormat: "csv"
      - name: "limit"
        in: "query"
        description: "maximum number of results to return"
        required: false
        type: "integer"
        format: "int32"
    responses:
      "200":
        description: "pet response"
        schema:
          type: "array"
          items:
            $ref: "#/definitions/Pet"

koa-oai-router-middleware's People

Contributors

amazing-gao avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

openvoip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.