當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Response.end方法代碼示例

本文整理匯總了TypeScript中express.Response.end方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Response.end方法的具體用法?TypeScript Response.end怎麽用?TypeScript Response.end使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在express.Response的用法示例。


在下文中一共展示了Response.end方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

    proxied.on("error", (err: any) => {
      if (err.code === "ETIMEDOUT" || err.code === "ESOCKETTIMEDOUT") {
        res.statusCode = 504;
        return res.end("Timed out waiting for function to respond.");
      }

      res.statusCode = 500;
      res.end(`An internal error occurred while proxying for ${rewriteIdentifier}`);
    });
開發者ID:firebase,項目名稱:firebase-tools,代碼行數:9,代碼來源:proxy.ts

示例2: function

 return function(req: Request, res: Response): void {
   const cdn = 'https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.13.1'
   res.set('content-type', 'text/html')
   res.send(`
     <html>
     <head>
       <title>${spec.info.title} API Documentation</title>
       <link rel="stylesheet" type="text/css" href="${cdn}/swagger-ui.css">
     </head>
     <body>
       <div id="swagger-ui"></div>
       <script src="${cdn}/swagger-ui-bundle.js"></script>
       <script src="${cdn}/swagger-ui-standalone-preset.js"></script>
       <script>
         window.onload = function () {
           window.ui = SwaggerUIBundle({
             url: new URL("${swaggerPath}", window.location.href).href,
             dom_id: '#swagger-ui',
             deepLinking: true,
             presets: [
               SwaggerUIBundle.presets.apis,
               SwaggerUIStandalonePreset
             ],
             plugins: [
               SwaggerUIBundle.plugins.DownloadUrl
             ],
             layout: "StandaloneLayout"
           })
         }
       </script>
   `)
   res.end()
 }
開發者ID:patrickhulce,項目名稱:klay,代碼行數:33,代碼來源:swagger.ts

示例3: Date

    res.end = (chunk?: any, encoding?: string | Function): void => {
        res.end = end;
        res.end(chunk, (encoding as string));

        meta.res = {
            statusCode: res.statusCode,
            responseTime: (new Date() as any) - res.locals.startTime,
        };

        if (resLog.headers) {
            // there are 2 headers that will not appear here:
            // 1. Date: "server date"
            // 2. Connection: "keep-alive"
            // there is an npm package that extracts these 2 headers too but it doesn't make sens to use it just for that
            // npm: https://github.com/watson/http-headers
            meta.res.headers = (res as any)._headers;
        }

        if (resLog.body && chunk) {
            const contentType = res.getHeader("content-type");
            const isJson = typeof contentType === "string" && contentType.indexOf("json") >= 0;
            meta.res.body = bodyToString(chunk, isJson);
        }

        logger.info("http-logger", meta);
    };
開發者ID:lmaran,項目名稱:scoala21,代碼行數:26,代碼來源:httpLogHandler.middleware.ts

示例4:

 Subject.findOneAndUpdate({code: code}, {$pull: {"tasks.requirements": {_id: req.params.id}}}).exec((err) => {
   if (!err) {
     res.end();
   } else {
     res.json(err);
   }
 });
開發者ID:Angularne,項目名稱:EduQ,代碼行數:7,代碼來源:subject.ts

示例5:

 user.save((err) => {
   if (!err) {
     res.end();
   } else {
     res.status(400).json(err);
   }
 });
開發者ID:Angularne,項目名稱:EduQ,代碼行數:7,代碼來源:user.ts

示例6: function

var serverError = function (response: Response, message: string, user?: User) {
    logger.error(message, user);
    response.type('application/json; charset=utf-8');
    response.writeHead(500);
    response.write('{"error": "' + message + '"}');
    response.end();
};
開發者ID:andi-git,項目名稱:nodejs-test,代碼行數:7,代碼來源:app.ts


注:本文中的express.Response.end方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。