UNPKG

graphql-yoga

Version:
17 lines (16 loc) • 579 B
export function useHealthCheck({ id = Date.now().toString(), endpoint = '/health', } = {}) { return { onRequest({ endResponse, fetchAPI, request, serverContext }) { if (request.url.endsWith(endpoint)) { serverContext.log.debug('Responding Health Check'); const response = new fetchAPI.Response(null, { status: 200, headers: { 'x-yoga-id': id, }, }); endResponse(response); } }, }; }