本文整理汇总了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);
}
};
示例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();
}
};
示例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);
}
}
示例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,
});
}
};
示例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();
}
};