本文整理汇总了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;未经允许,请勿转载。 |
请发表评论