Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
import * as path from 'path';
import { Inject } from 'typescript-ioc';
import { DELETE, Errors, FileParam, FormParam, GET, Path, PathParam, POST, PUT, QueryParam, Return } from 'typescript-rest';
import * as swagger from 'typescript-rest-swagger';
import { MiddlewareService } from '../../service/middleware';
@Path('middleware')
@swagger.Tags('Middleware')
@swagger.Security('Bearer')
export class MiddlewareRest {
@Inject private service: MiddlewareService;
@GET
@Path('filters')
public filters(@QueryParam('name') name?: string): Promise> {
return this.service.list('filter', name);
}
@GET
@Path('interceptors/request')
public requestInterceptors(@QueryParam('name') name?: string): Promise> {
return this.service.list('interceptor/request', name);
}
@GET
'use strict';
import { Path, GET, PathParam, Errors, QueryParam } from 'typescript-rest';
import { Stats } from '../../stats/stats';
import { Monitors } from '../../monitor/monitors';
import { Inject } from 'typescript-ioc';
import { StatsRecorder } from '../../stats/stats-recorder';
import { normalizePath } from '../../utils/path';
import * as swagger from 'typescript-rest-swagger';
@Path('stats')
@swagger.Tags('Stats')
@swagger.Security('Bearer')
export class StatsRest {
@Inject private monitors: Monitors;
@Inject private statsRecorder: StatsRecorder;
@GET
@Path('auth/fail/:apiId')
getAuthFail( @PathParam('apiId') apiId: string,
@QueryParam('path') path: string,
@QueryParam('count') count: number): Promise>> {
return this.getStats(apiId, 'auth', path, 'fail', count);
}
@GET
@Path('auth/success/:apiId')
getAuthSuccess( @PathParam('apiId') apiId: string,
@QueryParam('path') path: string,
'use strict';
import { Inject } from 'typescript-ioc';
import { GET, Path, POST } from 'typescript-rest';
import * as swagger from 'typescript-rest-swagger';
import { ConfigPackage, validateConfigPackage } from '../../config/config-package';
import { ConfigPackageService } from '../../service/config-package';
@Path('config')
@swagger.Tags('Config')
@swagger.Security('Bearer')
export class ConfigPackageRest {
@Inject private service: ConfigPackageService;
@POST
public async set(config: ConfigPackage): Promise {
await validateConfigPackage(config);
await this.service.set(config);
}
@GET
public async get(): Promise {
return await this.service.get();
}
}
'use strict';
import { Inject } from 'typescript-ioc';
import { DELETE, GET, Path, PUT } from 'typescript-rest';
import * as swagger from 'typescript-rest-swagger';
import { GatewayConfig, validateGatewayConfig } from '../../config/gateway';
import { GatewayService } from '../../service/gateway';
@Path('gateway')
@swagger.Tags('Gateway')
@swagger.Security('Bearer')
export class GatewayRest {
@Inject private service: GatewayService;
@PUT
public async updateConfig(config: GatewayConfig): Promise {
await validateGatewayConfig(config);
await this.service.save(config);
}
@DELETE
public async removeConfig(): Promise {
await this.service.remove();
}
@GET
public async getConfig(): Promise {
'use strict';
import { Inject } from 'typescript-ioc';
import { DELETE, GET, Path, PathParam, POST, PUT, QueryParam, Return } from 'typescript-rest';
import * as swagger from 'typescript-rest-swagger';
import { ApiConfig, validateApiConfig } from '../../config/api';
import { Configuration } from '../../configuration';
import { ApiService } from '../../service/api';
@Path('apis')
@swagger.Tags('APIs')
@swagger.Security('Bearer')
export class APIRest {
@Inject private service: ApiService;
@Inject private config: Configuration;
@GET
public list(@QueryParam('name') name?: string,
@QueryParam('version') version?: string,
@QueryParam('description') description?: string,
@QueryParam('path') path?: string): Promise> {
return this.service.list(name, version, description, path);
}
@POST
public async addApi(api: ApiConfig): Promise> {
await validateApiConfig(api, this.config.gateway.disableApiIdValidation);
const apiId = await this.service.create(api);