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


TypeScript apollo-server-core.processFileUploads函數代碼示例

本文整理匯總了TypeScript中apollo-server-core.processFileUploads函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript processFileUploads函數的具體用法?TypeScript processFileUploads怎麽用?TypeScript processFileUploads使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: processFileUploads

) => (
  req: FastifyRequest<IncomingMessage>,
  reply: FastifyReply<OutgoingMessage>,
  done: (err: Error | null, body?: any) => void,
) => {
  if (
    (req.req as any)[kMultipart] &&
    typeof processFileUploads === 'function'
  ) {
    processFileUploads(req.req, reply.res, uploadsConfig)
      .then(body => {
        req.body = body;
        done(null);
      })
      .catch(error => {
        if (error.status && error.expose) reply.status(error.status);

        throw formatApolloErrors([error], {
          formatter: server.requestOptions.formatError,
          debug: server.requestOptions.debug,
        });
      });
  } else {
    done(null);
  }
};
開發者ID:apollostack,項目名稱:apollo-server,代碼行數:26,代碼來源:ApolloServer.ts

示例2: typeis

) => (
  req: express.Request,
  res: express.Response,
  next: express.NextFunction,
) => {
  // Note: we use typeis directly instead of via req.is for connect support.
  if (
    typeof processFileUploads === 'function' &&
    typeis(req, ['multipart/form-data'])
  ) {
    processFileUploads(req, res, uploadsConfig)
      .then(body => {
        req.body = body;
        next();
      })
      .catch(error => {
        if (error.status && error.expose) res.status(error.status);

        next(
          formatApolloErrors([error], {
            formatter: server.requestOptions.formatError,
            debug: server.requestOptions.debug,
          }),
        );
      });
  } else {
    next();
  }
};
開發者ID:apollostack,項目名稱:apollo-server,代碼行數:29,代碼來源:ApolloServer.ts

示例3: handleFileUploads

  // If file uploads are detected, prepare them for easier handling with
  // the help of `graphql-upload`.
  private async handleFileUploads(req: MicroRequest, res: ServerResponse) {
    if (typeof processFileUploads !== 'function') {
      return;
    }

    const contentType = req.headers['content-type'];
    if (
      this.uploadsConfig &&
      contentType &&
      contentType.startsWith('multipart/form-data')
    ) {
      req.filePayload = await processFileUploads(req, res, this.uploadsConfig);
    }
  }
開發者ID:apollostack,項目名稱:apollo-server,代碼行數:16,代碼來源:ApolloServer.ts

示例4: async

 return async (request: hapi.Request, _h?: hapi.ResponseToolkit) => {
   if (
     typeof processFileUploads === 'function' &&
     request.mime === 'multipart/form-data'
   ) {
     Object.defineProperty(request, 'payload', {
       value: await processFileUploads(
         request,
         request.response,
         uploadsConfig,
       ),
       writable: false,
     });
   }
 };
開發者ID:apollostack,項目名稱:apollo-server,代碼行數:15,代碼來源:ApolloServer.ts

示例5: async

) => async (ctx: Koa.Context, next: Function) => {
  if (typeis(ctx.req, ['multipart/form-data'])) {
    try {
      ctx.request.body = await processFileUploads(
        ctx.req,
        ctx.res,
        uploadsConfig,
      );
      return next();
    } catch (error) {
      if (error.status && error.expose) ctx.status = error.status;

      throw formatApolloErrors([error], {
        formatter: server.requestOptions.formatError,
        debug: server.requestOptions.debug,
      });
    }
  } else {
    return next();
  }
};
開發者ID:apollostack,項目名稱:apollo-server,代碼行數:21,代碼來源:ApolloServer.ts


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