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


TypeScript NextFunction.default方法代码示例

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


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

示例1:

 .then((isMatch) => {
   if (!isMatch) { return next() }
   let opts: jwt.SignOptions = { expiresIn: '1h' }
   let token = jwt.sign(account, model.tokenSalt, opts)
   return res.status(200).json({
     id: account._id,
     success: true,
     token: token
   })
 })
开发者ID:chipp972,项目名称:stock_manager_api,代码行数:10,代码来源:auth.ts

示例2: GetById

  static async GetById(req: Request, res: Response, next: NextFunction): Promise<void> {
    try {
      const id: string = req.params.id;
      const todo: ITodos = await TodosModel.findById(id).exec();

      res.json({ todo });
    } catch (err) {
      next(err);
    }
  }
开发者ID:klik1301,项目名称:ts_express,代码行数:10,代码来源:todosCtrl.ts

示例3: newSession

 .then(session => {
     if (!session) {
         // session has been expired
         return newSession();
     }
     // console.log('session verified', session.sessionData);
     res.set('X-Auth-Token', token);
     req.session = session;
     next();
 });
开发者ID:VestaRayanAfzar,项目名称:express-api-template,代码行数:10,代码来源:session.ts

示例4: getSamplePhoto

  public static async getSamplePhoto(req: Request, res: Response, next: NextFunction) {
    if (!req.params.name) {
      return next();
    }
    const name = req.params.name;
    try {
      const photo = await ObjectManagers.getInstance()
        .PersonManager.getSamplePhoto(name);

      if (photo === null) {
        return next();
      }
      req.resultPipe = photo;
      return next();

    } catch (err) {
      return next(new ErrorDTO(ErrorCodes.PERSON_ERROR, 'Error during getting sample photo for a person', err));
    }
  }
开发者ID:bpatrik,项目名称:PiGallery2,代码行数:19,代码来源:PersonMWs.ts

示例5:

 .exec((err, user) => {
   if (err) { return next(err); }
   if (!user) {
     req.flash("errors", { msg: "Password reset token is invalid or has expired." });
     return res.redirect("/forgot");
   }
   res.render("account/reset", {
     title: "Password Reset"
   });
 });
开发者ID:20B2,项目名称:TypeScript-Node-Starter,代码行数:10,代码来源:user.ts

示例6:

 User.findById(request.params.id, (err: any, user: IUser) => {
   if (err) return next(err)
   request.body.forEach((property: any) => {
       user[property] = request.body[property]
   });
   user.save((err: any, user: IUser) => {
     if (err) return next(err)
     response.json(user)
   })
 })
开发者ID:pabloalonsolopez,项目名称:footbagent,代码行数:10,代码来源:users.ts

示例7: yamlParser

  return function yamlParser (req: Request, res: Response, next: NextFunction) {
    if (req._body) {
      debug('body already parsed')
      next()
      return
    }

    req.body = req.body || {}

    // skip requests without bodies
    if (!typeis.hasBody(req)) {
      debug('skip empty body')
      next()
      return
    }

    debug('content-type %j', req.headers['content-type'])

    // determine if request should be parsed
    if (!shouldParse(req)) {
      debug('skip parsing')
      next()
      return
    }

    // assert charset per RFC 7159 sec 8.1
    var charset = getCharset(req) || 'utf-8'
    if (charset.substr(0, 4) !== 'utf-') {
      debug('invalid charset')
      next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', {
        charset: charset
      }))
      return
    }

    // read
    read(req, res, next, parse, debug, {
      encoding: charset,
      inflate: inflate,
      limit: limit,
      verify: verify
    })
  }
开发者ID:MaxxtonGroup,项目名称:microdocs,代码行数:43,代码来源:yaml-parser.ts

示例8: changePassword

  public static async changePassword(req: Request, res: Response, next: NextFunction) {
    if (Config.Client.authenticationRequired === false) {
      return next(new ErrorDTO(ErrorCodes.USER_MANAGEMENT_DISABLED));
    }
    if ((typeof req.body === 'undefined') || (typeof req.body.userModReq === 'undefined')
      || (typeof req.body.userModReq.id === 'undefined')
      || (typeof req.body.userModReq.oldPassword === 'undefined')
      || (typeof req.body.userModReq.newPassword === 'undefined')) {
      return next();
    }

    try {
      await ObjectManagers.getInstance().UserManager.changePassword(req.body.userModReq);
      return next();

    } catch (err) {
      return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, null, err));
    }
  }
开发者ID:bpatrik,项目名称:PiGallery2,代码行数:19,代码来源:UserMWs.ts

示例9: deleteUser

  public static async deleteUser(req: Request, res: Response, next: NextFunction) {
    if (Config.Client.authenticationRequired === false) {
      return next(new ErrorDTO(ErrorCodes.USER_MANAGEMENT_DISABLED));
    }
    if ((typeof req.params === 'undefined') || (typeof req.params.id === 'undefined')) {
      return next();
    }


    try {
      await ObjectManagers.getInstance().UserManager.deleteUser(req.params.id);
      return next();

    } catch (err) {
      return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, null, err));
    }


  }
开发者ID:bpatrik,项目名称:PiGallery2,代码行数:19,代码来源:UserMWs.ts


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