Skip to content
generated from ts-stack/starter

A fork of the widely used `type-is` library, but this one accepts headers instead of a request object.

License

Notifications You must be signed in to change notification settings

ts-stack/type-is

Repository files navigation

@ts-stack/type-is

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.

Install

npm install @ts-stack/type-is

Usage

import http from 'http';
import { typeIs } from '@ts-stack/type-is';

http.createServer(function (req, res) {
  const istext = typeIs(req.headers, ['text/*'])
  res.end('you ' + (istext ? 'sent' : 'did not send') + ' me text')
})

License

MIT

About

A fork of the widely used `type-is` library, but this one accepts headers instead of a request object.

Resources

License

Stars

Watchers

Forks

Packages

No packages published