當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。