How to use the typescript-rest-swagger.Security function in typescript-rest-swagger

To help you get started, we’ve selected a few typescript-rest-swagger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TreeGateway / tree-gateway / src / admin / api / middleware.ts View on Github external
'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
github TreeGateway / tree-gateway / src / admin / api / stats.ts View on Github external
'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,
github TreeGateway / tree-gateway / src / admin / api / config-package.ts View on Github external
'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();
    }
}
github TreeGateway / tree-gateway / src / admin / api / gateway.ts View on Github external
'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 {
github TreeGateway / tree-gateway / src / admin / api / api.ts View on Github external
'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);

typescript-rest-swagger

Generate Swagger files from a typescript-rest project

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis