How to use the typescript-rest.Path function in typescript-rest

To help you get started, we’ve selected a few typescript-rest 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 vellengs / typerx / server / controllers / dict.controller.ts View on Github external
import { UISchema, PaginateResponse } from 'modex';
import { Db } from './../database';
import { Dict } from './../schemas';
import { Helper } from '../utils/helper';

/**
 * 获取菜单y.
 */
@Tags('base')
@Path('/api/dict')
export class DictController {

    /**
      * 获取客户管理界面配置信息.
      */
    @Path('config')
    @GET
    async getConfig(): Promise {
        return Helper.getUISchema('Dict');
    }

    /**
     * * 按分类获取字典数据
     * @param {string} category 分类键名
     * @returns {Promise};
     * @memberof DictController
     */
    @Path('category/:category')
    @GET
    async getDictByCategory( @PathParam('category') category: string): Promise {
        const docs = await Db.dict.find({ category: category }).exec();
        if (docs) {
github turt2live / matrix-dimension / src / api / admin / AdminWebhooksService.ts View on Github external
interface BridgeResponse {
    id: number;
    upstreamId?: number;
    provisionUrl?: string;
    sharedSecret?: string;
    isEnabled: boolean;
}

/**
 * Administrative API for configuring Webhook bridge instances.
 */
@Path("/api/v1/dimension/admin/webhooks")
export class AdminWebhooksService {

    @GET
    @Path("all")
    public async getBridges(@QueryParam("scalar_token") scalarToken: string): Promise {
        await AdminService.validateAndGetAdminTokenOwner(scalarToken);

        const bridges = await WebhookBridgeRecord.findAll();
        return Promise.all(bridges.map(async b => {
            return {
                id: b.id,
                upstreamId: b.upstreamId,
                provisionUrl: b.provisionUrl,
                sharedSecret: b.sharedSecret,
                isEnabled: b.isEnabled,
            };
        }));
    }

    @GET
github TreeGateway / tree-gateway / src / admin / api / middleware.ts View on Github external
}

    @POST
    @Path('throttling/skip')
    public addThrottlingSkip(@FileParam('file') file: Express.Multer.File, @FormParam('name') name: string) {
        return this.addMiddleware('throttling/skip', file, name);
    }

    @POST
    @Path('circuitbreaker')
    public addCircuitBreaker(@FileParam('file') file: Express.Multer.File, @FormParam('name') name: string) {
        return this.addMiddleware('circuitbreaker', file, name);
    }

    @POST
    @Path('cors/origin')
    public addCors(@FileParam('file') file: Express.Multer.File, @FormParam('name') name: string) {
        return this.addMiddleware('cors/origin', file, name);
    }

    @POST
    @Path('proxy/router')
    public addProxyRouter(@FileParam('file') file: Express.Multer.File, @FormParam('name') name: string) {
        return this.addMiddleware('proxy/router', file, name);
    }

    @POST
    @Path('servicediscovery')
    public addServiceDiscovery(@FileParam('file') file: Express.Multer.File, @FormParam('name') name: string) {
        return this.addMiddleware('servicediscovery', file, name);
    }
github turt2live / matrix-dimension / src / api / dimension / DimensionIntegrationsService.ts View on Github external
import { Bridge } from "../../integrations/Bridge";
import { BridgeStore } from "../../db/BridgeStore";
import { BotStore } from "../../db/BotStore";
import { AdminService } from "../admin/AdminService";

export interface IntegrationsResponse {
    widgets: Widget[],
    bots: SimpleBot[],
    complexBots: ComplexBot[],
    bridges: Bridge[],
}

/**
 * API for managing integrations, primarily for a given room
 */
@Path("/api/v1/dimension/integrations")
export class DimensionIntegrationsService {

    /**
     * Gets a list of widgets
     * @param {boolean} enabledOnly True to only return the enabled widgets
     * @returns {Promise} Resolves to the widget list
     */
    public static async getWidgets(enabledOnly: boolean): Promise {
        const cached = Cache.for(CACHE_INTEGRATIONS).get("widgets");
        if (cached) return cached;

        const widgets = await WidgetStore.listAll(enabledOnly ? true : null);
        Cache.for(CACHE_INTEGRATIONS).put("widgets", widgets);
        return widgets;
    }
github vellengs / typerx / server / controllers / setting.controller.ts View on Github external
import { GET, Path, PathParam, POST, PUT, DELETE, QueryParam, ServiceContext, Context } from 'typescript-rest';
import { Tags } from 'typescript-rest-swagger';
import { UISchema, PaginateResponse } from 'modex';
import { Db } from './../database';
import { Setting } from './../schemas';
import { Helper } from '../utils/helper';

/**
 * * 获取文章分类信息
 * 
 * @export
 * @class SettingController
 */
@Tags('system')
@Path('/api/setting')
export class SettingController {

    @Context
    context: ServiceContext;

    /**
     * 获取文章分类管理界面配置信息.
     */

    @Path('config')
    @GET
    async getConfig(): Promise {
        return Helper.getUISchema('Setting');
    }
github TreeGateway / tree-gateway / src / admin / api / api.ts View on Github external
@Path('/:id')
    public async updateApi(@PathParam('id') id: string, api: ApiConfig): Promise {
        api.id = id;

        await validateApiConfig(api, this.config.gateway.disableApiIdValidation);
        await this.service.update(api);
    }

    @DELETE
    @Path('/:id')
    public async removeApi(@PathParam('id') id: string): Promise {
        await this.service.remove(id);
    }

    @GET
    @Path('/:id')
    public async getApi(@PathParam('id') id: string): Promise {
        return await this.service.get(id);
    }
}
github vellengs / typerx / server / controllers / employee.controller.ts View on Github external
@PUT
    async update(entry: Employee): Promise {
        return Helper.update('Employee', entry);
    }


    /**
     * 分页查询员工表
     * 
     * @param {number} [page] 第几页  从 1 开始计;
     * @param {number} [size] 页大小
     * @param {string} [sort] 排序
     * @returns {Promise>} 
     * @memberof EmployeeController
     */
    @Path('query')
    @GET
    async getPaged(
        @QueryParam('page') page?: number,
        @QueryParam('size') size?: number,
        @QueryParam('sort') sort?: string): Promise> {
        return Helper.getPagedData('Employee', page, size, [], sort);
    }

    /**
     * 删除员工信息
     * 
     * @param {string} id 编号 可以逗号分割传递多个。
     * @returns {Promise} 
     * @memberof EmployeeController
     */
    @Path(':id')
github vellengs / typerx / packages / server / src / modules / core / dict.controller.ts View on Github external
* 更新字典
   * @param entry 设置项实体
   */
  @PUT
  async update(entry: EditDictDto): Promise {
    return this.service.update(entry);
  }

  /**
   * 分页查询字典
   * @param keyword 关键词
   * @param page 第几页
   * @param size 页大小
   * @param sort 排序
   */
  @Path('query')
  @GET
  async query(
    @QueryParam('keyword') keyword?: string,
    @QueryParam('category') category?: string,
    @QueryParam('page') page?: number,
    @QueryParam('size') size?: number,
    @QueryParam('sort') sort?: string): Promise {
    return this.service.query(keyword, category, page, size, sort);
  }


  /**
   * 按编号获取字典
   * @param id 键
   */
  @Path(':id')
github TreeGateway / tree-gateway / src / admin / api / middleware.ts View on Github external
}

    @POST
    @Path('servicediscovery')
    public addServiceDiscovery(@FileParam('file') file: Express.Multer.File, @FormParam('name') name: string) {
        return this.addMiddleware('servicediscovery', file, name);
    }

    @POST
    @Path('servicediscovery/provider')
    public addServiceDiscoveryProvider(@FileParam('file') file: Express.Multer.File, @FormParam('name') name: string) {
        return this.addMiddleware('servicediscovery/provider', file, name);
    }

    @POST
    @Path('errorhandler')
    public addErrorHandler(@FileParam('file') file: Express.Multer.File, @FormParam('name') name: string) {
        return this.addMiddleware('errorhandler', file, name);
    }

    @POST
    @Path('request/logger')
    public addRequestLogger(@FileParam('file') file: Express.Multer.File, @FormParam('name') name: string) {
        return this.addMiddleware('request/logger', file, name);
    }

    private async getMiddleware(type: string, name: string): Promise {
        try {
            const value = await this.service.read(type, name);
            return new Return.DownloadBinaryData(value, 'application/javascript', name + '.js');
        } catch (err) {
            throw new Errors.NotFoundError();
github turt2live / matrix-dimension / src / api / admin / AdminTermsService.ts View on Github external
import { GET, Path, PathParam, POST, PUT, Security } from "typescript-rest";
import TermsController, { ITerms } from "../controllers/TermsController";
import { AutoWired, Inject } from "typescript-ioc/es6";
import { ROLE_ADMIN, ROLE_USER } from "../security/MatrixSecurity";

interface CreatePolicyObject {
    name: string;
    text?: string;
    url: string;
}

/**
 * Administrative API for configuring terms of service.
 */
@Path("/api/v1/dimension/admin/terms")
@AutoWired
export class AdminTermsService {

    @Inject
    private termsController: TermsController;

    @GET
    @Path("all")
    @Security([ROLE_USER, ROLE_ADMIN])
    public async getPolicies(): Promise {
        return this.termsController.getPoliciesForAdmin();
    }

    @GET
    @Path(":shortcode/:version")
    @Security([ROLE_USER, ROLE_ADMIN])