helmetjs / helmet

Help secure Express apps with various HTTP headers

Home Page:https://helmetjs.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

interface exports

soloroman opened this issue · comments

Could you please add interface exports?

I am using my custom wrapper for config selection and I would like to declare types.

There are 2 ways:

  • Declare interfaces by myself and when package updates, this is potentially weak place.
  • Just export interfaces as many packages do.
function expressHelmet({
  options,
  serviceCase,
}: {
  options?: any // <- I would like to avoid this
  serviceCase?: ServiceType;
}) {
  return helmet(options || switcher(serviceCase) || {});
}

Unfortunately, I won't be able to export HelmetOptions in this major version without making a breaking change. Would something like this work for you?

type HelmetOptions = Parameters<typeof helmet>[0];

In the next major version of Helmet, I plan to export this.

I'm going to close this issue, but see #320 for more details.

I just released Helmet v5.0.0-beta.1 which includes this change. You can now import helmet, { HelmetOptions } from 'helmet'.

Please give it a try with npm install helmet@5.0.0-beta.1 and let me know if there are any problems! Feel free to reply here or email me@evanhahn.com with any feedback.