helmetjs / helmet

Help secure Express apps with various HTTP headers
https://helmetjs.github.io/
MIT License
10.23k stars 369 forks source link

"Middlewares" is not grammatically correct #297

Closed Fdawgs closed 3 years ago

Fdawgs commented 3 years ago

Hi there!

Noticed the usage of "Middlewares" quite a bit in this repo. "Middleware" is an uncountable noun, so the plural of "Middleware" is still "Middleware" and not "Middlewares".

I'm happy to make a PR to fix this if you want?

EvanHahn commented 3 years ago

In summary: it's not clear to me that there's a consensus here.

This is something I thought about while writing this documentation and my old book about Express. It didn't seem like there was a clear consensus on whether "middlewares" was acceptable. Furthermore, it didn't seem like there was consensus about what the word "middleware" even meant.

The READMEs for body-parser and vhost, both maintained by Express, say "middlewares" a few times. Rails's documentation says "middlewares" and Redux uses the word in variable names. In contrast, Connect and Ruby's Rack use "middleware", not "middlewares", to describe more than one.

To look at dictionaries: Wiktionary says that the plural is "middlewares"; Dictionary.com, the Collins English Dictionary, and the American Heritage Dictionary don't seem to opine; Merriam-Webster doesn't even have the word; the Oxford Advanced Learner's Dictionary says the word is uncountable, like you say. (I don't have an Oxford English Dictionary account so I don't know what they say, but it looks like the word was added in 2002 and I would expect it to be the same as the free Oxford Learner's resource I found.)

At times, it feels like people dance around ever using "middleware" or "middlewares" when describing more than one. Express's documentation always calls them "middleware functions" when pluralized, but "middleware" elsewhere. I certainly did this while writing my book.

There's also the question of what the words actually mean in the context of Express. Express's docs define them like this (emphasis and links removed):

Middleware functions are functions that have access to the request object (req), the response object (res), and the next middleware function in the application’s request-response cycle.

You'll notice that they don't actually define the word "middleware"; they only define "middleware functions". helmet() returns a middleware function (it's a function with req, res, and next), but is helmet itself a middleware function before you call it? I would say that it's not—it's a middleware—but it's not super clear, at least to me.

I don't know what the right answer is, but I've settled on the word "middlewares". Happy to discuss changing it.

Fdawgs commented 3 years ago

Thanks for the comprehensive response @EvanHahn !

davidkhierl commented 3 years ago

is this related to the issue I'm having? tried it on yarn 2 pnp and showing errors

.yarn/cache/helmet-npm-4.4.1-286ac392ee-32f5ca0517.zip/node_modules/helmet/dist/middlewares/content-security-policy/index.d.ts:1:23 - error TS2688: Cannot find type definition file for 'node'.        

/// <reference types="node" />
EvanHahn commented 3 years ago

@Fdawgs No problem! I'm going to close this issue, but let me know if that's wrong and I can reopen.

@davidkhierl I don't think it's related. Would you open a new issue?