0.3.17 • Published 5 years ago
@nestcloud/gateway v0.3.17
NestCloud - Gateway
Description
The gateway module for nestcloud.
Installation
$ npm install --save @nestcloud/gateway
Notification
You should not use body parser middleware when use this module or the post request will hang.
Quick Start
Register Module
import { Module } from '@nestjs/common';
import { NEST_BOOT } from '@nestcloud/common';
import { GatewayModule } from "@nestcloud/gateway";
@Module({
imports: [
GatewayModule.register({dependencies: [NEST_BOOT]}),
]
})
export class AppModule {
}
Configurations
gateway:
routes:
- id: user
uri: lb://nestcloud-user-service
- id: pay
uri: https://example.com/pay
Usage
import { All, Controller, Param, Req, Res } from "@nestjs/common";
import { Request, Response } from 'express';
import { Gateway, InjectGateway } from "@nestcloud/gateway";
@Controller('/gateway/:service')
export class GatewayController {
constructor(
@InjectGateway() private readonly gateway: Gateway,
) {
}
@All()
do(@Req() req: Request, @Res() res: Response, @Param('service') id) {
this.gateway.forward(req, res, id);
}
private updatRoutes() {
const routes = [{id: 'example', uri: 'lb://example-service'}];
this.gateway.updateRoutes(routes);
}
}
API
class GatewayModule
static register(options: IGatewayOptions = {}, proxy?: IProxyOptions): DynamicModule
Register gateway module.
field | type | description |
---|---|---|
options.dependencies | string[] | NEST_BOOT or NEST_CONSUL_CONFIG |
options.routes | IRoute[] | routes of gateway |
proxy | IProxyOptions | please see http-proxy doc for detail |
class Gateway
updateRoutes(routes: IRoute[], sync: boolean = true): void
Update gateway routes.
TODO
filter support
Stay in touch
- Author - NestCloud
License
NestCloud is MIT licensed.
0.3.17
5 years ago
0.3.16
5 years ago
0.3.16-0
5 years ago
0.3.15
5 years ago
0.3.14
5 years ago
0.3.14-2
5 years ago
0.3.14-1
5 years ago
0.3.14-0
5 years ago
0.3.13
5 years ago
0.3.12
5 years ago
0.3.10
5 years ago
0.3.9
5 years ago
0.3.9-0
5 years ago
0.3.8
5 years ago
0.3.8-5
5 years ago
0.3.8-4
5 years ago
0.3.8-3
5 years ago
0.3.8-2
5 years ago
0.3.8-1
5 years ago
0.3.8-0
5 years ago
0.3.7
5 years ago
0.3.6
5 years ago
0.3.5
5 years ago
0.3.4
5 years ago
0.3.1
5 years ago
0.3.0
5 years ago
0.2.5-3
5 years ago
0.2.5-2
5 years ago
0.2.5-1
5 years ago
0.2.5-0
5 years ago
0.2.4
5 years ago
0.2.4-3
5 years ago
0.2.4-2
5 years ago
0.2.4-1
5 years ago
0.2.4-0
5 years ago
0.2.3
5 years ago
0.2.2
5 years ago
0.2.1
5 years ago
0.2.1-5
5 years ago
0.2.1-4
5 years ago
0.2.1-3
5 years ago
0.2.1-2
5 years ago
0.2.1-1
5 years ago
0.2.1-0
5 years ago
0.1.3
5 years ago
0.1.2
5 years ago
0.1.1
5 years ago
0.1.0
5 years ago