nodecloud-gateway
nodecloud-gateway is a gateway component in microsoft service system. It is inspired by Zuul. It is based on koa middleware mechanism.
The lib is developing without any production verifications
Get Started
Install it via npm:
npm install --save nodecloud-gateway
Implements a filter extends PreGatewayFilter
(or AbstractGatewayFilter
, RouteGatewayFilter
, PostGatewayFilter
).
The filter which extends PreGatewayfilter
will be executed first. The following filters extend RouteGatewayFilter
and PostGatewayFilter
classes.
; { superapp; } // Likes the koa middleware async { ctx; }
Use it with koa framework:
;; const gateway = ;const app = ; // All responses have the header 'x-gateway: true'gateway // other koa logic and middlewaresapp;
Use it with nodecloud-boot, and You must create routeConfig
;;; const ncBoot = NCBoot;const app = ;const gateway = ;const routeConfig = prefix: '/api' routes: 'service0': path: '/example1/**' 'service1': path: '/example/**' ignorePattern: /\/example\/a\// ; ncBoot
API
routeConfig