当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Router.patch方法代码示例

本文整理汇总了TypeScript中express.Router.patch方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Router.patch方法的具体用法?TypeScript Router.patch怎么用?TypeScript Router.patch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在express.Router的用法示例。


在下文中一共展示了Router.patch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createRoutes

export function createRoutes(router: Router, setRouteVar: RequestHandler, auth: RequestHandler): void {
  // list route
  router.get('/users', setRouteVar, list)

  // route to check unique values
  router.post('/users/unique', setRouteVar, isUnique)

  // create route
  router.post('/users', setRouteVar, create)

  // TOTP login route - create
  router.post('/login/totp', setRouteVar, initTotp, sendTotp)

  // TOTP login route - login/signup
  router.patch('/login/totp', setRouteVar, verifyTotp, login)

  // reset password routes via TOTP
  router.patch('/login/reset', setRouteVar, verifyPasswords, verifyTotp)

  // update routes via TOTP
  router.patch('/self/totp', setRouteVar, auth, verifyTotp)

  // login routes via username/passport
  router.post('/login/local', setRouteVar, local, login)

  // JWT login routes
  router.get('/self', auth, login)

  // sublist route
  router.get('/self/:sublist', auth, sublist)

  // user created content route
  router.get('/self/:sublist/:slug', auth, content)

  // update route
  router.patch('/self', auth, update)

  // update user avatar
  router.put('/self/avatar', setRouteVar, auth, avatar)

  // delete route
  router.delete('/self', auth, remove)

  // user submit content route
  router.post('/self/submit', auth, submit)

  // user retract content route
  router.post('/self/retract', auth, retract)
}
开发者ID:yeegr,项目名称:SingularJS,代码行数:49,代码来源:UserController.ts

示例2: createRoutes

export function createRoutes(router: Router, auth: RequestHandler, setRouteVar: RequestHandler): void {
  // list route
  router.get('/', setRouteVar, list)

  // single entry route
  router.get('/:slug', setRouteVar, get)

  // comment route
  router.get('/:slug/comments', setRouteVar, comments)
  
  // action list route
  router.get('/:slug/:sublist', setRouteVar, sublist)
  
  // check if slug available
  router.post('/unique', setRouteVar, isUnique)

  // create route
  router.post('/', auth, setRouteVar, create)

  // create gallery
  router.put('/:slug/gallery', auth, setRouteVar, upload)

  // clear gallery
  router.delete('/:slug/gallery', auth, setRouteVar, clear, update)

  // update route
  router.patch('/:slug', auth, setRouteVar, update)

  // delete route
  router.delete('/:slug', auth, setRouteVar, remove)  
}
开发者ID:yeegr,项目名称:SingularJS,代码行数:31,代码来源:ContentController.ts

示例3: mount

  mount(router: Router) {
    var controller = require(this.controller)

    // if there is a target method, check to see if it exists and replace the original controller with it
    if (this.target) {
      if (!controller.hasOwnProperty(this.target)) {
        throw new Error("target function " + this.target + " does not exist on controller " + this.controller)
      }
      controller = controller[this.target]
    }

    // if controller is not a function, throw an error
    if (typeof (controller) != "function") {
      throw new Error("controllers must resolve to a function")
    }

    // use a switch (rather than checking for the method) to prevent 
    // unwanted method calls (ie. router.route(this.path, controller) would not be good...)
    switch (this.method.toLowerCase()) {
      case "all":
        router.all(this.path, controller)
        break
      case "get":
        router.get(this.path, controller)
        break
      case "put":
        router.put(this.path, controller)
        break
      case "post":
        router.post(this.path, controller)
        break
      case "delete":
        router.delete(this.path, controller)
        break
      case "patch":
        router.patch(this.path, controller)
        break
      case "use":
        if (typeof this.path === "string") {
          router.use(this.path, controller);
        } else {
          router.use(controller);
        }
        break;
      case "param":
        if (typeof this.path === "string") {
          router.param(this.path, controller);
        } else {
          router.param(controller);
        }
        break;
      default:
        throw new Error("unsupported method " + this.method)
    }
  }
开发者ID:Beng89,项目名称:adv-route,代码行数:55,代码来源:route.ts

示例4: routes

 routes() {
   // updates specific activity
   this.router.patch('/:id', this.update)
 }
开发者ID:yeegr,项目名称:SingularJS,代码行数:4,代码来源:ActivityRouter.ts


注:本文中的express.Router.patch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。