Infer the content-type of a request by headers. This is a fork of type-is, but this one accepts headers instead of a request object. Writen in TypeScript in format ESM.
npm install @ts-stack/type-isimporthttpfrom'http';import{typeIs}from'@ts-stack/type-is';http.createServer(function(req,res){constistext=typeIs(req.headers,['text/*'])res.end('you '+(istext ? 'sent' : 'did not send')+' me text')})