How to use the routing-controllers.Put function in routing-controllers

To help you get started, we’ve selected a few routing-controllers 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 epiphone / routing-controllers-openapi / __tests__ / fixtures / controllers.ts View on Github external
return
  }

  @HttpCode(201)
  @Post('/withType')
  @ResponseSchema(ModelDto, {
    description: 'Created user object',
    statusCode: 201
  })
  createUserWithType(
    @QueryParam('user', { type: CreateUserBody }) _user: string
  ) {
    return
  }

  @Put('/')
  createManyUsers(
    @Body({ required: true, type: CreateUserBody }) _body: CreateUserBody[]
  ) {
    return
  }

  @Post('/nested')
  createNestedUsers(@Body({ required: true }) _body: CreateNestedBody) {
    return
  }

  @Post('/:userId/posts')
  createUserPost(
    @Body({ required: true }) _body: CreatePostBody,
    @BodyParam('token') _token: string
  ) {
github shanmugharajk / react-point-of-sale / api / src / controllers / user / UserController.ts View on Github external
search,
      perPage: paginationInfo.perPage,
      page: paginationInfo.pageNo
    };
    return await this.crudServices.fetchPages(query);
  }

  @Post()
  public async createNewUser(
    @Body() User: User,
    @CurrentUser() userid: string
  ): Promise {
    return await this.crudServices.create(userid, User);
  }

  @Put("/:id")
  public async updateUser(
    @Param("id") id: string,
    @Body() data: User,
    @CurrentUser() userid: string
  ) {
    return await this.crudServices.updateById(userid, { id }, data);
  }

  @Delete("/:id")
  public async deleteUser(@Param("id") id: string): Promise {
    return await this.crudServices.deleteById(id);
  }
}
github epiphone / routing-controllers-openapi / sample / 01-basic / UsersController.ts View on Github external
]
  }

  @Get('/:id')
  @OpenAPI({ summary: 'Return a single user' })
  getOne(@Param('id') id: number) {
    return { name: 'User #' + id }
  }

  @Post('/')
  @OpenAPI({ summary: 'Create a new user' })
  createUser(@Body({ validate: true }) body: CreateUserBody) {
    return { ...body, id: 3 }
  }

  @Put('/')
  createManyUsers(@Body({ type: CreateUserBody }) body: CreateUserBody[]) {
    return {}
  }
}
github shanmugharajk / react-point-of-sale / api / src / controllers / vendor / VendorController.ts View on Github external
search,
      perPage: paginationInfo.perPage,
      page: paginationInfo.pageNo
    };
    return await this.crudServices.fetchPages(query);
  }

  @Post()
  public async createNewVendor(
    @Body() Vendor: Vendor,
    @CurrentUser() userid: string
  ): Promise {
    return await this.crudServices.create(userid, Vendor);
  }

  @Put("/:id")
  public async updateVendor(
    @Param("id") id: string,
    @Body() data: Vendor,
    @CurrentUser() userid: string
  ) {
    return await this.crudServices.updateById(userid, { id }, data);
  }

  @Delete("/:id")
  public async deleteVendor(@Param("id") id: string): Promise {
    return await this.crudServices.deleteById(id);
  }
}
github geli-lms / geli / api / src / controllers / PageController.ts View on Github external
return accessedPage.toObject();
  }

  @Post('/')
  @UseBefore(passportJwtMiddleware)
  @Authorized(['admin'])
  async addPage(@Body() data: any) {
    try {
      const page = await Page.create(data);
      return page.toObject();
    } catch (error) {
      const debug = error;
    }
  }

  @Put('/:path')
  @UseBefore(passportJwtMiddleware)
  @Authorized(['admin'])
  async  updatePage() {
    return new BadRequestError('Not implemented');
  }
}
github shanmugharajk / react-point-of-sale / api / src / controllers / products / ProductTypesController.ts View on Github external
search,
      perPage: paginationInfo.perPage,
      page: paginationInfo.pageNo
    };
    return await this.crudServices.fetchPages(query);
  }

  @Post()
  public async createNewProductType(
    @Body() productType: ProductType,
    @CurrentUser() userid: string
  ): Promise {
    return await this.crudServices.create(userid, productType);
  }

  @Put('/:id')
  public async updateProductType(
    @Param('id') id: string,
    @Body() data: ProductType,
    @CurrentUser() userid: string
  ) {
    return await this.crudServices.updateById(userid, { id }, data);
  }

  @Delete('/:id')
  public async deleteProductType(@Param('id') id: string): Promise {
    return await this.crudServices.deleteById(id);
  }
}
github shanmugharajk / react-point-of-sale / api / src / controllers / customer / CustomerController.ts View on Github external
search,
      perPage: paginationInfo.perPage,
      page: paginationInfo.pageNo
    };
    return await this.crudServices.fetchPages(query);
  }

  @Post()
  public async createNewCustomer(
    @Body() Customer: Customer,
    @CurrentUser() userid: string
  ): Promise {
    return await this.crudServices.create(userid, Customer);
  }

  @Put("/:id")
  public async updateCustomer(
    @Param("id") id: string,
    @Body() data: Customer,
    @CurrentUser() userid: string
  ) {
    return await this.crudServices.updateById(userid, { id }, data);
  }

  @Delete("/:id")
  public async deleteCustomer(@Param("id") id: string): Promise {
    return await this.crudServices.deleteById(id);
  }
}
github shanmugharajk / react-point-of-sale / api / src / controllers / expenses / ExpenseTypesController.ts View on Github external
search,
      perPage: paginationInfo.perPage,
      page: paginationInfo.pageNo
    };
    return await this.crudServices.fetchPages(query);
  }

  @Post()
  public async createNewExpenseType(
    @Body() ExpenseType: ExpenseType,
    @CurrentUser() userid: string
  ): Promise {
    return await this.crudServices.create(userid, ExpenseType);
  }

  @Put("/:id")
  public async updateExpenseType(
    @Param("id") id: string,
    @Body() data: ExpenseType,
    @CurrentUser() userid: string
  ) {
    return await this.crudServices.updateById(userid, { id }, data);
  }

  @Delete("/:id")
  public async deleteExpenseType(@Param("id") id: string): Promise {
    return await this.crudServices.deleteById(id);
  }
}
github RiseVision / rise-node / packages / core-transactions / src / api / httpApi.ts View on Github external
const postableTx = RiseV2.txs.toPostable(transaction);
    const res = await this.put({
      transaction: {
        ...postableTx,
        version: (postableTx as any).version || 0,
      } as any,
    });
    if (res.accepted && res.accepted.length === 1) {
      return { transactionId: res.accepted[0] };
    } else {
      throw new Error(res.invalid[0].reason);
    }
  }

  @Put()
  @ValidateSchema()
  public async put(@SchemaValid({
    properties: {
      transaction: { type: 'object' },
      transactions: { type: 'array', maxItems: 10 },
    },
    type: 'object',
  })
  @Body()
  body: {
    transaction?: ITransportTransaction;
    transactions?: Array>;
  }) {
    const { transaction } = body;
    let { transactions } = body;
    if (transactions && !Array.isArray(transactions)) {
github ChatPlug / ChatPlug / src / services / api / controllers / ServicesController.ts View on Github external
@QueryParam('query') q: string,
    @Param('id') id: number) {
    return await this.context.serviceManager.getServiceForId(id)!!.searchThreads(q)
  }

  @Delete('/instances/:id')
  async deleteService(@Param('id') id: number) {
    const foundService = await this.servicesRepository.findOne({ id })
    this.context.connection.getRepository(Log).update({ service: foundService }, { deleted: true })
    this.context.connection.getRepository(Thread).update({ service: foundService }, { deleted: true })
    this.context.connection.getRepository(User).update({ service: foundService }, { deleted: true })

    return this.servicesRepository.remove(foundService!!)
  }

  @Put('/instances/:id')
  async updateService(
    @Param('id') id: number,
    @Body() instance: any) {
    return this.servicesRepository.update({ id }, instance)
  }

  @Get('/:module/schema')
  async getConfigSchema(@Param('module') moduleName: string) {
    const serviceModule = (await this.context.serviceManager.getAvailableServices()).find(
      el => el.moduleName === moduleName,
    )
    if (!serviceModule) {
      throw new NotFoundError()
    }

    const schema = nativeRequire(serviceModule.modulePath).Config