graphql-yoga
Version:
<div align="center"><img src="./website/public/cover.png" width="720" /></div>
17 lines (16 loc) • 571 B
JavaScript
export function useHealthCheck({ id = Date.now().toString(), logger = console, endpoint = '/health', } = {}) {
return {
onRequest({ endResponse, fetchAPI, request }) {
if (request.url.endsWith(endpoint)) {
logger.debug('Responding Health Check');
const response = new fetchAPI.Response(null, {
status: 200,
headers: {
'x-yoga-id': id,
},
});
endResponse(response);
}
},
};
}