graphql-yoga
Version:
18 lines (17 loc) • 618 B
JavaScript
export function useHealthCheck({ id = Date.now().toString(), logger = console, endpoint = '/health', } = {}) {
return {
async onRequest({ endResponse, fetchAPI, url }) {
const { pathname: requestPath } = url;
if (requestPath === endpoint) {
logger.debug('Responding Health Check');
const response = new fetchAPI.Response(null, {
status: 200,
headers: {
'x-yoga-id': id,
},
});
endResponse(response);
}
},
};
}